Skip to content

Commit c936e58

Browse files
authored
Merge pull request #138 from tcdent/agentops-tags
Dynamically generate tags sent to AgentOps for better observability.
2 parents 40f5f04 + 4ea260d commit c936e58

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

agentstack/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,20 @@
66
"""
77
from pathlib import Path
88
from agentstack import conf
9+
from agentstack.utils import get_framework
910
from agentstack.inputs import get_inputs
1011

1112
___all___ = [
1213
"conf",
14+
"get_tags",
15+
"get_framework",
1316
"get_inputs",
1417
]
1518

19+
20+
def get_tags() -> list[str]:
21+
"""
22+
Get a list of tags relevant to the user's project.
23+
"""
24+
return ['agentstack', get_framework(), *conf.get_installed_tools()]
25+

agentstack/conf.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,21 @@ def get_framework() -> Optional[str]:
2323
and if we are inside a project directory.
2424
"""
2525
try:
26-
config = ConfigFile()
27-
return config.framework
26+
return ConfigFile().framework
2827
except FileNotFoundError:
2928
return None # not in a project directory; that's okay
3029

3130

31+
def get_installed_tools() -> list[str]:
32+
"""The tools used in the project. Will be available after PATH has been set
33+
and if we are inside a project directory.
34+
"""
35+
try:
36+
return ConfigFile().tools
37+
except FileNotFoundError:
38+
return []
39+
40+
3241
class ConfigFile(BaseModel):
3342
"""
3443
Interface for interacting with the agentstack.json file inside a project directory.

agentstack/templates/crewai/{{cookiecutter.project_metadata.project_slug}}/src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import agentstack
55
import agentops
66

7-
agentops.init(default_tags=['crewai', 'agentstack'])
7+
agentops.init(default_tags=agentstack.get_tags())
88

99
instance = {{cookiecutter.project_metadata.project_name|replace('-', '')|replace('_', '')|capitalize}}Crew().crew()
1010

0 commit comments

Comments
 (0)