traceai-agno 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- traceai_agno-0.1.0/.gitignore +85 -0
- traceai_agno-0.1.0/PKG-INFO +263 -0
- traceai_agno-0.1.0/README.md +230 -0
- traceai_agno-0.1.0/examples/agent_with_tools.py +136 -0
- traceai_agno-0.1.0/examples/basic_agent.py +56 -0
- traceai_agno-0.1.0/examples/team_example.py +90 -0
- traceai_agno-0.1.0/examples/workflow_example.py +109 -0
- traceai_agno-0.1.0/pyproject.toml +67 -0
- traceai_agno-0.1.0/tests/__init__.py +1 -0
- traceai_agno-0.1.0/tests/conftest.py +294 -0
- traceai_agno-0.1.0/tests/test_attributes.py +505 -0
- traceai_agno-0.1.0/tests/test_instrumentor.py +350 -0
- traceai_agno-0.1.0/traceai_agno/__init__.py +58 -0
- traceai_agno-0.1.0/traceai_agno/_attributes.py +337 -0
- traceai_agno-0.1.0/traceai_agno/_instrumentor.py +228 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
*.py[cod]
|
|
2
|
+
|
|
3
|
+
# C extensions
|
|
4
|
+
*.so
|
|
5
|
+
|
|
6
|
+
# IDEs
|
|
7
|
+
.idea/
|
|
8
|
+
.vscode/
|
|
9
|
+
|
|
10
|
+
# Packages
|
|
11
|
+
*.egg
|
|
12
|
+
*.egg-info
|
|
13
|
+
.eggs/
|
|
14
|
+
# build
|
|
15
|
+
parts
|
|
16
|
+
bin
|
|
17
|
+
var
|
|
18
|
+
sdist
|
|
19
|
+
dist
|
|
20
|
+
develop-eggs
|
|
21
|
+
.installed.cfg
|
|
22
|
+
lib
|
|
23
|
+
lib64
|
|
24
|
+
|
|
25
|
+
# Installer logs
|
|
26
|
+
pip-log.txt
|
|
27
|
+
|
|
28
|
+
# Unit test / coverage reports
|
|
29
|
+
.coverage
|
|
30
|
+
.tox
|
|
31
|
+
nosetests.xml
|
|
32
|
+
|
|
33
|
+
# Complexity
|
|
34
|
+
output/*.html
|
|
35
|
+
output/*/index.html
|
|
36
|
+
|
|
37
|
+
# Sphinx
|
|
38
|
+
docs/_build
|
|
39
|
+
|
|
40
|
+
# Cookiecutter
|
|
41
|
+
output/
|
|
42
|
+
|
|
43
|
+
.workon
|
|
44
|
+
|
|
45
|
+
**.wav
|
|
46
|
+
**.joblib
|
|
47
|
+
|
|
48
|
+
**/__pycache__
|
|
49
|
+
|
|
50
|
+
#Excel files
|
|
51
|
+
*.xlsx
|
|
52
|
+
#csv files
|
|
53
|
+
*.csv
|
|
54
|
+
#virtual environments
|
|
55
|
+
**/.venv
|
|
56
|
+
**/env
|
|
57
|
+
**/.env
|
|
58
|
+
*.DS_Store
|
|
59
|
+
*.pdf
|
|
60
|
+
**/node_modules
|
|
61
|
+
**/dist
|
|
62
|
+
*.log
|
|
63
|
+
.DS_Store
|
|
64
|
+
**/package-lock.json
|
|
65
|
+
**/tsconfig.tsbuildinfo
|
|
66
|
+
**/.fi
|
|
67
|
+
**/.pytest_cache
|
|
68
|
+
planning/
|
|
69
|
+
|
|
70
|
+
# Java build artifacts
|
|
71
|
+
**/target/
|
|
72
|
+
**/.settings/
|
|
73
|
+
**/.project
|
|
74
|
+
**/.classpath
|
|
75
|
+
**/.factorypath
|
|
76
|
+
*.class
|
|
77
|
+
*.jar
|
|
78
|
+
*.war
|
|
79
|
+
|
|
80
|
+
# C# build artifacts
|
|
81
|
+
**/bin/
|
|
82
|
+
**/obj/
|
|
83
|
+
|
|
84
|
+
# Python
|
|
85
|
+
**/uv.lock
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: traceai-agno
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: TraceAI instrumentation for Agno Agent Framework
|
|
5
|
+
Project-URL: Homepage, https://github.com/futureagi/traceai
|
|
6
|
+
Project-URL: Documentation, https://docs.futureagi.com/traceai
|
|
7
|
+
Project-URL: Repository, https://github.com/futureagi/traceai
|
|
8
|
+
Author-email: FutureAGI <support@futureagi.com>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
Keywords: agents,agno,ai,llm,observability,openinference,opentelemetry,traceai,tracing
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: System :: Monitoring
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: fi-instrumentation-otel>=0.1.11
|
|
23
|
+
Requires-Dist: opentelemetry-api>=1.0.0
|
|
24
|
+
Requires-Dist: opentelemetry-exporter-otlp>=1.0.0
|
|
25
|
+
Requires-Dist: opentelemetry-sdk>=1.0.0
|
|
26
|
+
Provides-Extra: agno
|
|
27
|
+
Requires-Dist: agno>=2.0.0; extra == 'agno'
|
|
28
|
+
Requires-Dist: openinference-instrumentation-agno>=0.1.0; extra == 'agno'
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# TraceAI Agno Instrumentation
|
|
35
|
+
|
|
36
|
+
OpenTelemetry instrumentation for [Agno](https://github.com/agno-agi/agno), the high-performance AI agent framework.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install traceai-agno
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
For full functionality, also install the Agno framework and its OpenInference instrumentation:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install agno openinference-instrumentation-agno
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Quick Start
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from fi_instrumentation import register
|
|
54
|
+
from fi_instrumentation.fi_types import ProjectType
|
|
55
|
+
from traceai_agno import configure_agno_tracing
|
|
56
|
+
|
|
57
|
+
# Setup TraceAI
|
|
58
|
+
trace_provider = register(
|
|
59
|
+
project_type=ProjectType.OBSERVE,
|
|
60
|
+
project_name="agno-agent",
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
# Configure Agno to use TraceAI (call BEFORE creating agents)
|
|
64
|
+
configure_agno_tracing(tracer_provider=trace_provider)
|
|
65
|
+
|
|
66
|
+
# Now import and use Agno normally
|
|
67
|
+
from agno.agent import Agent
|
|
68
|
+
from agno.models.openai import OpenAIChat
|
|
69
|
+
|
|
70
|
+
agent = Agent(
|
|
71
|
+
model=OpenAIChat(id="gpt-4"),
|
|
72
|
+
description="A helpful assistant",
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
response = agent.run("What is the capital of France?")
|
|
76
|
+
print(response.content)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Configuration Options
|
|
80
|
+
|
|
81
|
+
### Using fi_instrumentation (Recommended)
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from fi_instrumentation import register
|
|
85
|
+
from fi_instrumentation.fi_types import ProjectType
|
|
86
|
+
from traceai_agno import configure_agno_tracing
|
|
87
|
+
|
|
88
|
+
trace_provider = register(
|
|
89
|
+
project_type=ProjectType.OBSERVE,
|
|
90
|
+
project_name="my-agno-project",
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
configure_agno_tracing(tracer_provider=trace_provider)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Direct OTLP Configuration
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from traceai_agno import configure_agno_tracing
|
|
100
|
+
|
|
101
|
+
configure_agno_tracing(
|
|
102
|
+
otlp_endpoint="https://api.traceai.com/v1/traces",
|
|
103
|
+
otlp_headers={"Authorization": "Bearer YOUR_API_KEY"},
|
|
104
|
+
project_name="my-agno-project",
|
|
105
|
+
)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Using Custom Tracer Provider
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from traceai_agno import setup_traceai_exporter, configure_agno_tracing
|
|
112
|
+
|
|
113
|
+
# Create a custom tracer provider
|
|
114
|
+
provider = setup_traceai_exporter(
|
|
115
|
+
endpoint="https://api.traceai.com/v1/traces",
|
|
116
|
+
headers={"Authorization": "Bearer YOUR_API_KEY"},
|
|
117
|
+
service_name="my-agno-service",
|
|
118
|
+
use_batch_processor=True,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
configure_agno_tracing(tracer_provider=provider)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Features
|
|
125
|
+
|
|
126
|
+
### Agent Tracing
|
|
127
|
+
|
|
128
|
+
Automatically captures:
|
|
129
|
+
- Agent name, type, and configuration
|
|
130
|
+
- Model information (provider, ID, temperature, etc.)
|
|
131
|
+
- Tool count and configuration
|
|
132
|
+
- Memory and knowledge settings
|
|
133
|
+
- Debug mode and markdown settings
|
|
134
|
+
|
|
135
|
+
### Tool Tracing
|
|
136
|
+
|
|
137
|
+
Tracks tool executions including:
|
|
138
|
+
- Tool name and description
|
|
139
|
+
- Input parameters
|
|
140
|
+
- Execution results
|
|
141
|
+
|
|
142
|
+
### Team Tracing
|
|
143
|
+
|
|
144
|
+
For multi-agent setups:
|
|
145
|
+
- Team name
|
|
146
|
+
- Team member agents
|
|
147
|
+
- Inter-agent communication
|
|
148
|
+
|
|
149
|
+
### Workflow Tracing
|
|
150
|
+
|
|
151
|
+
For complex workflows:
|
|
152
|
+
- Workflow name
|
|
153
|
+
- Step execution
|
|
154
|
+
- State transitions
|
|
155
|
+
|
|
156
|
+
## Span Attributes
|
|
157
|
+
|
|
158
|
+
The instrumentation adds the following attributes to spans:
|
|
159
|
+
|
|
160
|
+
### LLM Attributes (OpenTelemetry GenAI Semantic Conventions)
|
|
161
|
+
- `gen_ai.system` - Model provider (openai, anthropic, etc.)
|
|
162
|
+
- `gen_ai.request.model` - Requested model ID
|
|
163
|
+
- `gen_ai.request.temperature` - Temperature setting
|
|
164
|
+
- `gen_ai.request.max_tokens` - Max tokens setting
|
|
165
|
+
- `gen_ai.usage.input_tokens` - Input token count
|
|
166
|
+
- `gen_ai.usage.output_tokens` - Output token count
|
|
167
|
+
|
|
168
|
+
### Agent Attributes
|
|
169
|
+
- `agent.name` - Agent name
|
|
170
|
+
- `agent.type` - Agent type
|
|
171
|
+
- `agent.description` - Agent description
|
|
172
|
+
- `agent.instructions` - Agent instructions
|
|
173
|
+
|
|
174
|
+
### Agno-Specific Attributes
|
|
175
|
+
- `agno.agent.id` - Agent ID
|
|
176
|
+
- `agno.tool_count` - Number of tools
|
|
177
|
+
- `agno.team.name` - Team name
|
|
178
|
+
- `agno.team.members` - Team member names
|
|
179
|
+
- `agno.workflow.name` - Workflow name
|
|
180
|
+
- `agno.session.id` - Session ID
|
|
181
|
+
- `agno.user.id` - User ID
|
|
182
|
+
- `agno.debug_mode` - Debug mode status
|
|
183
|
+
- `agno.memory.enabled` - Memory enabled status
|
|
184
|
+
- `agno.knowledge.enabled` - Knowledge enabled status
|
|
185
|
+
|
|
186
|
+
## Helper Functions
|
|
187
|
+
|
|
188
|
+
### Extract Agent Attributes
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
from traceai_agno import get_agent_attributes
|
|
192
|
+
|
|
193
|
+
agent = Agent(model=OpenAIChat(id="gpt-4"), name="MyAgent")
|
|
194
|
+
attrs = get_agent_attributes(agent)
|
|
195
|
+
# {'agent.name': 'MyAgent', 'agent.type': 'Agent', ...}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Extract Tool Attributes
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
from traceai_agno import get_tool_attributes
|
|
202
|
+
|
|
203
|
+
def my_tool(query: str) -> str:
|
|
204
|
+
"""Search for information."""
|
|
205
|
+
return "result"
|
|
206
|
+
|
|
207
|
+
attrs = get_tool_attributes(my_tool)
|
|
208
|
+
# {'gen_ai.tool.name': 'my_tool', 'gen_ai.tool.description': 'Search for information.'}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Extract Team Attributes
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
from traceai_agno import get_team_attributes
|
|
215
|
+
|
|
216
|
+
team = Team(name="ResearchTeam", agents=[agent1, agent2])
|
|
217
|
+
attrs = get_team_attributes(team)
|
|
218
|
+
# {'agno.team.name': 'ResearchTeam', 'agno.team.members': 'Agent1, Agent2'}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Detect Model Provider
|
|
222
|
+
|
|
223
|
+
```python
|
|
224
|
+
from traceai_agno import get_model_provider
|
|
225
|
+
|
|
226
|
+
provider = get_model_provider("gpt-4") # Returns "openai"
|
|
227
|
+
provider = get_model_provider("claude-3-sonnet") # Returns "anthropic"
|
|
228
|
+
provider = get_model_provider("ollama/llama3") # Returns "ollama"
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Create Trace Context
|
|
232
|
+
|
|
233
|
+
```python
|
|
234
|
+
from traceai_agno import create_trace_context
|
|
235
|
+
|
|
236
|
+
context = create_trace_context(
|
|
237
|
+
session_id="session-123",
|
|
238
|
+
user_id="user-456",
|
|
239
|
+
tags=["production"],
|
|
240
|
+
metadata={"environment": "prod"},
|
|
241
|
+
)
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Examples
|
|
245
|
+
|
|
246
|
+
See the [examples](./examples) directory for complete usage examples:
|
|
247
|
+
|
|
248
|
+
- `basic_agent.py` - Simple agent with tracing
|
|
249
|
+
- `agent_with_tools.py` - Agent with tool calling
|
|
250
|
+
- `team_example.py` - Multi-agent team coordination
|
|
251
|
+
- `workflow_example.py` - Complex workflow tracing
|
|
252
|
+
|
|
253
|
+
## Requirements
|
|
254
|
+
|
|
255
|
+
- Python >= 3.10
|
|
256
|
+
- opentelemetry-api >= 1.0.0
|
|
257
|
+
- opentelemetry-sdk >= 1.0.0
|
|
258
|
+
- opentelemetry-exporter-otlp >= 1.0.0
|
|
259
|
+
- fi-instrumentation >= 0.1.0
|
|
260
|
+
|
|
261
|
+
## License
|
|
262
|
+
|
|
263
|
+
Apache-2.0
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# TraceAI Agno Instrumentation
|
|
2
|
+
|
|
3
|
+
OpenTelemetry instrumentation for [Agno](https://github.com/agno-agi/agno), the high-performance AI agent framework.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install traceai-agno
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
For full functionality, also install the Agno framework and its OpenInference instrumentation:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install agno openinference-instrumentation-agno
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from fi_instrumentation import register
|
|
21
|
+
from fi_instrumentation.fi_types import ProjectType
|
|
22
|
+
from traceai_agno import configure_agno_tracing
|
|
23
|
+
|
|
24
|
+
# Setup TraceAI
|
|
25
|
+
trace_provider = register(
|
|
26
|
+
project_type=ProjectType.OBSERVE,
|
|
27
|
+
project_name="agno-agent",
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Configure Agno to use TraceAI (call BEFORE creating agents)
|
|
31
|
+
configure_agno_tracing(tracer_provider=trace_provider)
|
|
32
|
+
|
|
33
|
+
# Now import and use Agno normally
|
|
34
|
+
from agno.agent import Agent
|
|
35
|
+
from agno.models.openai import OpenAIChat
|
|
36
|
+
|
|
37
|
+
agent = Agent(
|
|
38
|
+
model=OpenAIChat(id="gpt-4"),
|
|
39
|
+
description="A helpful assistant",
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
response = agent.run("What is the capital of France?")
|
|
43
|
+
print(response.content)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Configuration Options
|
|
47
|
+
|
|
48
|
+
### Using fi_instrumentation (Recommended)
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from fi_instrumentation import register
|
|
52
|
+
from fi_instrumentation.fi_types import ProjectType
|
|
53
|
+
from traceai_agno import configure_agno_tracing
|
|
54
|
+
|
|
55
|
+
trace_provider = register(
|
|
56
|
+
project_type=ProjectType.OBSERVE,
|
|
57
|
+
project_name="my-agno-project",
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
configure_agno_tracing(tracer_provider=trace_provider)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Direct OTLP Configuration
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from traceai_agno import configure_agno_tracing
|
|
67
|
+
|
|
68
|
+
configure_agno_tracing(
|
|
69
|
+
otlp_endpoint="https://api.traceai.com/v1/traces",
|
|
70
|
+
otlp_headers={"Authorization": "Bearer YOUR_API_KEY"},
|
|
71
|
+
project_name="my-agno-project",
|
|
72
|
+
)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Using Custom Tracer Provider
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from traceai_agno import setup_traceai_exporter, configure_agno_tracing
|
|
79
|
+
|
|
80
|
+
# Create a custom tracer provider
|
|
81
|
+
provider = setup_traceai_exporter(
|
|
82
|
+
endpoint="https://api.traceai.com/v1/traces",
|
|
83
|
+
headers={"Authorization": "Bearer YOUR_API_KEY"},
|
|
84
|
+
service_name="my-agno-service",
|
|
85
|
+
use_batch_processor=True,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
configure_agno_tracing(tracer_provider=provider)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Features
|
|
92
|
+
|
|
93
|
+
### Agent Tracing
|
|
94
|
+
|
|
95
|
+
Automatically captures:
|
|
96
|
+
- Agent name, type, and configuration
|
|
97
|
+
- Model information (provider, ID, temperature, etc.)
|
|
98
|
+
- Tool count and configuration
|
|
99
|
+
- Memory and knowledge settings
|
|
100
|
+
- Debug mode and markdown settings
|
|
101
|
+
|
|
102
|
+
### Tool Tracing
|
|
103
|
+
|
|
104
|
+
Tracks tool executions including:
|
|
105
|
+
- Tool name and description
|
|
106
|
+
- Input parameters
|
|
107
|
+
- Execution results
|
|
108
|
+
|
|
109
|
+
### Team Tracing
|
|
110
|
+
|
|
111
|
+
For multi-agent setups:
|
|
112
|
+
- Team name
|
|
113
|
+
- Team member agents
|
|
114
|
+
- Inter-agent communication
|
|
115
|
+
|
|
116
|
+
### Workflow Tracing
|
|
117
|
+
|
|
118
|
+
For complex workflows:
|
|
119
|
+
- Workflow name
|
|
120
|
+
- Step execution
|
|
121
|
+
- State transitions
|
|
122
|
+
|
|
123
|
+
## Span Attributes
|
|
124
|
+
|
|
125
|
+
The instrumentation adds the following attributes to spans:
|
|
126
|
+
|
|
127
|
+
### LLM Attributes (OpenTelemetry GenAI Semantic Conventions)
|
|
128
|
+
- `gen_ai.system` - Model provider (openai, anthropic, etc.)
|
|
129
|
+
- `gen_ai.request.model` - Requested model ID
|
|
130
|
+
- `gen_ai.request.temperature` - Temperature setting
|
|
131
|
+
- `gen_ai.request.max_tokens` - Max tokens setting
|
|
132
|
+
- `gen_ai.usage.input_tokens` - Input token count
|
|
133
|
+
- `gen_ai.usage.output_tokens` - Output token count
|
|
134
|
+
|
|
135
|
+
### Agent Attributes
|
|
136
|
+
- `agent.name` - Agent name
|
|
137
|
+
- `agent.type` - Agent type
|
|
138
|
+
- `agent.description` - Agent description
|
|
139
|
+
- `agent.instructions` - Agent instructions
|
|
140
|
+
|
|
141
|
+
### Agno-Specific Attributes
|
|
142
|
+
- `agno.agent.id` - Agent ID
|
|
143
|
+
- `agno.tool_count` - Number of tools
|
|
144
|
+
- `agno.team.name` - Team name
|
|
145
|
+
- `agno.team.members` - Team member names
|
|
146
|
+
- `agno.workflow.name` - Workflow name
|
|
147
|
+
- `agno.session.id` - Session ID
|
|
148
|
+
- `agno.user.id` - User ID
|
|
149
|
+
- `agno.debug_mode` - Debug mode status
|
|
150
|
+
- `agno.memory.enabled` - Memory enabled status
|
|
151
|
+
- `agno.knowledge.enabled` - Knowledge enabled status
|
|
152
|
+
|
|
153
|
+
## Helper Functions
|
|
154
|
+
|
|
155
|
+
### Extract Agent Attributes
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
from traceai_agno import get_agent_attributes
|
|
159
|
+
|
|
160
|
+
agent = Agent(model=OpenAIChat(id="gpt-4"), name="MyAgent")
|
|
161
|
+
attrs = get_agent_attributes(agent)
|
|
162
|
+
# {'agent.name': 'MyAgent', 'agent.type': 'Agent', ...}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Extract Tool Attributes
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
from traceai_agno import get_tool_attributes
|
|
169
|
+
|
|
170
|
+
def my_tool(query: str) -> str:
|
|
171
|
+
"""Search for information."""
|
|
172
|
+
return "result"
|
|
173
|
+
|
|
174
|
+
attrs = get_tool_attributes(my_tool)
|
|
175
|
+
# {'gen_ai.tool.name': 'my_tool', 'gen_ai.tool.description': 'Search for information.'}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Extract Team Attributes
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
from traceai_agno import get_team_attributes
|
|
182
|
+
|
|
183
|
+
team = Team(name="ResearchTeam", agents=[agent1, agent2])
|
|
184
|
+
attrs = get_team_attributes(team)
|
|
185
|
+
# {'agno.team.name': 'ResearchTeam', 'agno.team.members': 'Agent1, Agent2'}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Detect Model Provider
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
from traceai_agno import get_model_provider
|
|
192
|
+
|
|
193
|
+
provider = get_model_provider("gpt-4") # Returns "openai"
|
|
194
|
+
provider = get_model_provider("claude-3-sonnet") # Returns "anthropic"
|
|
195
|
+
provider = get_model_provider("ollama/llama3") # Returns "ollama"
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Create Trace Context
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
from traceai_agno import create_trace_context
|
|
202
|
+
|
|
203
|
+
context = create_trace_context(
|
|
204
|
+
session_id="session-123",
|
|
205
|
+
user_id="user-456",
|
|
206
|
+
tags=["production"],
|
|
207
|
+
metadata={"environment": "prod"},
|
|
208
|
+
)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Examples
|
|
212
|
+
|
|
213
|
+
See the [examples](./examples) directory for complete usage examples:
|
|
214
|
+
|
|
215
|
+
- `basic_agent.py` - Simple agent with tracing
|
|
216
|
+
- `agent_with_tools.py` - Agent with tool calling
|
|
217
|
+
- `team_example.py` - Multi-agent team coordination
|
|
218
|
+
- `workflow_example.py` - Complex workflow tracing
|
|
219
|
+
|
|
220
|
+
## Requirements
|
|
221
|
+
|
|
222
|
+
- Python >= 3.10
|
|
223
|
+
- opentelemetry-api >= 1.0.0
|
|
224
|
+
- opentelemetry-sdk >= 1.0.0
|
|
225
|
+
- opentelemetry-exporter-otlp >= 1.0.0
|
|
226
|
+
- fi-instrumentation >= 0.1.0
|
|
227
|
+
|
|
228
|
+
## License
|
|
229
|
+
|
|
230
|
+
Apache-2.0
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"""Agno agent with tools example with TraceAI instrumentation.
|
|
2
|
+
|
|
3
|
+
This example demonstrates how to set up tracing for an agent with tool calling.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
from typing import Optional
|
|
8
|
+
|
|
9
|
+
# Setup tracing BEFORE importing Agno
|
|
10
|
+
from fi_instrumentation import register
|
|
11
|
+
from fi_instrumentation.fi_types import ProjectType
|
|
12
|
+
from traceai_agno import configure_agno_tracing
|
|
13
|
+
|
|
14
|
+
# Initialize TraceAI
|
|
15
|
+
trace_provider = register(
|
|
16
|
+
project_type=ProjectType.OBSERVE,
|
|
17
|
+
project_name="agno-tools-example",
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
# Configure Agno to use TraceAI
|
|
21
|
+
configure_agno_tracing(tracer_provider=trace_provider)
|
|
22
|
+
|
|
23
|
+
# Now import Agno modules
|
|
24
|
+
from agno.agent import Agent
|
|
25
|
+
from agno.models.openai import OpenAIChat
|
|
26
|
+
from agno.tools import tool
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# Define tools
|
|
30
|
+
@tool
|
|
31
|
+
def get_weather(city: str) -> str:
|
|
32
|
+
"""Get the current weather for a city.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
city: The name of the city to get weather for.
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
A string describing the current weather.
|
|
39
|
+
"""
|
|
40
|
+
# Mock weather data
|
|
41
|
+
weather_data = {
|
|
42
|
+
"new york": "Sunny, 72°F (22°C)",
|
|
43
|
+
"london": "Cloudy, 59°F (15°C)",
|
|
44
|
+
"tokyo": "Rainy, 68°F (20°C)",
|
|
45
|
+
"paris": "Partly cloudy, 65°F (18°C)",
|
|
46
|
+
"sydney": "Clear, 77°F (25°C)",
|
|
47
|
+
}
|
|
48
|
+
city_lower = city.lower()
|
|
49
|
+
return weather_data.get(city_lower, f"Weather data not available for {city}")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@tool
|
|
53
|
+
def calculate(expression: str) -> str:
|
|
54
|
+
"""Evaluate a mathematical expression.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
expression: A mathematical expression to evaluate (e.g., "2 + 2", "10 * 5").
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
The result of the calculation.
|
|
61
|
+
"""
|
|
62
|
+
try:
|
|
63
|
+
# Only allow safe mathematical operations
|
|
64
|
+
allowed_chars = set("0123456789+-*/.(). ")
|
|
65
|
+
if not all(c in allowed_chars for c in expression):
|
|
66
|
+
return "Error: Invalid characters in expression"
|
|
67
|
+
result = eval(expression)
|
|
68
|
+
return str(result)
|
|
69
|
+
except Exception as e:
|
|
70
|
+
return f"Error: {str(e)}"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@tool
|
|
74
|
+
def search_knowledge(query: str, topic: Optional[str] = None) -> str:
|
|
75
|
+
"""Search for information about a topic.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
query: The search query.
|
|
79
|
+
topic: Optional topic to narrow down the search.
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
Relevant information about the query.
|
|
83
|
+
"""
|
|
84
|
+
# Mock knowledge base
|
|
85
|
+
knowledge = {
|
|
86
|
+
"python": "Python is a high-level programming language known for readability.",
|
|
87
|
+
"machine learning": "Machine learning is a subset of AI focused on learning from data.",
|
|
88
|
+
"agno": "Agno is a high-performance AI agent framework for building intelligent agents.",
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
query_lower = query.lower()
|
|
92
|
+
for key, value in knowledge.items():
|
|
93
|
+
if key in query_lower:
|
|
94
|
+
return value
|
|
95
|
+
return f"No specific information found for: {query}"
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def main():
|
|
99
|
+
"""Run an agent with tools example."""
|
|
100
|
+
# Create an agent with tools
|
|
101
|
+
agent = Agent(
|
|
102
|
+
name="ToolAgent",
|
|
103
|
+
model=OpenAIChat(id="gpt-4"),
|
|
104
|
+
description="An assistant that can check weather, perform calculations, and search for information.",
|
|
105
|
+
tools=[get_weather, calculate, search_knowledge],
|
|
106
|
+
instructions=[
|
|
107
|
+
"Use the available tools to help answer questions",
|
|
108
|
+
"For weather questions, use the get_weather tool",
|
|
109
|
+
"For math problems, use the calculate tool",
|
|
110
|
+
"For information queries, use the search_knowledge tool",
|
|
111
|
+
],
|
|
112
|
+
show_tool_calls=True,
|
|
113
|
+
markdown=True,
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
# Example queries that use different tools
|
|
117
|
+
queries = [
|
|
118
|
+
"What's the weather like in Paris?",
|
|
119
|
+
"What is 25 * 4 + 10?",
|
|
120
|
+
"Tell me about machine learning",
|
|
121
|
+
"What's the weather in Tokyo and calculate 100 / 5",
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
print("Agent: ToolAgent")
|
|
125
|
+
print("Tools: get_weather, calculate, search_knowledge")
|
|
126
|
+
print("=" * 50)
|
|
127
|
+
|
|
128
|
+
for query in queries:
|
|
129
|
+
print(f"\nQuery: {query}")
|
|
130
|
+
print("-" * 40)
|
|
131
|
+
response = agent.run(query)
|
|
132
|
+
print(f"Response: {response.content}")
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
if __name__ == "__main__":
|
|
136
|
+
main()
|