agentbyte 0.3.2__tar.gz → 0.3.6__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.
- agentbyte-0.3.6/.github/skills/agentbyte-llm-client/SKILL.md +127 -0
- agentbyte-0.3.6/.github/skills/agentbyte-middleware/SKILL.md +75 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/CHANGELOG.md +44 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/PKG-INFO +11 -2
- {agentbyte-0.3.2 → agentbyte-0.3.6}/README.md +10 -1
- agentbyte-0.3.6/src/agentbyte/__about__.py +2 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/__init__.py +2 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/llm/__init__.py +16 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/llm/azure_openai.py +21 -35
- agentbyte-0.3.6/src/agentbyte/llm/azure_openai_embedding.py +547 -0
- agentbyte-0.3.6/src/agentbyte/llm/embeddings_base.py +119 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/llm/openai.py +16 -38
- agentbyte-0.3.6/src/agentbyte/llm/openai_embedding.py +314 -0
- agentbyte-0.3.6/src/agentbyte/llm/pricing.py +219 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/llm/settings.py +20 -1
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/llm/types.py +64 -1
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/middleware/base.py +68 -21
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/middleware/otel.py +81 -12
- agentbyte-0.3.6/src/agentbyte/notebook.py +58 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/workflow/__init__.py +4 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/workflow/core/models.py +18 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/workflow/core/runner.py +48 -6
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/workflow/core/workflow.py +51 -4
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/llm/test_azure_client.py +25 -0
- agentbyte-0.3.6/tests/llm/test_azure_embedding_client.py +160 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/llm/test_openai_client.py +25 -0
- agentbyte-0.3.6/tests/llm/test_openai_embedding_client.py +157 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/middleware/test_middleware_chain.py +18 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/workflow/test_workflow_class.py +76 -1
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/workflow/test_workflow_runner.py +172 -1
- agentbyte-0.3.2/.github/skills/agentbyte-llm-client/SKILL.md +0 -63
- agentbyte-0.3.2/.github/skills/agentbyte-middleware/SKILL.md +0 -35
- agentbyte-0.3.2/src/agentbyte/__about__.py +0 -2
- {agentbyte-0.3.2 → agentbyte-0.3.6}/.github/skills/agentbyte-agent-as-tool/SKILL.md +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/.github/skills/agentbyte-dataset/SKILL.md +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/.github/skills/agentbyte-function-tools/SKILL.md +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/.github/skills/agentbyte-list-memory/SKILL.md +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/.github/skills/agentbyte-memory-tool/SKILL.md +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/.github/skills/agentbyte-multi-turn-context/SKILL.md +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/.github/skills/agentbyte-otel-tracing/SKILL.md +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/.github/skills/agentbyte-simple-agent/SKILL.md +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/.github/skills/agentbyte-tool-approval/SKILL.md +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/.github/skills/skill-authoring/SKILL.md +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/.gitignore +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/LICENSE +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/pyproject.toml +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/agents/__init__.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/agents/agent.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/agents/agent_as_tool.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/agents/base.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/agents/types.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/cancellation_token.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/cli/__init__.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/cli/main.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/component.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/context.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/dataset/__init__.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/dataset/base.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/dataset/json.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/dataset/loader.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/dataset/loaders.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/dataset/sqlite.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/entity.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/llm/auth.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/llm/base.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/memory/__init__.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/memory/base.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/messages.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/middleware/__init__.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/session.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/tools/__init__.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/tools/base.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/tools/core_tools.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/tools/decorator.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/tools/memory_tool.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/types.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/workflow/core/__init__.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/workflow/core/checkpoint.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/workflow/defaults.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/workflow/schema_utils.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/workflow/steps/__init__.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/workflow/steps/agentbyte_agent.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/workflow/steps/echo.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/workflow/steps/function.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/workflow/steps/http.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/workflow/steps/step.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/workflow/steps/transform.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/src/agentbyte/workflow/visualizer.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/agents/test_agent_as_tool.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/agents/test_agent_basic.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/agents/test_agent_event_types.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/agents/test_agent_memory_integration.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/agents/test_agent_middleware_integration.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/agents/test_agent_stream_events.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/agents/test_tool_approval.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/cli/test_create_skills.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/llm/test_llm_types.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/memory/test_memory.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/middleware/test_otel.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/test_cancellation_token.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/test_context.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/test_messages.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/test_package_api.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/test_session.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/test_types.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/tools/test_memory_tool.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/tools/test_tools.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/workflow/test_checkpoint.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/workflow/test_workflow_models.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/workflow/test_workflow_steps.py +0 -0
- {agentbyte-0.3.2 → agentbyte-0.3.6}/tests/workflow/test_workflow_visualizer.py +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
````skill
|
|
2
|
+
---
|
|
3
|
+
name: agentbyte-llm-client
|
|
4
|
+
description: Guide for initializing Agentbyte chat and embedding clients for OpenAI/Azure OpenAI. Use this when setting up authentication, provider fallback, or validating usage/cost metadata from results.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Use this skill when a user needs to initialize Agentbyte model clients (`OpenAI*` / `AzureOpenAI*`) for either chat completion or embeddings.
|
|
8
|
+
|
|
9
|
+
## Supported client families
|
|
10
|
+
|
|
11
|
+
- **Chat:** `OpenAIChatCompletionClient`, `AzureOpenAIChatCompletionClient`
|
|
12
|
+
- **Embeddings:** `OpenAIEmbeddingClient`, `AzureOpenAIEmbeddingClient`
|
|
13
|
+
|
|
14
|
+
## Core Patterns
|
|
15
|
+
|
|
16
|
+
### 1. OpenAI Chat Client Initialization
|
|
17
|
+
|
|
18
|
+
#### Method A: Env-based factory (Recommended)
|
|
19
|
+
```python
|
|
20
|
+
from agentbyte.llm.openai import OpenAIChatCompletionClient
|
|
21
|
+
|
|
22
|
+
model_client = OpenAIChatCompletionClient.from_api_key(
|
|
23
|
+
model="gpt-4o",
|
|
24
|
+
config={"max_completion_tokens": 500},
|
|
25
|
+
)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
#### Method B: Direct Dependency Injection
|
|
29
|
+
```python
|
|
30
|
+
import os
|
|
31
|
+
from openai import AsyncOpenAI
|
|
32
|
+
from agentbyte.llm.openai import OpenAIChatCompletionClient
|
|
33
|
+
|
|
34
|
+
raw_client = AsyncOpenAI(api_key=os.environ["OPENAI_API_KEY"], timeout=30.0)
|
|
35
|
+
model_client = OpenAIChatCompletionClient(model="gpt-4o", client=raw_client)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 2. Azure OpenAI Chat Client Initialization
|
|
39
|
+
|
|
40
|
+
#### Method A: Managed Identity (Azure-hosted production)
|
|
41
|
+
```python
|
|
42
|
+
from agentbyte.llm.azure_openai import AzureOpenAIChatCompletionClient
|
|
43
|
+
|
|
44
|
+
model_client = AzureOpenAIChatCompletionClient.from_default_credential(
|
|
45
|
+
model="gpt-4o-mini"
|
|
46
|
+
)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
#### Method B: Certificate Auth (Service Principal)
|
|
50
|
+
```python
|
|
51
|
+
import os
|
|
52
|
+
from agentbyte.llm.azure_openai import AzureOpenAIChatCompletionClient
|
|
53
|
+
|
|
54
|
+
model_client = AzureOpenAIChatCompletionClient.from_certificate(
|
|
55
|
+
model="gpt-4o-mini",
|
|
56
|
+
tenant_id=os.environ["AZURE_TENANT_ID"],
|
|
57
|
+
client_id=os.environ["AZURE_CLIENT_ID"],
|
|
58
|
+
certificate_data=os.environ["AZURE_CERT_DATA"],
|
|
59
|
+
)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 3. Embedding Client Initialization (single-provider fallback)
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
import os
|
|
66
|
+
from agentbyte.llm import OpenAIEmbeddingClient, AzureOpenAIEmbeddingClient
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def build_embedding_client():
|
|
70
|
+
if os.getenv("OPENAI_API_KEY"):
|
|
71
|
+
return (
|
|
72
|
+
"openai",
|
|
73
|
+
OpenAIEmbeddingClient.from_api_key(
|
|
74
|
+
model="text-embedding-3-small",
|
|
75
|
+
config={"encoding_format": "float"},
|
|
76
|
+
),
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
model = os.getenv("AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME")
|
|
80
|
+
if not model:
|
|
81
|
+
raise ValueError(
|
|
82
|
+
"Set OPENAI_API_KEY or AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME to build an embedding client."
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
if os.getenv("AZURE_OPENAI_API_KEY"):
|
|
86
|
+
return (
|
|
87
|
+
"azure-openai",
|
|
88
|
+
AzureOpenAIEmbeddingClient.from_api_key(
|
|
89
|
+
model=model,
|
|
90
|
+
api_version=os.getenv("AZURE_OPENAI_API_VERSION", "2024-10-21"),
|
|
91
|
+
),
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
"azure-openai",
|
|
96
|
+
AzureOpenAIEmbeddingClient.from_certificate(
|
|
97
|
+
model=model,
|
|
98
|
+
api_version=os.getenv("AZURE_OPENAI_API_VERSION", "2024-10-21"),
|
|
99
|
+
),
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
provider, embedding_client = build_embedding_client()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 4. Embedding result usage (current API)
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
result = await embedding_client.create_batch(["alpha", "beta"])
|
|
110
|
+
|
|
111
|
+
vectors = result.embeddings
|
|
112
|
+
tokens = result.usage.tokens_input
|
|
113
|
+
cost = result.usage.cost_estimate
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
`create(...)` and `create_batch(...)` return `EmbeddingResult`.
|
|
117
|
+
|
|
118
|
+
## Guardrails
|
|
119
|
+
|
|
120
|
+
- **Environment Loading:** Always use `load_dotenv(find_dotenv(), override=True)` before initializing clients in scripts or notebooks.
|
|
121
|
+
- **Client Reuse:** Prefer creating one client instance and reusing it instead of re-initializing for each call.
|
|
122
|
+
- **Factory vs. Constructor:** Use factory methods (`from_api_key`, `from_certificate`) for standard auth. Use constructor injection only for custom-configured SDK instances.
|
|
123
|
+
- **Single-provider init for embeddings:** In notebooks/demos, initialize OpenAI **or** Azure (not both) to avoid missing-env failures.
|
|
124
|
+
- **Embedding API shape:** Do not expect raw `list[float]` from `create(...)`; read vectors from `EmbeddingResult.embeddings`.
|
|
125
|
+
- **Cost precision:** `usage.cost_estimate` is rounded to 15 decimals; tiny single-call embedding costs can still be very small.
|
|
126
|
+
|
|
127
|
+
````
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
````skill
|
|
2
|
+
---
|
|
3
|
+
name: agentbyte-middleware
|
|
4
|
+
description: Guide for adding middleware chains in Agentbyte for agent and embedding operations. Use this for logging, guardrails, PII redaction, usage tracking, and tracing.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Use this skill when you need to intercept operations via `MiddlewareChain` and `BaseMiddleware`.
|
|
8
|
+
|
|
9
|
+
## Pattern: Custom Middleware (current interface)
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
from typing import Any, Optional
|
|
13
|
+
|
|
14
|
+
from agentbyte.middleware import BaseMiddleware, MiddlewareContext
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class MyLogger(BaseMiddleware):
|
|
18
|
+
async def process_request(self, context: MiddlewareContext) -> MiddlewareContext:
|
|
19
|
+
print(f"request: {context.operation} ({context.agent_name})")
|
|
20
|
+
return context
|
|
21
|
+
|
|
22
|
+
async def process_response(self, context: MiddlewareContext, result: Any) -> Any:
|
|
23
|
+
print(f"response: {context.operation} ({context.agent_name})")
|
|
24
|
+
return result
|
|
25
|
+
|
|
26
|
+
async def process_error(
|
|
27
|
+
self,
|
|
28
|
+
context: MiddlewareContext,
|
|
29
|
+
error: Exception,
|
|
30
|
+
) -> Optional[Any]:
|
|
31
|
+
print(f"error: {context.operation} ({context.agent_name}): {error}")
|
|
32
|
+
return None
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Where middleware is applied
|
|
36
|
+
|
|
37
|
+
- **Agent-level:** chat model calls, tool calls, memory access.
|
|
38
|
+
- **Embedding client-level:** embedding requests (`operation="embedding_call"`) in `BaseEmbeddingClient`.
|
|
39
|
+
|
|
40
|
+
For embeddings, register middleware directly on the client:
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from agentbyte.llm import OpenAIEmbeddingClient
|
|
44
|
+
from agentbyte.middleware import LoggingMiddleware, PIIRedactionMiddleware
|
|
45
|
+
|
|
46
|
+
client = OpenAIEmbeddingClient.from_api_key(model="text-embedding-3-small")
|
|
47
|
+
client.add_middleware(LoggingMiddleware())
|
|
48
|
+
client.add_middleware(PIIRedactionMiddleware())
|
|
49
|
+
|
|
50
|
+
result = await client.create("Contact me at demo@example.com")
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Built-in Middlewares
|
|
54
|
+
|
|
55
|
+
- `LoggingMiddleware`: Emits operation request/response/error logs.
|
|
56
|
+
- `GuardrailMiddleware`: Blocks configured tools and forbidden patterns.
|
|
57
|
+
- `PIIRedactionMiddleware`: Masks common PII patterns in supported payloads.
|
|
58
|
+
- `RateLimitMiddleware`: Applies in-memory throttling.
|
|
59
|
+
- `MetricsMiddleware`: Tracks operation counts, durations, and errors.
|
|
60
|
+
- `OTelMiddleware`: Emits OpenTelemetry traces/metrics when enabled.
|
|
61
|
+
|
|
62
|
+
## Embedding-specific notes
|
|
63
|
+
|
|
64
|
+
- `PIIRedactionMiddleware` supports `embedding_call` payload shape: `{"input": [...], "kwargs": {...}}`.
|
|
65
|
+
- Logging output appears at INFO level under logger `agentbyte.middleware`.
|
|
66
|
+
- In notebooks, configure logging first if middleware logs should appear.
|
|
67
|
+
|
|
68
|
+
## Guardrails
|
|
69
|
+
|
|
70
|
+
- **Execution order:** `process_request` runs in list order; `process_response` runs in reverse order.
|
|
71
|
+
- **Error handling:** Use `process_error(...)` to recover or propagate failures.
|
|
72
|
+
- **Context contract:** Use `MiddlewareContext` (`operation`, `agent_name`, `agent_context`, `data`, `metadata`) to pass state.
|
|
73
|
+
- **No duplicate registration:** In notebooks, prefer idempotent middleware registration to avoid stacking duplicate handlers across repeated runs.
|
|
74
|
+
|
|
75
|
+
````
|
|
@@ -4,6 +4,50 @@ All notable changes to Agentbyte are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format follows Keep a Changelog principles and semantic versioning.
|
|
6
6
|
|
|
7
|
+
## [0.3.6] - 2026-03-23
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- New notebook-focused logging utility: `configure_notebook_logging()` in `agentbyte.notebook`
|
|
11
|
+
- Simplifies logging setup in Jupyter notebooks
|
|
12
|
+
- Always shows middleware logs at INFO level for demo visibility
|
|
13
|
+
- Suppresses noisy HTTP/Azure/OpenAI logs in quiet mode by default
|
|
14
|
+
- Exported from package root for easy notebook imports
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- Azure embedding client authentication simplified in notebook 02c:
|
|
18
|
+
- Removed API-key auth path (certificate-only for Azure in notebooks)
|
|
19
|
+
- Kept API-key auth for OpenAI embeddings
|
|
20
|
+
- Notebook now supports on-the-fly model/API-version overrides
|
|
21
|
+
|
|
22
|
+
## [0.3.5] - 2026-03-18
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- New async embeddings client foundation in `agentbyte.llm`:
|
|
26
|
+
- `BaseEmbeddingClient`, `BaseEmbeddingClientConfig`
|
|
27
|
+
- `OpenAIEmbeddingClient`, `OpenAIEmbeddingClientConfig`
|
|
28
|
+
- `AzureOpenAIEmbeddingClient`, `AzureOpenAIEmbeddingClientConfig`
|
|
29
|
+
- `EmbeddingResult` type export in `agentbyte.llm`.
|
|
30
|
+
- Separate embedding APIs for single and batch generation:
|
|
31
|
+
- `create(input_text: str) -> list[float]`
|
|
32
|
+
- `create_batch(input_texts: list[str]) -> list[list[float]]`
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
- `AzureOpenAISettings` now supports `embedding_deployment_name` from
|
|
36
|
+
`AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME` for embedding client factory resolution.
|
|
37
|
+
|
|
38
|
+
### Testing
|
|
39
|
+
- Added focused unit tests for OpenAI and Azure embedding clients covering
|
|
40
|
+
single input, batch ordering, empty input validation, and env-based factory loading.
|
|
41
|
+
|
|
42
|
+
## [0.3.4] - 2026-03-18
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
- `AzureServicePrincipalSettings`: replaced `model_post_init` with a `@model_validator(mode="after")` to normalize `cognitive_scope`. All three input forms are handled: bare URL → `/.default` appended; URL ending with `/` → `.default` appended; URL already ending with `/.default` → unchanged.
|
|
46
|
+
|
|
47
|
+
## [0.3.3] - 2026-03-18
|
|
48
|
+
### Changed
|
|
49
|
+
- `AzureServicePrincipalSettings.model_post_init` now automatically appends `/.default` to `cognitive_scope` if it is not already present (e.g. `https://cognitiveservices.azure.com` → `https://cognitiveservices.azure.com/.default`).
|
|
50
|
+
|
|
7
51
|
## [0.3.2] - 2026-03-18
|
|
8
52
|
|
|
9
53
|
### Changed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentbyte
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.6
|
|
4
4
|
Summary: A toolkit for designing multiagent systems
|
|
5
5
|
Project-URL: Homepage, https://gitlab.com/pyninja/aiengineering/agentbyte
|
|
6
6
|
Project-URL: Repository, https://gitlab.com/pyninja/aiengineering/agentbyte
|
|
@@ -38,10 +38,19 @@ Description-Content-Type: text/markdown
|
|
|
38
38
|
|
|
39
39
|
Agentbyte is an observability-first agentic AI framework for building and studying multiagent systems with a learning-first, implementation-oriented workflow.
|
|
40
40
|
|
|
41
|
-
Current release: **0.3.
|
|
41
|
+
Current release: **0.3.5**
|
|
42
42
|
|
|
43
43
|
Repository: [gitlab.com/pyninja/aiengineering/agentbyte](https://gitlab.com/pyninja/aiengineering/agentbyte)
|
|
44
44
|
|
|
45
|
+
## What's New in 0.3.5
|
|
46
|
+
|
|
47
|
+
- Added first-class async embeddings clients in `agentbyte.llm` for OpenAI and Azure OpenAI.
|
|
48
|
+
- Added separate single/batch embedding methods:
|
|
49
|
+
- `create(input_text: str) -> list[float]`
|
|
50
|
+
- `create_batch(input_texts: list[str]) -> list[list[float]]`
|
|
51
|
+
- Added Azure embedding deployment setting support:
|
|
52
|
+
`AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME`.
|
|
53
|
+
|
|
45
54
|
## What's New in 0.3.2
|
|
46
55
|
|
|
47
56
|
- **Python baseline lowered:** package runtime requirement is now **Python 3.11+**.
|
|
@@ -6,10 +6,19 @@
|
|
|
6
6
|
|
|
7
7
|
Agentbyte is an observability-first agentic AI framework for building and studying multiagent systems with a learning-first, implementation-oriented workflow.
|
|
8
8
|
|
|
9
|
-
Current release: **0.3.
|
|
9
|
+
Current release: **0.3.5**
|
|
10
10
|
|
|
11
11
|
Repository: [gitlab.com/pyninja/aiengineering/agentbyte](https://gitlab.com/pyninja/aiengineering/agentbyte)
|
|
12
12
|
|
|
13
|
+
## What's New in 0.3.5
|
|
14
|
+
|
|
15
|
+
- Added first-class async embeddings clients in `agentbyte.llm` for OpenAI and Azure OpenAI.
|
|
16
|
+
- Added separate single/batch embedding methods:
|
|
17
|
+
- `create(input_text: str) -> list[float]`
|
|
18
|
+
- `create_batch(input_texts: list[str]) -> list[list[float]]`
|
|
19
|
+
- Added Azure embedding deployment setting support:
|
|
20
|
+
`AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME`.
|
|
21
|
+
|
|
13
22
|
## What's New in 0.3.2
|
|
14
23
|
|
|
15
24
|
- **Python baseline lowered:** package runtime requirement is now **Python 3.11+**.
|
|
@@ -16,6 +16,7 @@ from agentbyte.__about__ import VERSION
|
|
|
16
16
|
from agentbyte.agents import Agent
|
|
17
17
|
from agentbyte.entity import Entity
|
|
18
18
|
from agentbyte.middleware import init_auto_instrumentation_from_env
|
|
19
|
+
from agentbyte.notebook import configure_notebook_logging
|
|
19
20
|
from agentbyte.session import BaseSession, InMemorySession, Session
|
|
20
21
|
|
|
21
22
|
# Auto-instrument with OpenTelemetry if enabled.
|
|
@@ -34,4 +35,5 @@ __all__ = [
|
|
|
34
35
|
"Session",
|
|
35
36
|
"BaseSession",
|
|
36
37
|
"InMemorySession",
|
|
38
|
+
"configure_notebook_logging",
|
|
37
39
|
]
|
|
@@ -31,11 +31,17 @@ from .base import (
|
|
|
31
31
|
AuthenticationError,
|
|
32
32
|
InvalidRequestError,
|
|
33
33
|
)
|
|
34
|
+
from .embeddings_base import BaseEmbeddingClient, BaseEmbeddingClientConfig
|
|
34
35
|
from .openai import OpenAIChatCompletionClient, OpenAIChatCompletionClientConfig
|
|
36
|
+
from .openai_embedding import OpenAIEmbeddingClient, OpenAIEmbeddingClientConfig
|
|
35
37
|
from .azure_openai import (
|
|
36
38
|
AzureOpenAIChatCompletionClient,
|
|
37
39
|
AzureOpenAIChatCompletionClientConfig,
|
|
38
40
|
)
|
|
41
|
+
from .azure_openai_embedding import (
|
|
42
|
+
AzureOpenAIEmbeddingClient,
|
|
43
|
+
AzureOpenAIEmbeddingClientConfig,
|
|
44
|
+
)
|
|
39
45
|
from .auth import (
|
|
40
46
|
get_default_token_provider,
|
|
41
47
|
get_certificate_token_provider,
|
|
@@ -58,18 +64,26 @@ from agentbyte.messages import (
|
|
|
58
64
|
from .types import (
|
|
59
65
|
ChatCompletionChunk,
|
|
60
66
|
ChatCompletionResult,
|
|
67
|
+
EmbeddingResult,
|
|
61
68
|
ModelClientError,
|
|
69
|
+
ModelPricing,
|
|
62
70
|
)
|
|
63
71
|
|
|
64
72
|
__all__ = [
|
|
65
73
|
# Base classes
|
|
66
74
|
"BaseChatCompletionClient",
|
|
67
75
|
"BaseChatCompletionClientConfig",
|
|
76
|
+
"BaseEmbeddingClient",
|
|
77
|
+
"BaseEmbeddingClientConfig",
|
|
68
78
|
# Provider implementations
|
|
69
79
|
"OpenAIChatCompletionClient",
|
|
70
80
|
"OpenAIChatCompletionClientConfig",
|
|
81
|
+
"OpenAIEmbeddingClient",
|
|
82
|
+
"OpenAIEmbeddingClientConfig",
|
|
71
83
|
"AzureOpenAIChatCompletionClient",
|
|
72
84
|
"AzureOpenAIChatCompletionClientConfig",
|
|
85
|
+
"AzureOpenAIEmbeddingClient",
|
|
86
|
+
"AzureOpenAIEmbeddingClientConfig",
|
|
73
87
|
# Authentication utilities
|
|
74
88
|
"get_default_token_provider",
|
|
75
89
|
"get_certificate_token_provider",
|
|
@@ -96,4 +110,6 @@ __all__ = [
|
|
|
96
110
|
"Usage",
|
|
97
111
|
"ChatCompletionResult",
|
|
98
112
|
"ChatCompletionChunk",
|
|
113
|
+
"EmbeddingResult",
|
|
114
|
+
"ModelPricing",
|
|
99
115
|
]
|
|
@@ -81,9 +81,11 @@ from .base import (
|
|
|
81
81
|
AuthenticationError,
|
|
82
82
|
InvalidRequestError,
|
|
83
83
|
)
|
|
84
|
+
from .pricing import PricingRegistry
|
|
84
85
|
from .types import (
|
|
85
86
|
ChatCompletionChunk,
|
|
86
87
|
ChatCompletionResult,
|
|
88
|
+
ModelPricing,
|
|
87
89
|
ModelClientError,
|
|
88
90
|
Usage,
|
|
89
91
|
)
|
|
@@ -168,6 +170,7 @@ class AzureOpenAIChatCompletionClient(
|
|
|
168
170
|
model: str,
|
|
169
171
|
client: AsyncAzureOpenAI,
|
|
170
172
|
config: Optional[Dict[str, Any]] = None,
|
|
173
|
+
model_pricing: Optional[ModelPricing] = None,
|
|
171
174
|
max_retries: int = 3,
|
|
172
175
|
initial_retry_delay: float = 1.0,
|
|
173
176
|
max_retry_delay: float = 60.0,
|
|
@@ -240,7 +243,7 @@ class AzureOpenAIChatCompletionClient(
|
|
|
240
243
|
... )
|
|
241
244
|
"""
|
|
242
245
|
super().__init__(model, client, config)
|
|
243
|
-
|
|
246
|
+
self.model_pricing = model_pricing
|
|
244
247
|
self.max_retries = max_retries
|
|
245
248
|
self.initial_retry_delay = initial_retry_delay
|
|
246
249
|
self.max_retry_delay = max_retry_delay
|
|
@@ -255,6 +258,7 @@ class AzureOpenAIChatCompletionClient(
|
|
|
255
258
|
api_key: Optional[str] = None,
|
|
256
259
|
service_settings: Optional[Any] = None,
|
|
257
260
|
config: Optional[Dict[str, Any]] = None,
|
|
261
|
+
model_pricing: Optional[ModelPricing] = None,
|
|
258
262
|
max_retries: int = 3,
|
|
259
263
|
initial_retry_delay: float = 1.0,
|
|
260
264
|
max_retry_delay: float = 60.0,
|
|
@@ -334,6 +338,7 @@ class AzureOpenAIChatCompletionClient(
|
|
|
334
338
|
model=resolved_model,
|
|
335
339
|
client=azure_client,
|
|
336
340
|
config=config,
|
|
341
|
+
model_pricing=model_pricing,
|
|
337
342
|
max_retries=max_retries,
|
|
338
343
|
initial_retry_delay=initial_retry_delay,
|
|
339
344
|
max_retry_delay=max_retry_delay,
|
|
@@ -347,6 +352,7 @@ class AzureOpenAIChatCompletionClient(
|
|
|
347
352
|
service_settings: Optional[Any] = None,
|
|
348
353
|
scope: str = "https://cognitiveservices.azure.com/.default",
|
|
349
354
|
config: Optional[Dict[str, Any]] = None,
|
|
355
|
+
model_pricing: Optional[ModelPricing] = None,
|
|
350
356
|
max_retries: int = 3,
|
|
351
357
|
initial_retry_delay: float = 1.0,
|
|
352
358
|
max_retry_delay: float = 60.0,
|
|
@@ -431,6 +437,7 @@ class AzureOpenAIChatCompletionClient(
|
|
|
431
437
|
model=resolved_model,
|
|
432
438
|
client=azure_client,
|
|
433
439
|
config=config,
|
|
440
|
+
model_pricing=model_pricing,
|
|
434
441
|
max_retries=max_retries,
|
|
435
442
|
initial_retry_delay=initial_retry_delay,
|
|
436
443
|
max_retry_delay=max_retry_delay,
|
|
@@ -445,6 +452,7 @@ class AzureOpenAIChatCompletionClient(
|
|
|
445
452
|
principal_settings: Optional[Any] = None,
|
|
446
453
|
scope: Optional[str] = None,
|
|
447
454
|
config: Optional[Dict[str, Any]] = None,
|
|
455
|
+
model_pricing: Optional[ModelPricing] = None,
|
|
448
456
|
max_retries: int = 3,
|
|
449
457
|
initial_retry_delay: float = 1.0,
|
|
450
458
|
max_retry_delay: float = 60.0,
|
|
@@ -535,6 +543,7 @@ class AzureOpenAIChatCompletionClient(
|
|
|
535
543
|
model=resolved_model,
|
|
536
544
|
client=azure_client,
|
|
537
545
|
config=config,
|
|
546
|
+
model_pricing=model_pricing,
|
|
538
547
|
max_retries=max_retries,
|
|
539
548
|
initial_retry_delay=initial_retry_delay,
|
|
540
549
|
max_retry_delay=max_retry_delay,
|
|
@@ -548,6 +557,7 @@ class AzureOpenAIChatCompletionClient(
|
|
|
548
557
|
api_version: Optional[str] = None,
|
|
549
558
|
service_settings: Optional[Any] = None,
|
|
550
559
|
config: Optional[Dict[str, Any]] = None,
|
|
560
|
+
model_pricing: Optional[ModelPricing] = None,
|
|
551
561
|
max_retries: int = 3,
|
|
552
562
|
initial_retry_delay: float = 1.0,
|
|
553
563
|
max_retry_delay: float = 60.0,
|
|
@@ -623,6 +633,7 @@ class AzureOpenAIChatCompletionClient(
|
|
|
623
633
|
model=resolved_model,
|
|
624
634
|
client=azure_client,
|
|
625
635
|
config=config,
|
|
636
|
+
model_pricing=model_pricing,
|
|
626
637
|
max_retries=max_retries,
|
|
627
638
|
initial_retry_delay=initial_retry_delay,
|
|
628
639
|
max_retry_delay=max_retry_delay,
|
|
@@ -1140,46 +1151,21 @@ class AzureOpenAIChatCompletionClient(
|
|
|
1140
1151
|
Returns:
|
|
1141
1152
|
Estimated cost in USD
|
|
1142
1153
|
|
|
1143
|
-
Azure
|
|
1144
|
-
|
|
1145
|
-
- GPT-4 Turbo: $0.01 per 1K input tokens, $0.03 per 1K output tokens
|
|
1146
|
-
- GPT-4: $0.03 per 1K input tokens, $0.06 per 1K output tokens
|
|
1147
|
-
- GPT-3.5 Turbo: $0.0005 per 1K input tokens, $0.0015 per 1K output tokens
|
|
1148
|
-
- Falls back to GPT-4 pricing for unknown models
|
|
1154
|
+
Pricing is resolved from PricingRegistry for Azure OpenAI; user-provided pricing always takes precedence.
|
|
1155
|
+
Unknown models trigger a warning and fall back to GPT-4 pricing.
|
|
1149
1156
|
|
|
1150
1157
|
Note:
|
|
1151
1158
|
Azure pricing is typically lower than standard OpenAI pricing.
|
|
1152
1159
|
For production, validate pricing against your Azure account.
|
|
1153
1160
|
"""
|
|
1154
|
-
#
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
"gpt-3.5-turbo": {"input_per_1m": 0.50, "output_per_1m": 1.50},
|
|
1161
|
-
"gpt-4.1": {"input_per_1m": 2.0, "output_per_1m": 8.0},
|
|
1162
|
-
"gpt-4.1-nano": {"input_per_1m": 0.10, "output_per_1m": 0.40},
|
|
1163
|
-
"gpt-5-mini": {"input_per_1m": 0.25, "output_per_1m": 2.0},
|
|
1164
|
-
"gpt-5.1-chat": {"input_per_1m": 1.25, "output_per_1m": 10.0}
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
# Find matching pricing; try to match model name prefix
|
|
1168
|
-
model_pricing = None
|
|
1169
|
-
for model_key, pricing_data in pricing.items():
|
|
1170
|
-
if model_key in self.model.lower():
|
|
1171
|
-
model_pricing = pricing_data
|
|
1172
|
-
break
|
|
1173
|
-
|
|
1174
|
-
# Default to GPT-4 pricing if no match found
|
|
1175
|
-
if not model_pricing:
|
|
1176
|
-
model_pricing = pricing["gpt-4"]
|
|
1177
|
-
|
|
1178
|
-
# Calculate cost in USD
|
|
1179
|
-
input_cost = (prompt_tokens / 1_000_000) * model_pricing["input_per_1m"]
|
|
1180
|
-
output_cost = (completion_tokens / 1_000_000) * model_pricing["output_per_1m"]
|
|
1161
|
+
# User-provided pricing always takes precedence
|
|
1162
|
+
if self.model_pricing is not None:
|
|
1163
|
+
pricing = self.model_pricing
|
|
1164
|
+
else:
|
|
1165
|
+
# Resolve from registry (warns if not found, uses default GPT-4 pricing)
|
|
1166
|
+
pricing = PricingRegistry.resolve_azure_chat_pricing(self.model)
|
|
1181
1167
|
|
|
1182
|
-
return
|
|
1168
|
+
return pricing.calculate_cost(prompt_tokens, completion_tokens)
|
|
1183
1169
|
|
|
1184
1170
|
def _to_config(self) -> AzureOpenAIChatCompletionClientConfig:
|
|
1185
1171
|
"""Serialize to config. Env-var names are stored; secrets are never written."""
|