agentq 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.
- agentq-0.1.0/PKG-INFO +129 -0
- agentq-0.1.0/README.md +92 -0
- agentq-0.1.0/agentq/__init__.py +22 -0
- agentq-0.1.0/agentq/instrumentation.py +752 -0
- agentq-0.1.0/agentq/integrations/__init__.py +1 -0
- agentq-0.1.0/agentq/integrations/_extract.py +68 -0
- agentq-0.1.0/agentq/integrations/anthropic_patch.py +122 -0
- agentq-0.1.0/agentq/integrations/celery_patch.py +48 -0
- agentq-0.1.0/agentq/integrations/gemini_patch.py +123 -0
- agentq-0.1.0/agentq/integrations/openai_patch.py +119 -0
- agentq-0.1.0/agentq/otel.py +271 -0
- agentq-0.1.0/agentq/registry.py +59 -0
- agentq-0.1.0/agentq.egg-info/PKG-INFO +129 -0
- agentq-0.1.0/agentq.egg-info/SOURCES.txt +17 -0
- agentq-0.1.0/agentq.egg-info/dependency_links.txt +1 -0
- agentq-0.1.0/agentq.egg-info/requires.txt +21 -0
- agentq-0.1.0/agentq.egg-info/top_level.txt +1 -0
- agentq-0.1.0/pyproject.toml +44 -0
- agentq-0.1.0/setup.cfg +4 -0
agentq-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentq
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AgentQ SDK — agent observability for Python.
|
|
5
|
+
Author: Ryan Dao
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/ryandao/agentq
|
|
8
|
+
Project-URL: Repository, https://github.com/ryandao/agentq
|
|
9
|
+
Project-URL: Issues, https://github.com/ryandao/agentq/issues
|
|
10
|
+
Keywords: observability,ai-agents,llm,tracing,opentelemetry
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
18
|
+
Classifier: Topic :: System :: Monitoring
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Requires-Dist: opentelemetry-api>=1.20
|
|
22
|
+
Requires-Dist: opentelemetry-sdk>=1.20
|
|
23
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.20
|
|
24
|
+
Provides-Extra: openai
|
|
25
|
+
Requires-Dist: openai>=1.0; extra == "openai"
|
|
26
|
+
Provides-Extra: anthropic
|
|
27
|
+
Requires-Dist: anthropic>=0.20; extra == "anthropic"
|
|
28
|
+
Provides-Extra: gemini
|
|
29
|
+
Requires-Dist: google-genai>=1.0; extra == "gemini"
|
|
30
|
+
Provides-Extra: celery
|
|
31
|
+
Requires-Dist: celery>=5.0; extra == "celery"
|
|
32
|
+
Provides-Extra: all
|
|
33
|
+
Requires-Dist: openai>=1.0; extra == "all"
|
|
34
|
+
Requires-Dist: anthropic>=0.20; extra == "all"
|
|
35
|
+
Requires-Dist: google-genai>=1.0; extra == "all"
|
|
36
|
+
Requires-Dist: celery>=5.0; extra == "all"
|
|
37
|
+
|
|
38
|
+
# AgentQ SDK
|
|
39
|
+
|
|
40
|
+
A Python SDK for instrumenting AI agents with observability. Traces agent runs, LLM calls, and tool invocations, sending data to an AgentQ server via OpenTelemetry.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install agentq
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
For auto-instrumentation of specific LLM providers, install them alongside:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install agentq openai anthropic google-genai
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Quick Start
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
import agentq
|
|
58
|
+
|
|
59
|
+
# Point to your AgentQ server
|
|
60
|
+
agentq.init(endpoint="http://localhost:3000")
|
|
61
|
+
|
|
62
|
+
# Auto-patch supported LLM libraries
|
|
63
|
+
agentq.instrument()
|
|
64
|
+
|
|
65
|
+
@agentq.agent(name="my-agent")
|
|
66
|
+
def run_task(prompt: str) -> str:
|
|
67
|
+
# Any OpenAI/Anthropic/Gemini calls inside here are traced automatically
|
|
68
|
+
response = openai.chat.completions.create(
|
|
69
|
+
model="gpt-4",
|
|
70
|
+
messages=[{"role": "user", "content": prompt}],
|
|
71
|
+
)
|
|
72
|
+
return response.choices[0].message.content
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Features
|
|
76
|
+
|
|
77
|
+
- **`@agent` decorator** -- Wraps functions and classes to create traced runs with input/output capture
|
|
78
|
+
- **Auto-instrumentation** -- Monkey-patches OpenAI, Anthropic, and Google Gemini to trace every LLM call
|
|
79
|
+
- **Session tracking** -- Group related runs into sessions with the `session` context manager
|
|
80
|
+
- **Nested spans** -- Nested `@agent` calls and manual `track_agent`/`track_llm`/`track_tool` spans
|
|
81
|
+
- **Celery integration** -- Captures queue wait time for Celery tasks
|
|
82
|
+
- **OpenTelemetry native** -- Built on OpenTelemetry, compatible with any OTLP endpoint
|
|
83
|
+
|
|
84
|
+
## API Reference
|
|
85
|
+
|
|
86
|
+
### `agentq.init(endpoint, headers, service_name)`
|
|
87
|
+
|
|
88
|
+
Initialize the SDK. Call once at startup.
|
|
89
|
+
|
|
90
|
+
- `endpoint` -- OTLP HTTP base URL (e.g. `http://localhost:3000`). Falls back to `OTEL_EXPORTER_OTLP_ENDPOINT`.
|
|
91
|
+
- `headers` -- Extra headers for OTLP requests (e.g. `{"Authorization": "Bearer sk-xxx"}`).
|
|
92
|
+
- `service_name` -- Value for the `service.name` resource attribute (default: `"agentq"`).
|
|
93
|
+
|
|
94
|
+
### `agentq.instrument()`
|
|
95
|
+
|
|
96
|
+
Activate auto-instrumentation for OpenAI, Anthropic, Google Gemini, and Celery. Safe to call even if libraries aren't installed.
|
|
97
|
+
|
|
98
|
+
### `@agentq.agent(name, entry_method, description, version, metadata)`
|
|
99
|
+
|
|
100
|
+
Decorator for functions or classes. Creates a traced run for each invocation.
|
|
101
|
+
|
|
102
|
+
For classes, `entry_method` specifies which method(s) to instrument (default: `"execute"`).
|
|
103
|
+
|
|
104
|
+
### `agentq.session(name, session_id, run_id, metadata)`
|
|
105
|
+
|
|
106
|
+
Context manager that groups runs into a session:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
with agentq.session(name="user-chat"):
|
|
110
|
+
run_task("Hello")
|
|
111
|
+
run_task("Follow up")
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Manual Span Context Managers
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
with agentq.track_agent("sub-agent") as span:
|
|
118
|
+
...
|
|
119
|
+
|
|
120
|
+
with agentq.track_llm("gpt-4") as span:
|
|
121
|
+
...
|
|
122
|
+
|
|
123
|
+
with agentq.track_tool("web-search") as span:
|
|
124
|
+
...
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
[MIT](../LICENSE)
|
agentq-0.1.0/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# AgentQ SDK
|
|
2
|
+
|
|
3
|
+
A Python SDK for instrumenting AI agents with observability. Traces agent runs, LLM calls, and tool invocations, sending data to an AgentQ server via OpenTelemetry.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install agentq
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
For auto-instrumentation of specific LLM providers, install them alongside:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install agentq openai anthropic google-genai
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
import agentq
|
|
21
|
+
|
|
22
|
+
# Point to your AgentQ server
|
|
23
|
+
agentq.init(endpoint="http://localhost:3000")
|
|
24
|
+
|
|
25
|
+
# Auto-patch supported LLM libraries
|
|
26
|
+
agentq.instrument()
|
|
27
|
+
|
|
28
|
+
@agentq.agent(name="my-agent")
|
|
29
|
+
def run_task(prompt: str) -> str:
|
|
30
|
+
# Any OpenAI/Anthropic/Gemini calls inside here are traced automatically
|
|
31
|
+
response = openai.chat.completions.create(
|
|
32
|
+
model="gpt-4",
|
|
33
|
+
messages=[{"role": "user", "content": prompt}],
|
|
34
|
+
)
|
|
35
|
+
return response.choices[0].message.content
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Features
|
|
39
|
+
|
|
40
|
+
- **`@agent` decorator** -- Wraps functions and classes to create traced runs with input/output capture
|
|
41
|
+
- **Auto-instrumentation** -- Monkey-patches OpenAI, Anthropic, and Google Gemini to trace every LLM call
|
|
42
|
+
- **Session tracking** -- Group related runs into sessions with the `session` context manager
|
|
43
|
+
- **Nested spans** -- Nested `@agent` calls and manual `track_agent`/`track_llm`/`track_tool` spans
|
|
44
|
+
- **Celery integration** -- Captures queue wait time for Celery tasks
|
|
45
|
+
- **OpenTelemetry native** -- Built on OpenTelemetry, compatible with any OTLP endpoint
|
|
46
|
+
|
|
47
|
+
## API Reference
|
|
48
|
+
|
|
49
|
+
### `agentq.init(endpoint, headers, service_name)`
|
|
50
|
+
|
|
51
|
+
Initialize the SDK. Call once at startup.
|
|
52
|
+
|
|
53
|
+
- `endpoint` -- OTLP HTTP base URL (e.g. `http://localhost:3000`). Falls back to `OTEL_EXPORTER_OTLP_ENDPOINT`.
|
|
54
|
+
- `headers` -- Extra headers for OTLP requests (e.g. `{"Authorization": "Bearer sk-xxx"}`).
|
|
55
|
+
- `service_name` -- Value for the `service.name` resource attribute (default: `"agentq"`).
|
|
56
|
+
|
|
57
|
+
### `agentq.instrument()`
|
|
58
|
+
|
|
59
|
+
Activate auto-instrumentation for OpenAI, Anthropic, Google Gemini, and Celery. Safe to call even if libraries aren't installed.
|
|
60
|
+
|
|
61
|
+
### `@agentq.agent(name, entry_method, description, version, metadata)`
|
|
62
|
+
|
|
63
|
+
Decorator for functions or classes. Creates a traced run for each invocation.
|
|
64
|
+
|
|
65
|
+
For classes, `entry_method` specifies which method(s) to instrument (default: `"execute"`).
|
|
66
|
+
|
|
67
|
+
### `agentq.session(name, session_id, run_id, metadata)`
|
|
68
|
+
|
|
69
|
+
Context manager that groups runs into a session:
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
with agentq.session(name="user-chat"):
|
|
73
|
+
run_task("Hello")
|
|
74
|
+
run_task("Follow up")
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Manual Span Context Managers
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
with agentq.track_agent("sub-agent") as span:
|
|
81
|
+
...
|
|
82
|
+
|
|
83
|
+
with agentq.track_llm("gpt-4") as span:
|
|
84
|
+
...
|
|
85
|
+
|
|
86
|
+
with agentq.track_tool("web-search") as span:
|
|
87
|
+
...
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
[MIT](../LICENSE)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from agentq.registry import init, instrument
|
|
2
|
+
from agentq.instrumentation import (
|
|
3
|
+
agent,
|
|
4
|
+
session,
|
|
5
|
+
current_span,
|
|
6
|
+
track_agent,
|
|
7
|
+
track_llm,
|
|
8
|
+
track_tool,
|
|
9
|
+
ObservabilityLogHandler,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"init",
|
|
14
|
+
"instrument",
|
|
15
|
+
"agent",
|
|
16
|
+
"session",
|
|
17
|
+
"current_span",
|
|
18
|
+
"track_agent",
|
|
19
|
+
"track_llm",
|
|
20
|
+
"track_tool",
|
|
21
|
+
"ObservabilityLogHandler",
|
|
22
|
+
]
|