agentex-sdk 0.1.0a6__py3-none-any.whl
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.
- agentex/__init__.py +103 -0
- agentex/_base_client.py +1992 -0
- agentex/_client.py +506 -0
- agentex/_compat.py +219 -0
- agentex/_constants.py +14 -0
- agentex/_exceptions.py +108 -0
- agentex/_files.py +123 -0
- agentex/_models.py +829 -0
- agentex/_qs.py +150 -0
- agentex/_resource.py +43 -0
- agentex/_response.py +830 -0
- agentex/_streaming.py +333 -0
- agentex/_types.py +219 -0
- agentex/_utils/__init__.py +57 -0
- agentex/_utils/_logs.py +25 -0
- agentex/_utils/_proxy.py +65 -0
- agentex/_utils/_reflection.py +42 -0
- agentex/_utils/_resources_proxy.py +24 -0
- agentex/_utils/_streams.py +12 -0
- agentex/_utils/_sync.py +86 -0
- agentex/_utils/_transform.py +447 -0
- agentex/_utils/_typing.py +151 -0
- agentex/_utils/_utils.py +422 -0
- agentex/_version.py +4 -0
- agentex/lib/.keep +4 -0
- agentex/lib/__init__.py +0 -0
- agentex/lib/adk/__init__.py +41 -0
- agentex/lib/adk/_modules/__init__.py +0 -0
- agentex/lib/adk/_modules/acp.py +247 -0
- agentex/lib/adk/_modules/agent_task_tracker.py +176 -0
- agentex/lib/adk/_modules/agents.py +77 -0
- agentex/lib/adk/_modules/events.py +141 -0
- agentex/lib/adk/_modules/messages.py +285 -0
- agentex/lib/adk/_modules/state.py +291 -0
- agentex/lib/adk/_modules/streaming.py +75 -0
- agentex/lib/adk/_modules/tasks.py +124 -0
- agentex/lib/adk/_modules/tracing.py +194 -0
- agentex/lib/adk/providers/__init__.py +9 -0
- agentex/lib/adk/providers/_modules/__init__.py +0 -0
- agentex/lib/adk/providers/_modules/litellm.py +232 -0
- agentex/lib/adk/providers/_modules/openai.py +416 -0
- agentex/lib/adk/providers/_modules/sgp.py +85 -0
- agentex/lib/adk/utils/__init__.py +5 -0
- agentex/lib/adk/utils/_modules/__init__.py +0 -0
- agentex/lib/adk/utils/_modules/templating.py +94 -0
- agentex/lib/cli/__init__.py +0 -0
- agentex/lib/cli/commands/__init__.py +0 -0
- agentex/lib/cli/commands/agents.py +328 -0
- agentex/lib/cli/commands/init.py +227 -0
- agentex/lib/cli/commands/main.py +33 -0
- agentex/lib/cli/commands/secrets.py +169 -0
- agentex/lib/cli/commands/tasks.py +118 -0
- agentex/lib/cli/commands/uv.py +133 -0
- agentex/lib/cli/handlers/__init__.py +0 -0
- agentex/lib/cli/handlers/agent_handlers.py +160 -0
- agentex/lib/cli/handlers/cleanup_handlers.py +186 -0
- agentex/lib/cli/handlers/deploy_handlers.py +351 -0
- agentex/lib/cli/handlers/run_handlers.py +452 -0
- agentex/lib/cli/handlers/secret_handlers.py +670 -0
- agentex/lib/cli/templates/default/.dockerignore.j2 +43 -0
- agentex/lib/cli/templates/default/Dockerfile-uv.j2 +42 -0
- agentex/lib/cli/templates/default/Dockerfile.j2 +42 -0
- agentex/lib/cli/templates/default/README.md.j2 +193 -0
- agentex/lib/cli/templates/default/deploy/example.yaml.j2 +55 -0
- agentex/lib/cli/templates/default/manifest.yaml.j2 +116 -0
- agentex/lib/cli/templates/default/project/acp.py.j2 +29 -0
- agentex/lib/cli/templates/default/pyproject.toml.j2 +33 -0
- agentex/lib/cli/templates/default/requirements.txt.j2 +5 -0
- agentex/lib/cli/templates/deploy/Screenshot 2025-03-19 at 10.36.57/342/200/257AM.png +0 -0
- agentex/lib/cli/templates/deploy/example.yaml.j2 +55 -0
- agentex/lib/cli/templates/sync/.dockerignore.j2 +43 -0
- agentex/lib/cli/templates/sync/Dockerfile-uv.j2 +42 -0
- agentex/lib/cli/templates/sync/Dockerfile.j2 +42 -0
- agentex/lib/cli/templates/sync/README.md.j2 +293 -0
- agentex/lib/cli/templates/sync/deploy/example.yaml.j2 +55 -0
- agentex/lib/cli/templates/sync/manifest.yaml.j2 +116 -0
- agentex/lib/cli/templates/sync/project/acp.py.j2 +26 -0
- agentex/lib/cli/templates/sync/pyproject.toml.j2 +33 -0
- agentex/lib/cli/templates/sync/requirements.txt.j2 +5 -0
- agentex/lib/cli/templates/temporal/.dockerignore.j2 +43 -0
- agentex/lib/cli/templates/temporal/Dockerfile-uv.j2 +48 -0
- agentex/lib/cli/templates/temporal/Dockerfile.j2 +48 -0
- agentex/lib/cli/templates/temporal/README.md.j2 +316 -0
- agentex/lib/cli/templates/temporal/deploy/example.yaml.j2 +55 -0
- agentex/lib/cli/templates/temporal/manifest.yaml.j2 +137 -0
- agentex/lib/cli/templates/temporal/project/acp.py.j2 +30 -0
- agentex/lib/cli/templates/temporal/project/run_worker.py.j2 +33 -0
- agentex/lib/cli/templates/temporal/project/workflow.py.j2 +66 -0
- agentex/lib/cli/templates/temporal/pyproject.toml.j2 +34 -0
- agentex/lib/cli/templates/temporal/requirements.txt.j2 +5 -0
- agentex/lib/cli/utils/cli_utils.py +14 -0
- agentex/lib/cli/utils/credential_utils.py +103 -0
- agentex/lib/cli/utils/exceptions.py +6 -0
- agentex/lib/cli/utils/kubectl_utils.py +135 -0
- agentex/lib/cli/utils/kubernetes_secrets_utils.py +185 -0
- agentex/lib/core/__init__.py +0 -0
- agentex/lib/core/adapters/__init__.py +0 -0
- agentex/lib/core/adapters/llm/__init__.py +1 -0
- agentex/lib/core/adapters/llm/adapter_litellm.py +46 -0
- agentex/lib/core/adapters/llm/adapter_sgp.py +55 -0
- agentex/lib/core/adapters/llm/port.py +24 -0
- agentex/lib/core/adapters/streams/adapter_redis.py +128 -0
- agentex/lib/core/adapters/streams/port.py +50 -0
- agentex/lib/core/clients/__init__.py +1 -0
- agentex/lib/core/clients/temporal/__init__.py +0 -0
- agentex/lib/core/clients/temporal/temporal_client.py +181 -0
- agentex/lib/core/clients/temporal/types.py +47 -0
- agentex/lib/core/clients/temporal/utils.py +56 -0
- agentex/lib/core/services/__init__.py +0 -0
- agentex/lib/core/services/adk/__init__.py +0 -0
- agentex/lib/core/services/adk/acp/__init__.py +0 -0
- agentex/lib/core/services/adk/acp/acp.py +210 -0
- agentex/lib/core/services/adk/agent_task_tracker.py +85 -0
- agentex/lib/core/services/adk/agents.py +43 -0
- agentex/lib/core/services/adk/events.py +61 -0
- agentex/lib/core/services/adk/messages.py +164 -0
- agentex/lib/core/services/adk/providers/__init__.py +0 -0
- agentex/lib/core/services/adk/providers/litellm.py +256 -0
- agentex/lib/core/services/adk/providers/openai.py +723 -0
- agentex/lib/core/services/adk/providers/sgp.py +99 -0
- agentex/lib/core/services/adk/state.py +120 -0
- agentex/lib/core/services/adk/streaming.py +262 -0
- agentex/lib/core/services/adk/tasks.py +69 -0
- agentex/lib/core/services/adk/tracing.py +36 -0
- agentex/lib/core/services/adk/utils/__init__.py +0 -0
- agentex/lib/core/services/adk/utils/templating.py +58 -0
- agentex/lib/core/temporal/__init__.py +0 -0
- agentex/lib/core/temporal/activities/__init__.py +207 -0
- agentex/lib/core/temporal/activities/activity_helpers.py +37 -0
- agentex/lib/core/temporal/activities/adk/__init__.py +0 -0
- agentex/lib/core/temporal/activities/adk/acp/__init__.py +0 -0
- agentex/lib/core/temporal/activities/adk/acp/acp_activities.py +86 -0
- agentex/lib/core/temporal/activities/adk/agent_task_tracker_activities.py +76 -0
- agentex/lib/core/temporal/activities/adk/agents_activities.py +35 -0
- agentex/lib/core/temporal/activities/adk/events_activities.py +50 -0
- agentex/lib/core/temporal/activities/adk/messages_activities.py +94 -0
- agentex/lib/core/temporal/activities/adk/providers/__init__.py +0 -0
- agentex/lib/core/temporal/activities/adk/providers/litellm_activities.py +71 -0
- agentex/lib/core/temporal/activities/adk/providers/openai_activities.py +210 -0
- agentex/lib/core/temporal/activities/adk/providers/sgp_activities.py +42 -0
- agentex/lib/core/temporal/activities/adk/state_activities.py +85 -0
- agentex/lib/core/temporal/activities/adk/streaming_activities.py +33 -0
- agentex/lib/core/temporal/activities/adk/tasks_activities.py +48 -0
- agentex/lib/core/temporal/activities/adk/tracing_activities.py +55 -0
- agentex/lib/core/temporal/activities/adk/utils/__init__.py +0 -0
- agentex/lib/core/temporal/activities/adk/utils/templating_activities.py +41 -0
- agentex/lib/core/temporal/services/__init__.py +0 -0
- agentex/lib/core/temporal/services/temporal_task_service.py +69 -0
- agentex/lib/core/temporal/types/__init__.py +0 -0
- agentex/lib/core/temporal/types/workflow.py +5 -0
- agentex/lib/core/temporal/workers/__init__.py +0 -0
- agentex/lib/core/temporal/workers/worker.py +162 -0
- agentex/lib/core/temporal/workflows/workflow.py +26 -0
- agentex/lib/core/tracing/__init__.py +5 -0
- agentex/lib/core/tracing/processors/agentex_tracing_processor.py +117 -0
- agentex/lib/core/tracing/processors/sgp_tracing_processor.py +119 -0
- agentex/lib/core/tracing/processors/tracing_processor_interface.py +40 -0
- agentex/lib/core/tracing/trace.py +311 -0
- agentex/lib/core/tracing/tracer.py +70 -0
- agentex/lib/core/tracing/tracing_processor_manager.py +62 -0
- agentex/lib/environment_variables.py +87 -0
- agentex/lib/py.typed +0 -0
- agentex/lib/sdk/__init__.py +0 -0
- agentex/lib/sdk/config/__init__.py +0 -0
- agentex/lib/sdk/config/agent_config.py +61 -0
- agentex/lib/sdk/config/agent_manifest.py +219 -0
- agentex/lib/sdk/config/build_config.py +35 -0
- agentex/lib/sdk/config/deployment_config.py +117 -0
- agentex/lib/sdk/config/local_development_config.py +56 -0
- agentex/lib/sdk/config/project_config.py +103 -0
- agentex/lib/sdk/fastacp/__init__.py +3 -0
- agentex/lib/sdk/fastacp/base/base_acp_server.py +406 -0
- agentex/lib/sdk/fastacp/fastacp.py +74 -0
- agentex/lib/sdk/fastacp/impl/agentic_base_acp.py +72 -0
- agentex/lib/sdk/fastacp/impl/sync_acp.py +109 -0
- agentex/lib/sdk/fastacp/impl/temporal_acp.py +97 -0
- agentex/lib/sdk/fastacp/tests/README.md +297 -0
- agentex/lib/sdk/fastacp/tests/conftest.py +307 -0
- agentex/lib/sdk/fastacp/tests/pytest.ini +10 -0
- agentex/lib/sdk/fastacp/tests/run_tests.py +227 -0
- agentex/lib/sdk/fastacp/tests/test_base_acp_server.py +450 -0
- agentex/lib/sdk/fastacp/tests/test_fastacp_factory.py +344 -0
- agentex/lib/sdk/fastacp/tests/test_integration.py +477 -0
- agentex/lib/sdk/state_machine/__init__.py +6 -0
- agentex/lib/sdk/state_machine/noop_workflow.py +21 -0
- agentex/lib/sdk/state_machine/state.py +10 -0
- agentex/lib/sdk/state_machine/state_machine.py +189 -0
- agentex/lib/sdk/state_machine/state_workflow.py +16 -0
- agentex/lib/sdk/utils/__init__.py +0 -0
- agentex/lib/sdk/utils/messages.py +223 -0
- agentex/lib/types/__init__.py +0 -0
- agentex/lib/types/acp.py +94 -0
- agentex/lib/types/agent_configs.py +79 -0
- agentex/lib/types/agent_results.py +29 -0
- agentex/lib/types/credentials.py +34 -0
- agentex/lib/types/fastacp.py +61 -0
- agentex/lib/types/files.py +13 -0
- agentex/lib/types/json_rpc.py +49 -0
- agentex/lib/types/llm_messages.py +354 -0
- agentex/lib/types/task_message_updates.py +171 -0
- agentex/lib/types/tracing.py +34 -0
- agentex/lib/utils/__init__.py +0 -0
- agentex/lib/utils/completions.py +131 -0
- agentex/lib/utils/console.py +14 -0
- agentex/lib/utils/io.py +29 -0
- agentex/lib/utils/iterables.py +14 -0
- agentex/lib/utils/json_schema.py +23 -0
- agentex/lib/utils/logging.py +31 -0
- agentex/lib/utils/mcp.py +17 -0
- agentex/lib/utils/model_utils.py +46 -0
- agentex/lib/utils/parsing.py +15 -0
- agentex/lib/utils/regex.py +6 -0
- agentex/lib/utils/temporal.py +13 -0
- agentex/py.typed +0 -0
- agentex/resources/__init__.py +103 -0
- agentex/resources/agents.py +707 -0
- agentex/resources/events.py +294 -0
- agentex/resources/messages/__init__.py +33 -0
- agentex/resources/messages/batch.py +271 -0
- agentex/resources/messages/messages.py +492 -0
- agentex/resources/spans.py +557 -0
- agentex/resources/states.py +544 -0
- agentex/resources/tasks.py +615 -0
- agentex/resources/tracker.py +384 -0
- agentex/types/__init__.py +56 -0
- agentex/types/acp_type.py +7 -0
- agentex/types/agent.py +29 -0
- agentex/types/agent_list_params.py +13 -0
- agentex/types/agent_list_response.py +10 -0
- agentex/types/agent_rpc_by_name_params.py +21 -0
- agentex/types/agent_rpc_params.py +51 -0
- agentex/types/agent_rpc_params1.py +21 -0
- agentex/types/agent_rpc_response.py +20 -0
- agentex/types/agent_rpc_result.py +90 -0
- agentex/types/agent_task_tracker.py +34 -0
- agentex/types/data_content.py +30 -0
- agentex/types/data_content_param.py +31 -0
- agentex/types/data_delta.py +14 -0
- agentex/types/event.py +29 -0
- agentex/types/event_list_params.py +22 -0
- agentex/types/event_list_response.py +10 -0
- agentex/types/message_author.py +7 -0
- agentex/types/message_create_params.py +18 -0
- agentex/types/message_list_params.py +14 -0
- agentex/types/message_list_response.py +10 -0
- agentex/types/message_style.py +7 -0
- agentex/types/message_update_params.py +18 -0
- agentex/types/messages/__init__.py +8 -0
- agentex/types/messages/batch_create_params.py +16 -0
- agentex/types/messages/batch_create_response.py +10 -0
- agentex/types/messages/batch_update_params.py +16 -0
- agentex/types/messages/batch_update_response.py +10 -0
- agentex/types/shared/__init__.py +3 -0
- agentex/types/shared/task_message_update.py +83 -0
- agentex/types/span.py +36 -0
- agentex/types/span_create_params.py +40 -0
- agentex/types/span_list_params.py +12 -0
- agentex/types/span_list_response.py +10 -0
- agentex/types/span_update_params.py +37 -0
- agentex/types/state.py +25 -0
- agentex/types/state_create_params.py +16 -0
- agentex/types/state_list_params.py +16 -0
- agentex/types/state_list_response.py +10 -0
- agentex/types/state_update_params.py +16 -0
- agentex/types/task.py +23 -0
- agentex/types/task_delete_by_name_response.py +8 -0
- agentex/types/task_delete_response.py +8 -0
- agentex/types/task_list_response.py +10 -0
- agentex/types/task_message.py +33 -0
- agentex/types/task_message_content.py +16 -0
- agentex/types/task_message_content_param.py +17 -0
- agentex/types/task_message_delta.py +16 -0
- agentex/types/text_content.py +53 -0
- agentex/types/text_content_param.py +54 -0
- agentex/types/text_delta.py +14 -0
- agentex/types/tool_request_content.py +36 -0
- agentex/types/tool_request_content_param.py +37 -0
- agentex/types/tool_request_delta.py +18 -0
- agentex/types/tool_response_content.py +36 -0
- agentex/types/tool_response_content_param.py +36 -0
- agentex/types/tool_response_delta.py +18 -0
- agentex/types/tracker_list_params.py +16 -0
- agentex/types/tracker_list_response.py +10 -0
- agentex/types/tracker_update_params.py +19 -0
- agentex_sdk-0.1.0a6.dist-info/METADATA +426 -0
- agentex_sdk-0.1.0a6.dist-info/RECORD +289 -0
- agentex_sdk-0.1.0a6.dist-info/WHEEL +4 -0
- agentex_sdk-0.1.0a6.dist-info/entry_points.txt +2 -0
- agentex_sdk-0.1.0a6.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,61 @@
|
|
1
|
+
from typing import Literal
|
2
|
+
|
3
|
+
from pydantic import BaseModel, Field
|
4
|
+
|
5
|
+
|
6
|
+
class BaseACPConfig(BaseModel):
|
7
|
+
"""
|
8
|
+
Base configuration for all ACP implementations
|
9
|
+
|
10
|
+
Attributes:
|
11
|
+
type: The type of ACP implementation
|
12
|
+
"""
|
13
|
+
|
14
|
+
pass
|
15
|
+
|
16
|
+
|
17
|
+
class SyncACPConfig(BaseACPConfig):
|
18
|
+
"""
|
19
|
+
Configuration for SyncACP implementation
|
20
|
+
|
21
|
+
Attributes:
|
22
|
+
type: The type of ACP implementation
|
23
|
+
"""
|
24
|
+
|
25
|
+
pass
|
26
|
+
|
27
|
+
|
28
|
+
class AgenticACPConfig(BaseACPConfig):
|
29
|
+
"""
|
30
|
+
Base class for agentic ACP configurations
|
31
|
+
|
32
|
+
Attributes:
|
33
|
+
type: The type of ACP implementation
|
34
|
+
"""
|
35
|
+
|
36
|
+
type: Literal["temporal", "base"] = Field(..., frozen=True)
|
37
|
+
|
38
|
+
|
39
|
+
class TemporalACPConfig(AgenticACPConfig):
|
40
|
+
"""
|
41
|
+
Configuration for TemporalACP implementation
|
42
|
+
|
43
|
+
Attributes:
|
44
|
+
type: The type of ACP implementation
|
45
|
+
temporal_address: The address of the temporal server
|
46
|
+
"""
|
47
|
+
|
48
|
+
type: Literal["temporal"] = Field(default="temporal", frozen=True)
|
49
|
+
temporal_address: str = Field(
|
50
|
+
default="temporal-frontend.temporal.svc.cluster.local:7233", frozen=True
|
51
|
+
)
|
52
|
+
|
53
|
+
|
54
|
+
class AgenticBaseACPConfig(AgenticACPConfig):
|
55
|
+
"""Configuration for AgenticBaseACP implementation
|
56
|
+
|
57
|
+
Attributes:
|
58
|
+
type: The type of ACP implementation
|
59
|
+
"""
|
60
|
+
|
61
|
+
type: Literal["base"] = Field(default="base", frozen=True)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
from agentex.lib.utils.model_utils import BaseModel
|
2
|
+
|
3
|
+
|
4
|
+
class FileContentResponse(BaseModel):
|
5
|
+
"""Response model for downloaded file content.
|
6
|
+
|
7
|
+
Attributes:
|
8
|
+
mime_type: The MIME type of the file
|
9
|
+
base64_content: The base64 encoded content of the file
|
10
|
+
"""
|
11
|
+
|
12
|
+
mime_type: str
|
13
|
+
base64_content: str
|
@@ -0,0 +1,49 @@
|
|
1
|
+
from typing import Any, Literal
|
2
|
+
|
3
|
+
from agentex.lib.utils.model_utils import BaseModel
|
4
|
+
|
5
|
+
|
6
|
+
class JSONRPCError(BaseModel):
|
7
|
+
"""JSON-RPC 2.0 Error
|
8
|
+
|
9
|
+
Attributes:
|
10
|
+
code: The error code
|
11
|
+
message: The error message
|
12
|
+
data: The error data
|
13
|
+
"""
|
14
|
+
|
15
|
+
code: int
|
16
|
+
message: str
|
17
|
+
data: Any | None = None
|
18
|
+
|
19
|
+
|
20
|
+
class JSONRPCRequest(BaseModel):
|
21
|
+
"""JSON-RPC 2.0 Request
|
22
|
+
|
23
|
+
Attributes:
|
24
|
+
jsonrpc: The JSON-RPC version
|
25
|
+
method: The method to call
|
26
|
+
params: The parameters for the request
|
27
|
+
id: The ID of the request
|
28
|
+
"""
|
29
|
+
|
30
|
+
jsonrpc: Literal["2.0"] = "2.0"
|
31
|
+
method: str
|
32
|
+
params: dict[str, Any]
|
33
|
+
id: int | str | None = None
|
34
|
+
|
35
|
+
|
36
|
+
class JSONRPCResponse(BaseModel):
|
37
|
+
"""JSON-RPC 2.0 Response
|
38
|
+
|
39
|
+
Attributes:
|
40
|
+
jsonrpc: The JSON-RPC version
|
41
|
+
result: The result of the request
|
42
|
+
error: The error of the request
|
43
|
+
id: The ID of the request
|
44
|
+
"""
|
45
|
+
|
46
|
+
jsonrpc: Literal["2.0"] = "2.0"
|
47
|
+
result: dict[str, Any] | None = None
|
48
|
+
error: JSONRPCError | None = None
|
49
|
+
id: int | str | None = None
|
@@ -0,0 +1,354 @@
|
|
1
|
+
from typing import Any, Literal
|
2
|
+
|
3
|
+
try:
|
4
|
+
from typing import Annotated
|
5
|
+
except ImportError:
|
6
|
+
from typing import Annotated
|
7
|
+
from pydantic import Field
|
8
|
+
|
9
|
+
from agentex.lib.utils.model_utils import BaseModel
|
10
|
+
|
11
|
+
|
12
|
+
class LLMConfig(BaseModel):
|
13
|
+
"""
|
14
|
+
LLMConfig is the configuration for the LLM.
|
15
|
+
|
16
|
+
Attributes:
|
17
|
+
model: The model to use
|
18
|
+
messages: The messages to send to the LLM
|
19
|
+
temperature: The temperature to use
|
20
|
+
top_p: The top_p to use
|
21
|
+
n: The number of completions to generate
|
22
|
+
stream: Whether to stream the completions
|
23
|
+
stream_options: The options for the stream
|
24
|
+
stop: The stop sequence to use
|
25
|
+
max_tokens: The maximum number of tokens to generate
|
26
|
+
max_completion_tokens: The maximum number of tokens to generate for the completion
|
27
|
+
presence_penalty: The presence penalty to use
|
28
|
+
frequency_penalty: The frequency penalty to use
|
29
|
+
logit_bias: The logit bias to use
|
30
|
+
response_format: The response format to use
|
31
|
+
seed: The seed to use
|
32
|
+
tools: The tools to use
|
33
|
+
tool_choice: The tool choice to use
|
34
|
+
parallel_tool_calls: Whether to allow parallel tool calls
|
35
|
+
logprobs: Whether to return log probabilities
|
36
|
+
top_logprobs: The number of top log probabilities to return
|
37
|
+
"""
|
38
|
+
|
39
|
+
model: str
|
40
|
+
messages: list = []
|
41
|
+
temperature: float | None = None
|
42
|
+
top_p: float | None = None
|
43
|
+
n: int | None = None
|
44
|
+
stream: bool | None = None
|
45
|
+
stream_options: dict | None = None
|
46
|
+
stop: str | list | None = None
|
47
|
+
max_tokens: int | None = None
|
48
|
+
max_completion_tokens: int | None = None
|
49
|
+
presence_penalty: float | None = None
|
50
|
+
frequency_penalty: float | None = None
|
51
|
+
logit_bias: dict | None = None
|
52
|
+
response_format: dict | type[BaseModel] | str | None = None
|
53
|
+
seed: int | None = None
|
54
|
+
tools: list | None = None
|
55
|
+
tool_choice: str | None = None
|
56
|
+
parallel_tool_calls: bool | None = None
|
57
|
+
logprobs: bool | None = None
|
58
|
+
top_logprobs: int | None = None
|
59
|
+
|
60
|
+
|
61
|
+
class ContentPartText(BaseModel):
|
62
|
+
"""
|
63
|
+
ContentPartText is the text content of the message.
|
64
|
+
|
65
|
+
Attributes:
|
66
|
+
text: The text content.
|
67
|
+
type: The type of the content part.
|
68
|
+
"""
|
69
|
+
|
70
|
+
text: str = Field(..., description="The text content.")
|
71
|
+
type: Literal["text"] = Field(
|
72
|
+
default="text", description="The type of the content part."
|
73
|
+
)
|
74
|
+
|
75
|
+
|
76
|
+
class ImageURL(BaseModel):
|
77
|
+
"""
|
78
|
+
ImageURL is the URL of the image.
|
79
|
+
|
80
|
+
Attributes:
|
81
|
+
url: The URL of the image.
|
82
|
+
detail: The detail level of the image.
|
83
|
+
"""
|
84
|
+
|
85
|
+
url: str = Field(
|
86
|
+
..., description="Either a URL of the image or the base64 encoded image data."
|
87
|
+
)
|
88
|
+
detail: Literal["auto", "low", "high"] = Field(
|
89
|
+
...,
|
90
|
+
description="""Specifies the detail level of the image.
|
91
|
+
|
92
|
+
Learn more in the
|
93
|
+
[Vision guide](https://platform.openai.com/docs/guides/vision/low-or-high-fidelity-image-understanding).
|
94
|
+
""",
|
95
|
+
)
|
96
|
+
|
97
|
+
|
98
|
+
class ContentPartImage(BaseModel):
|
99
|
+
"""
|
100
|
+
ContentPartImage is the image content of the message.
|
101
|
+
|
102
|
+
Attributes:
|
103
|
+
image_url: The URL of the image.
|
104
|
+
type: The type of the content part.
|
105
|
+
"""
|
106
|
+
|
107
|
+
image_url: ImageURL = Field(..., description="The image URL.")
|
108
|
+
type: Literal["image_url"] = Field(..., description="The type of the content part.")
|
109
|
+
|
110
|
+
|
111
|
+
class FileContent(BaseModel):
|
112
|
+
"""
|
113
|
+
FileContent is the file content of the message.
|
114
|
+
|
115
|
+
Attributes:
|
116
|
+
filename: The name of the file.
|
117
|
+
file_data: The base64 encoded file data with MIME type, e.g., 'data:application/pdf;base64,...'
|
118
|
+
"""
|
119
|
+
|
120
|
+
filename: str = Field(..., description="The name of the file.")
|
121
|
+
file_data: str = Field(
|
122
|
+
...,
|
123
|
+
description="The base64 encoded file data with MIME type, e.g., 'data:application/pdf;base64,...'",
|
124
|
+
)
|
125
|
+
|
126
|
+
|
127
|
+
class ContentPartFile(BaseModel):
|
128
|
+
"""
|
129
|
+
ContentPartFile is the file content of the message.
|
130
|
+
|
131
|
+
Attributes:
|
132
|
+
file: The file content.
|
133
|
+
type: The type of the content part.
|
134
|
+
"""
|
135
|
+
|
136
|
+
file: FileContent = Field(..., description="The file content.")
|
137
|
+
type: Literal["file"] = Field(
|
138
|
+
default="file", description="The type of the content part."
|
139
|
+
)
|
140
|
+
|
141
|
+
|
142
|
+
ContentPart = ContentPartText | ContentPartImage | ContentPartFile
|
143
|
+
|
144
|
+
|
145
|
+
class SystemMessage(BaseModel):
|
146
|
+
"""
|
147
|
+
SystemMessage is the system message of the message.
|
148
|
+
|
149
|
+
Attributes:
|
150
|
+
role: The role of the messages author, in this case `system`.
|
151
|
+
content: The contents of the system message.
|
152
|
+
"""
|
153
|
+
|
154
|
+
role: Literal["system"] = Field(
|
155
|
+
default="system",
|
156
|
+
description="The role of the messages author, in this case `system`.",
|
157
|
+
)
|
158
|
+
content: str = Field(..., description="The contents of the system message.")
|
159
|
+
|
160
|
+
|
161
|
+
class UserMessage(BaseModel):
|
162
|
+
"""
|
163
|
+
UserMessage is the user message of the message.
|
164
|
+
|
165
|
+
Attributes:
|
166
|
+
role: The role of the messages author, in this case `user`.
|
167
|
+
content: The contents of the user message.
|
168
|
+
"""
|
169
|
+
|
170
|
+
role: Literal["user"] = Field(
|
171
|
+
default="user",
|
172
|
+
description="The role of the messages author, in this case `user`.",
|
173
|
+
)
|
174
|
+
content: str | list[ContentPart] = Field(
|
175
|
+
...,
|
176
|
+
description="The contents of the user message. Can be a string or a list of content parts.",
|
177
|
+
)
|
178
|
+
|
179
|
+
|
180
|
+
class ToolCall(BaseModel):
|
181
|
+
"""
|
182
|
+
ToolCall is the tool call of the message.
|
183
|
+
|
184
|
+
Attributes:
|
185
|
+
name: The name of the function to call.
|
186
|
+
arguments: The arguments to call the function with, as generated by the model in JSON format.
|
187
|
+
"""
|
188
|
+
|
189
|
+
name: str | None = Field(
|
190
|
+
default=None, description="The name of the function to call."
|
191
|
+
)
|
192
|
+
arguments: str | None = Field(
|
193
|
+
default=None,
|
194
|
+
description="""
|
195
|
+
The arguments to call the function with, as generated by the model in JSON
|
196
|
+
format. Note that the model does not always generate valid JSON, and may
|
197
|
+
hallucinate parameters not defined by your function schema. Validate the
|
198
|
+
arguments in your code before calling your function.
|
199
|
+
""",
|
200
|
+
)
|
201
|
+
|
202
|
+
|
203
|
+
class ToolCallRequest(BaseModel):
|
204
|
+
"""
|
205
|
+
ToolCallRequest is the tool call request of the message.
|
206
|
+
|
207
|
+
Attributes:
|
208
|
+
type: The type of the tool. Currently, only `function` is supported.
|
209
|
+
id: The ID of the tool call request.
|
210
|
+
function: The function that the model is requesting.
|
211
|
+
index: The index of the tool call request.
|
212
|
+
"""
|
213
|
+
|
214
|
+
type: Literal["function"] = Field(
|
215
|
+
default="function",
|
216
|
+
description="The type of the tool. Currently, only `function` is supported.",
|
217
|
+
)
|
218
|
+
id: str | None = Field(default=None, description="The ID of the tool call request.")
|
219
|
+
function: ToolCall = Field(
|
220
|
+
..., description="The function that the model is requesting."
|
221
|
+
)
|
222
|
+
index: int | None = None
|
223
|
+
|
224
|
+
|
225
|
+
class AssistantMessage(BaseModel):
|
226
|
+
"""
|
227
|
+
AssistantMessage is the assistant message of the message.
|
228
|
+
|
229
|
+
Attributes:
|
230
|
+
role: The role of the messages author, in this case `assistant`.
|
231
|
+
content: The contents of the assistant message.
|
232
|
+
tool_calls: The tool calls generated by the model, such as function calls.
|
233
|
+
parsed: The parsed content of the message to a specific type
|
234
|
+
"""
|
235
|
+
|
236
|
+
role: Literal["assistant"] = Field(
|
237
|
+
default="assistant",
|
238
|
+
description="The role of the messages author, in this case `assistant`.",
|
239
|
+
)
|
240
|
+
content: str | None = Field(
|
241
|
+
default=None,
|
242
|
+
description="""The contents of the assistant message.
|
243
|
+
|
244
|
+
Required unless `tool_calls` or `function_call` is specified.
|
245
|
+
""",
|
246
|
+
)
|
247
|
+
tool_calls: list[ToolCallRequest] | None = Field(
|
248
|
+
default=None,
|
249
|
+
description="The tool calls generated by the model, such as function calls.",
|
250
|
+
)
|
251
|
+
parsed: Any | None = Field(
|
252
|
+
default=None, description="The parsed content of the message to a specific type"
|
253
|
+
)
|
254
|
+
|
255
|
+
|
256
|
+
class ToolMessage(BaseModel):
|
257
|
+
"""
|
258
|
+
ToolMessage is the tool message of the message.
|
259
|
+
|
260
|
+
Attributes:
|
261
|
+
role: The role of the messages author, in this case `tool`.
|
262
|
+
content: The contents of the tool message.
|
263
|
+
tool_call_id: The tool call that this message is responding to.
|
264
|
+
name: The name of the tool called.
|
265
|
+
is_error: Whether the tool call was successful.
|
266
|
+
"""
|
267
|
+
|
268
|
+
role: Literal["tool"] = Field(
|
269
|
+
default="tool",
|
270
|
+
description="The role of the messages author, in this case `tool`.",
|
271
|
+
)
|
272
|
+
content: str | list[ContentPart] = Field(
|
273
|
+
..., description="The contents of the tool message."
|
274
|
+
)
|
275
|
+
tool_call_id: str = Field(
|
276
|
+
..., description="Tool call that this message is responding to."
|
277
|
+
)
|
278
|
+
# name is optional based on OAI API defined here for chat_completion_input: https://platform.openai.com/docs/api-reference/chat/create
|
279
|
+
name: str | None = Field(default=None, description="The name of the tool called.")
|
280
|
+
is_error: bool | None = Field(
|
281
|
+
default=None, description="Whether the tool call was successful."
|
282
|
+
)
|
283
|
+
|
284
|
+
|
285
|
+
Message = Annotated[
|
286
|
+
SystemMessage | UserMessage | AssistantMessage | ToolMessage,
|
287
|
+
Field(discriminator="role"),
|
288
|
+
]
|
289
|
+
|
290
|
+
|
291
|
+
class Delta(BaseModel):
|
292
|
+
"""
|
293
|
+
Delta is the delta of the message.
|
294
|
+
|
295
|
+
Attributes:
|
296
|
+
content: The content of the delta.
|
297
|
+
role: The role of the delta.
|
298
|
+
tool_calls: The tool calls of the delta.
|
299
|
+
"""
|
300
|
+
|
301
|
+
content: str | None = Field(default=None)
|
302
|
+
role: str | None = Field(default=None)
|
303
|
+
tool_calls: list[ToolCallRequest] | None = Field(default=None)
|
304
|
+
|
305
|
+
|
306
|
+
class Choice(BaseModel):
|
307
|
+
"""
|
308
|
+
Choice is the choice of the message.
|
309
|
+
|
310
|
+
Attributes:
|
311
|
+
index: The index of the choice.
|
312
|
+
finish_reason: The finish reason of the choice.
|
313
|
+
message: The message of the choice.
|
314
|
+
delta: The delta of the choice.
|
315
|
+
"""
|
316
|
+
|
317
|
+
index: int
|
318
|
+
finish_reason: Literal["stop", "length", "content_filter", "tool_calls"] | None = (
|
319
|
+
None
|
320
|
+
)
|
321
|
+
message: AssistantMessage | None = None
|
322
|
+
delta: Delta | None = None
|
323
|
+
|
324
|
+
|
325
|
+
class Usage(BaseModel):
|
326
|
+
"""
|
327
|
+
Usage is the usage of the message.
|
328
|
+
|
329
|
+
Attributes:
|
330
|
+
prompt_tokens: The number of prompt tokens.
|
331
|
+
completion_tokens: The number of completion tokens.
|
332
|
+
total_tokens: The total number of tokens.
|
333
|
+
"""
|
334
|
+
|
335
|
+
prompt_tokens: int
|
336
|
+
completion_tokens: int
|
337
|
+
total_tokens: int
|
338
|
+
|
339
|
+
|
340
|
+
class Completion(BaseModel):
|
341
|
+
"""
|
342
|
+
Completion is the completion of the message.
|
343
|
+
|
344
|
+
Attributes:
|
345
|
+
choices: The choices of the completion.
|
346
|
+
created: The created time of the completion.
|
347
|
+
model: The model of the completion.
|
348
|
+
usage: The usage of the completion.
|
349
|
+
"""
|
350
|
+
|
351
|
+
choices: list[Choice]
|
352
|
+
created: int | None = None
|
353
|
+
model: str | None = None
|
354
|
+
usage: Usage | None = None
|
@@ -0,0 +1,171 @@
|
|
1
|
+
from enum import Enum
|
2
|
+
from typing import Annotated, Literal
|
3
|
+
|
4
|
+
from pydantic import Field, model_validator
|
5
|
+
|
6
|
+
from agentex.types.task_message import TaskMessage
|
7
|
+
from agentex.types.task_message_content import TaskMessageContent
|
8
|
+
from agentex.lib.utils.model_utils import BaseModel
|
9
|
+
|
10
|
+
|
11
|
+
class BaseTaskMessageDelta(BaseModel):
|
12
|
+
"""
|
13
|
+
Base class for all delta updates
|
14
|
+
|
15
|
+
Attributes:
|
16
|
+
type: The type of delta update
|
17
|
+
"""
|
18
|
+
|
19
|
+
type: Literal["text", "data", "tool_request", "tool_response"]
|
20
|
+
|
21
|
+
|
22
|
+
class TextDelta(BaseTaskMessageDelta):
|
23
|
+
"""
|
24
|
+
Delta for text updates
|
25
|
+
|
26
|
+
Attributes:
|
27
|
+
type: The type of delta update
|
28
|
+
text_delta: The delta for the text
|
29
|
+
"""
|
30
|
+
|
31
|
+
type: Literal["text"] = "text"
|
32
|
+
text_delta: str | None = ""
|
33
|
+
|
34
|
+
|
35
|
+
class DataDelta(BaseTaskMessageDelta):
|
36
|
+
"""
|
37
|
+
Delta for data updates
|
38
|
+
|
39
|
+
Attributes:
|
40
|
+
type: The type of delta update
|
41
|
+
data_delta: The delta for the data
|
42
|
+
"""
|
43
|
+
|
44
|
+
type: Literal["data"] = "data"
|
45
|
+
data_delta: str | None = ""
|
46
|
+
|
47
|
+
|
48
|
+
class ToolRequestDelta(BaseTaskMessageDelta):
|
49
|
+
"""
|
50
|
+
Delta for tool request updates
|
51
|
+
|
52
|
+
Attributes:
|
53
|
+
type: The type of delta update
|
54
|
+
name: The name of the tool
|
55
|
+
arguments_delta: The delta for the arguments
|
56
|
+
"""
|
57
|
+
|
58
|
+
type: Literal["tool_request"] = "tool_request"
|
59
|
+
tool_call_id: str
|
60
|
+
name: str
|
61
|
+
arguments_delta: str | None = ""
|
62
|
+
|
63
|
+
|
64
|
+
class ToolResponseDelta(BaseTaskMessageDelta):
|
65
|
+
"""
|
66
|
+
Delta for tool response updates
|
67
|
+
|
68
|
+
Attributes:
|
69
|
+
type: The type of delta update
|
70
|
+
tool_response_delta: The delta for the tool response
|
71
|
+
"""
|
72
|
+
|
73
|
+
type: Literal["tool_response"] = "tool_response"
|
74
|
+
tool_call_id: str
|
75
|
+
name: str
|
76
|
+
tool_response_delta: str | None = ""
|
77
|
+
|
78
|
+
|
79
|
+
TaskMessageDelta = Annotated[
|
80
|
+
TextDelta | DataDelta | ToolRequestDelta | ToolResponseDelta,
|
81
|
+
Field(discriminator="type"),
|
82
|
+
]
|
83
|
+
|
84
|
+
|
85
|
+
class StreamTaskMessage(BaseModel):
|
86
|
+
"""Base class for all task message stream events
|
87
|
+
|
88
|
+
Attributes:
|
89
|
+
type: The type of task message update
|
90
|
+
parent_task_message: The parent task message
|
91
|
+
index: The index of the task message
|
92
|
+
"""
|
93
|
+
|
94
|
+
type: Literal["start", "delta", "full", "done"]
|
95
|
+
# Used for streaming chunks to a direct parent_task_message
|
96
|
+
parent_task_message: TaskMessage | None = None
|
97
|
+
# Used to correlate chunks of different task messages with each other
|
98
|
+
# directly in the Sync ACP case
|
99
|
+
index: int | None = None
|
100
|
+
|
101
|
+
@model_validator(mode="after")
|
102
|
+
def validate_message_correlation(self):
|
103
|
+
"""Ensure exactly one of index or parent_task_message is set"""
|
104
|
+
has_parent = self.parent_task_message is not None
|
105
|
+
has_index = self.index is not None
|
106
|
+
|
107
|
+
if not has_parent and not has_index:
|
108
|
+
raise ValueError("Either 'index' or 'parent_task_message' must be set")
|
109
|
+
|
110
|
+
if has_parent and has_index:
|
111
|
+
raise ValueError(
|
112
|
+
"Cannot set both 'index' and 'parent_task_message' - only one is allowed"
|
113
|
+
)
|
114
|
+
|
115
|
+
return self
|
116
|
+
|
117
|
+
|
118
|
+
# Everything is streamed as a partial json blob, except for text.
|
119
|
+
class StreamTaskMessageStart(StreamTaskMessage):
|
120
|
+
"""Event for starting a streaming message
|
121
|
+
|
122
|
+
Attributes:
|
123
|
+
type: The type of task message update
|
124
|
+
content: The content of the task message
|
125
|
+
"""
|
126
|
+
|
127
|
+
type: Literal["start"] = "start"
|
128
|
+
content: TaskMessageContent
|
129
|
+
|
130
|
+
|
131
|
+
class StreamTaskMessageDelta(StreamTaskMessage):
|
132
|
+
"""Event for streaming chunks of content
|
133
|
+
|
134
|
+
Attributes:
|
135
|
+
type: The type of task message update
|
136
|
+
delta: The delta of the task message
|
137
|
+
"""
|
138
|
+
|
139
|
+
type: Literal["delta"] = "delta"
|
140
|
+
delta: TaskMessageDelta | None = None
|
141
|
+
|
142
|
+
|
143
|
+
class StreamTaskMessageFull(StreamTaskMessage):
|
144
|
+
"""Event for streaming the full content
|
145
|
+
|
146
|
+
Attributes:
|
147
|
+
type: The type of task message update
|
148
|
+
content: The content of the task message
|
149
|
+
"""
|
150
|
+
|
151
|
+
type: Literal["full"] = "full"
|
152
|
+
content: TaskMessageContent
|
153
|
+
|
154
|
+
|
155
|
+
class StreamTaskMessageDone(StreamTaskMessage):
|
156
|
+
"""Event for indicating the task is done
|
157
|
+
|
158
|
+
Attributes:
|
159
|
+
type: The type of task message update
|
160
|
+
"""
|
161
|
+
|
162
|
+
type: Literal["done"] = "done"
|
163
|
+
|
164
|
+
|
165
|
+
TaskMessageUpdate = Annotated[
|
166
|
+
StreamTaskMessageStart
|
167
|
+
| StreamTaskMessageDelta
|
168
|
+
| StreamTaskMessageFull
|
169
|
+
| StreamTaskMessageDone,
|
170
|
+
Field(discriminator="type"),
|
171
|
+
]
|
@@ -0,0 +1,34 @@
|
|
1
|
+
from typing import Annotated, Literal
|
2
|
+
|
3
|
+
from pydantic import Field
|
4
|
+
|
5
|
+
from agentex.lib.utils.model_utils import BaseModel
|
6
|
+
|
7
|
+
|
8
|
+
class BaseModelWithTraceParams(BaseModel):
|
9
|
+
"""
|
10
|
+
Base model with trace parameters.
|
11
|
+
|
12
|
+
Attributes:
|
13
|
+
trace_id: The trace ID
|
14
|
+
parent_span_id: The parent span ID
|
15
|
+
"""
|
16
|
+
|
17
|
+
trace_id: str | None = None
|
18
|
+
parent_span_id: str | None = None
|
19
|
+
|
20
|
+
|
21
|
+
class AgentexTracingProcessorConfig(BaseModel):
|
22
|
+
type: Literal["agentex"] = "agentex"
|
23
|
+
|
24
|
+
|
25
|
+
class SGPTracingProcessorConfig(BaseModel):
|
26
|
+
type: Literal["sgp"] = "sgp"
|
27
|
+
sgp_api_key: str
|
28
|
+
sgp_account_id: str
|
29
|
+
|
30
|
+
|
31
|
+
TracingProcessorConfig = Annotated[
|
32
|
+
AgentexTracingProcessorConfig | SGPTracingProcessorConfig,
|
33
|
+
Field(discriminator="type"),
|
34
|
+
]
|
File without changes
|