agentex-sdk 0.4.18__py3-none-any.whl → 0.4.20__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 +0 -1
- agentex/_utils/_typing.py +3 -1
- agentex/_version.py +1 -1
- agentex/lib/adk/__init__.py +3 -0
- agentex/lib/adk/_modules/acp.py +3 -1
- agentex/lib/adk/_modules/agent_task_tracker.py +3 -1
- agentex/lib/adk/_modules/agents.py +3 -1
- agentex/lib/adk/_modules/events.py +3 -1
- agentex/lib/adk/_modules/messages.py +3 -1
- agentex/lib/adk/_modules/state.py +3 -1
- agentex/lib/adk/_modules/streaming.py +3 -1
- agentex/lib/adk/_modules/tasks.py +4 -2
- agentex/lib/adk/_modules/tracing.py +3 -1
- agentex/lib/adk/providers/__init__.py +2 -2
- agentex/lib/adk/providers/_modules/litellm.py +10 -11
- agentex/lib/adk/providers/_modules/openai.py +27 -28
- agentex/lib/adk/providers/_modules/sgp.py +5 -6
- agentex/lib/adk/utils/_modules/client.py +4 -1
- agentex/lib/adk/utils/_modules/templating.py +5 -6
- agentex/lib/cli/commands/agents.py +21 -21
- agentex/lib/cli/commands/init.py +3 -3
- agentex/lib/cli/commands/main.py +3 -3
- agentex/lib/cli/commands/secrets.py +10 -10
- agentex/lib/cli/commands/tasks.py +26 -28
- agentex/lib/cli/commands/uv.py +1 -1
- agentex/lib/cli/debug/__init__.py +1 -1
- agentex/lib/cli/debug/debug_config.py +1 -2
- agentex/lib/cli/debug/debug_handlers.py +6 -4
- agentex/lib/cli/handlers/agent_handlers.py +15 -16
- agentex/lib/cli/handlers/cleanup_handlers.py +1 -1
- agentex/lib/cli/handlers/deploy_handlers.py +41 -55
- agentex/lib/cli/handlers/run_handlers.py +13 -16
- agentex/lib/cli/handlers/secret_handlers.py +25 -25
- agentex/lib/cli/templates/temporal/project/acp.py.j2 +11 -8
- agentex/lib/cli/utils/auth_utils.py +3 -2
- agentex/lib/cli/utils/credential_utils.py +1 -1
- agentex/lib/cli/utils/kubectl_utils.py +3 -3
- agentex/lib/cli/utils/kubernetes_secrets_utils.py +4 -4
- agentex/lib/cli/utils/path_utils.py +2 -2
- agentex/lib/core/adapters/llm/adapter_litellm.py +9 -4
- agentex/lib/core/adapters/llm/adapter_sgp.py +10 -7
- agentex/lib/core/adapters/llm/port.py +1 -1
- agentex/lib/core/adapters/streams/adapter_redis.py +7 -4
- agentex/lib/core/adapters/streams/port.py +1 -1
- agentex/lib/core/clients/temporal/temporal_client.py +34 -34
- agentex/lib/core/clients/temporal/types.py +1 -1
- agentex/lib/core/clients/temporal/utils.py +9 -12
- agentex/lib/core/services/adk/acp/acp.py +6 -6
- agentex/lib/core/services/adk/agent_task_tracker.py +1 -1
- agentex/lib/core/services/adk/agents.py +1 -1
- agentex/lib/core/services/adk/events.py +1 -1
- agentex/lib/core/services/adk/messages.py +5 -6
- agentex/lib/core/services/adk/providers/litellm.py +10 -10
- agentex/lib/core/services/adk/providers/openai.py +75 -43
- agentex/lib/core/services/adk/providers/sgp.py +3 -3
- agentex/lib/core/services/adk/state.py +5 -1
- agentex/lib/core/services/adk/streaming.py +19 -19
- agentex/lib/core/services/adk/tasks.py +8 -2
- agentex/lib/core/services/adk/tracing.py +3 -2
- agentex/lib/core/services/adk/utils/templating.py +4 -2
- agentex/lib/core/temporal/activities/__init__.py +27 -27
- agentex/lib/core/temporal/activities/activity_helpers.py +1 -1
- agentex/lib/core/temporal/activities/adk/acp/acp_activities.py +4 -4
- agentex/lib/core/temporal/activities/adk/agent_task_tracker_activities.py +1 -1
- agentex/lib/core/temporal/activities/adk/agents_activities.py +2 -2
- agentex/lib/core/temporal/activities/adk/events_activities.py +1 -1
- agentex/lib/core/temporal/activities/adk/messages_activities.py +3 -3
- agentex/lib/core/temporal/activities/adk/providers/litellm_activities.py +4 -4
- agentex/lib/core/temporal/activities/adk/providers/sgp_activities.py +1 -1
- agentex/lib/core/temporal/activities/adk/state_activities.py +1 -1
- agentex/lib/core/temporal/activities/adk/streaming_activities.py +3 -3
- agentex/lib/core/temporal/activities/adk/tasks_activities.py +2 -2
- agentex/lib/core/temporal/activities/adk/tracing_activities.py +1 -1
- agentex/lib/core/temporal/activities/adk/utils/templating_activities.py +1 -1
- agentex/lib/core/temporal/services/temporal_task_service.py +7 -7
- agentex/lib/core/temporal/workers/worker.py +31 -40
- agentex/lib/core/temporal/workflows/workflow.py +2 -2
- agentex/lib/core/tracing/__init__.py +2 -2
- agentex/lib/core/tracing/processors/agentex_tracing_processor.py +6 -6
- agentex/lib/core/tracing/processors/sgp_tracing_processor.py +16 -16
- agentex/lib/core/tracing/processors/tracing_processor_interface.py +1 -1
- agentex/lib/core/tracing/trace.py +7 -7
- agentex/lib/core/tracing/tracer.py +2 -2
- agentex/lib/core/tracing/tracing_processor_manager.py +43 -13
- agentex/lib/environment_variables.py +5 -4
- agentex/lib/sdk/config/agent_config.py +2 -2
- agentex/lib/sdk/config/agent_manifest.py +8 -8
- agentex/lib/sdk/config/environment_config.py +10 -2
- agentex/lib/sdk/config/project_config.py +6 -6
- agentex/lib/sdk/config/validation.py +2 -2
- agentex/lib/sdk/fastacp/base/base_acp_server.py +31 -13
- agentex/lib/sdk/fastacp/fastacp.py +14 -15
- agentex/lib/sdk/fastacp/impl/agentic_base_acp.py +4 -5
- agentex/lib/sdk/fastacp/impl/sync_acp.py +7 -7
- agentex/lib/sdk/fastacp/impl/temporal_acp.py +28 -19
- agentex/lib/sdk/fastacp/tests/conftest.py +18 -16
- agentex/lib/sdk/fastacp/tests/run_tests.py +1 -1
- agentex/lib/sdk/fastacp/tests/test_base_acp_server.py +4 -4
- agentex/lib/sdk/fastacp/tests/test_fastacp_factory.py +8 -8
- agentex/lib/sdk/fastacp/tests/test_integration.py +15 -14
- agentex/lib/sdk/state_machine/__init__.py +1 -1
- agentex/lib/sdk/state_machine/noop_workflow.py +5 -3
- agentex/lib/sdk/state_machine/state_machine.py +18 -12
- agentex/lib/sdk/utils/messages.py +5 -5
- agentex/lib/types/acp.py +2 -2
- agentex/lib/types/agent_configs.py +1 -1
- agentex/lib/types/converters.py +4 -2
- agentex/lib/types/credentials.py +1 -1
- agentex/lib/types/fastacp.py +4 -5
- agentex/lib/types/tracing.py +1 -1
- agentex/lib/utils/completions.py +5 -5
- agentex/lib/utils/console.py +1 -1
- agentex/lib/utils/debug.py +10 -5
- agentex/lib/utils/dev_tools/async_messages.py +11 -12
- agentex/lib/utils/iterables.py +1 -1
- agentex/lib/utils/json_schema.py +4 -4
- agentex/lib/utils/logging.py +62 -14
- agentex/lib/utils/mcp.py +1 -0
- agentex/lib/utils/model_utils.py +4 -5
- agentex/lib/utils/registration.py +5 -4
- agentex/resources/agents.py +11 -4
- agentex/types/agent_rpc_response.py +3 -3
- agentex/types/data_content.py +1 -1
- agentex/types/tool_request_content.py +1 -1
- agentex/types/tool_response_content.py +0 -1
- {agentex_sdk-0.4.18.dist-info → agentex_sdk-0.4.20.dist-info}/METADATA +4 -1
- {agentex_sdk-0.4.18.dist-info → agentex_sdk-0.4.20.dist-info}/RECORD +130 -130
- {agentex_sdk-0.4.18.dist-info → agentex_sdk-0.4.20.dist-info}/WHEEL +0 -0
- {agentex_sdk-0.4.18.dist-info → agentex_sdk-0.4.20.dist-info}/entry_points.txt +0 -0
- {agentex_sdk-0.4.18.dist-info → agentex_sdk-0.4.20.dist-info}/licenses/LICENSE +0 -0
@@ -1,8 +1,8 @@
|
|
1
|
-
from pathlib import Path
|
2
1
|
from typing import Dict
|
2
|
+
from pathlib import Path
|
3
3
|
|
4
|
-
from agentex.lib.sdk.config.agent_manifest import AgentManifest
|
5
4
|
from agentex.lib.utils.logging import make_logger
|
5
|
+
from agentex.lib.sdk.config.agent_manifest import AgentManifest
|
6
6
|
|
7
7
|
logger = make_logger(__name__)
|
8
8
|
|
@@ -1,15 +1,17 @@
|
|
1
|
-
from
|
1
|
+
from typing import override
|
2
|
+
from collections.abc import Generator, AsyncGenerator
|
2
3
|
|
3
4
|
import litellm as llm
|
4
5
|
|
5
|
-
from agentex.lib.core.adapters.llm.port import LLMGateway
|
6
|
-
from agentex.lib.types.llm_messages import Completion
|
7
6
|
from agentex.lib.utils.logging import make_logger
|
7
|
+
from agentex.lib.types.llm_messages import Completion
|
8
|
+
from agentex.lib.core.adapters.llm.port import LLMGateway
|
8
9
|
|
9
10
|
logger = make_logger(__name__)
|
10
11
|
|
11
12
|
|
12
13
|
class LiteLLMGateway(LLMGateway):
|
14
|
+
@override
|
13
15
|
def completion(self, *args, **kwargs) -> Completion:
|
14
16
|
if kwargs.get("stream", True):
|
15
17
|
raise ValueError(
|
@@ -19,6 +21,7 @@ class LiteLLMGateway(LLMGateway):
|
|
19
21
|
response = llm.completion(*args, **kwargs)
|
20
22
|
return Completion.model_validate(response)
|
21
23
|
|
24
|
+
@override
|
22
25
|
def completion_stream(self, *args, **kwargs) -> Generator[Completion, None, None]:
|
23
26
|
if not kwargs.get("stream"):
|
24
27
|
raise ValueError("To use streaming, please set stream=True in the kwargs")
|
@@ -26,6 +29,7 @@ class LiteLLMGateway(LLMGateway):
|
|
26
29
|
for chunk in llm.completion(*args, **kwargs):
|
27
30
|
yield Completion.model_validate(chunk)
|
28
31
|
|
32
|
+
@override
|
29
33
|
async def acompletion(self, *args, **kwargs) -> Completion:
|
30
34
|
if kwargs.get("stream", True):
|
31
35
|
raise ValueError(
|
@@ -36,11 +40,12 @@ class LiteLLMGateway(LLMGateway):
|
|
36
40
|
response = await llm.acompletion(*args, **kwargs)
|
37
41
|
return Completion.model_validate(response)
|
38
42
|
|
43
|
+
@override
|
39
44
|
async def acompletion_stream(
|
40
45
|
self, *args, **kwargs
|
41
46
|
) -> AsyncGenerator[Completion, None]:
|
42
47
|
if not kwargs.get("stream"):
|
43
48
|
raise ValueError("To use streaming, please set stream=True in the kwargs")
|
44
49
|
|
45
|
-
async for chunk in await llm.acompletion(*args, **kwargs):
|
50
|
+
async for chunk in await llm.acompletion(*args, **kwargs): # type: ignore[misc]
|
46
51
|
yield Completion.model_validate(chunk)
|
@@ -1,11 +1,12 @@
|
|
1
1
|
import os
|
2
|
-
from
|
2
|
+
from typing import override
|
3
|
+
from collections.abc import Generator, AsyncGenerator
|
3
4
|
|
4
|
-
from scale_gp import
|
5
|
+
from scale_gp import SGPClient, AsyncSGPClient
|
5
6
|
|
6
|
-
from agentex.lib.core.adapters.llm.port import LLMGateway
|
7
|
-
from agentex.lib.types.llm_messages import Completion
|
8
7
|
from agentex.lib.utils.logging import make_logger
|
8
|
+
from agentex.lib.types.llm_messages import Completion
|
9
|
+
from agentex.lib.core.adapters.llm.port import LLMGateway
|
9
10
|
|
10
11
|
logger = make_logger(__name__)
|
11
12
|
|
@@ -17,6 +18,7 @@ class SGPLLMGateway(LLMGateway):
|
|
17
18
|
api_key=os.environ.get("SGP_API_KEY", sgp_api_key)
|
18
19
|
)
|
19
20
|
|
21
|
+
@override
|
20
22
|
def completion(self, *args, **kwargs) -> Completion:
|
21
23
|
if kwargs.get("stream", True):
|
22
24
|
raise ValueError(
|
@@ -26,6 +28,7 @@ class SGPLLMGateway(LLMGateway):
|
|
26
28
|
response = self.sync_client.beta.chat.completions.create(*args, **kwargs)
|
27
29
|
return Completion.model_validate(response)
|
28
30
|
|
31
|
+
@override
|
29
32
|
def completion_stream(self, *args, **kwargs) -> Generator[Completion, None, None]:
|
30
33
|
if not kwargs.get("stream"):
|
31
34
|
raise ValueError("To use streaming, please set stream=True in the kwargs")
|
@@ -33,6 +36,7 @@ class SGPLLMGateway(LLMGateway):
|
|
33
36
|
for chunk in self.sync_client.beta.chat.completions.create(*args, **kwargs):
|
34
37
|
yield Completion.model_validate(chunk)
|
35
38
|
|
39
|
+
@override
|
36
40
|
async def acompletion(self, *args, **kwargs) -> Completion:
|
37
41
|
if kwargs.get("stream", True):
|
38
42
|
raise ValueError(
|
@@ -43,13 +47,12 @@ class SGPLLMGateway(LLMGateway):
|
|
43
47
|
response = await self.async_client.beta.chat.completions.create(*args, **kwargs)
|
44
48
|
return Completion.model_validate(response)
|
45
49
|
|
50
|
+
@override
|
46
51
|
async def acompletion_stream(
|
47
52
|
self, *args, **kwargs
|
48
53
|
) -> AsyncGenerator[Completion, None]:
|
49
54
|
if not kwargs.get("stream"):
|
50
55
|
raise ValueError("To use streaming, please set stream=True in the kwargs")
|
51
56
|
|
52
|
-
async for chunk in
|
53
|
-
*args, **kwargs
|
54
|
-
):
|
57
|
+
async for chunk in self.async_client.beta.chat.completions.create(*args, **kwargs): # type: ignore[misc]
|
55
58
|
yield Completion.model_validate(chunk)
|
@@ -1,14 +1,14 @@
|
|
1
|
-
import asyncio
|
2
|
-
import json
|
3
1
|
import os
|
2
|
+
import json
|
3
|
+
import asyncio
|
4
|
+
from typing import Any, Annotated, override
|
4
5
|
from collections.abc import AsyncIterator
|
5
|
-
from typing import Annotated, Any
|
6
6
|
|
7
7
|
import redis.asyncio as redis
|
8
8
|
from fastapi import Depends
|
9
9
|
|
10
|
-
from agentex.lib.core.adapters.streams.port import StreamRepository
|
11
10
|
from agentex.lib.utils.logging import make_logger
|
11
|
+
from agentex.lib.core.adapters.streams.port import StreamRepository
|
12
12
|
|
13
13
|
logger = make_logger(__name__)
|
14
14
|
|
@@ -26,6 +26,7 @@ class RedisStreamRepository(StreamRepository):
|
|
26
26
|
)
|
27
27
|
self.redis = redis.from_url(self.redis_url)
|
28
28
|
|
29
|
+
@override
|
29
30
|
async def send_event(self, topic: str, event: dict[str, Any]) -> str:
|
30
31
|
"""
|
31
32
|
Send an event to a Redis stream.
|
@@ -55,6 +56,7 @@ class RedisStreamRepository(StreamRepository):
|
|
55
56
|
logger.error(f"Error publishing to Redis stream {topic}: {e}")
|
56
57
|
raise
|
57
58
|
|
59
|
+
@override
|
58
60
|
async def subscribe(
|
59
61
|
self, topic: str, last_id: str = "$"
|
60
62
|
) -> AsyncIterator[dict[str, Any]]:
|
@@ -108,6 +110,7 @@ class RedisStreamRepository(StreamRepository):
|
|
108
110
|
logger.error(f"Error reading from Redis stream: {e}")
|
109
111
|
await asyncio.sleep(1) # Back off on errors
|
110
112
|
|
113
|
+
@override
|
111
114
|
async def cleanup_stream(self, topic: str) -> None:
|
112
115
|
"""
|
113
116
|
Clean up a Redis stream.
|
@@ -1,25 +1,29 @@
|
|
1
|
-
from collections.abc import Callable
|
2
|
-
from datetime import timedelta
|
3
1
|
from typing import Any
|
2
|
+
from datetime import timedelta
|
3
|
+
from collections.abc import Callable
|
4
4
|
|
5
5
|
from temporalio.client import Client, WorkflowExecutionStatus
|
6
|
-
from temporalio.common import RetryPolicy as TemporalRetryPolicy
|
7
|
-
from temporalio.common import WorkflowIDReusePolicy
|
6
|
+
from temporalio.common import RetryPolicy as TemporalRetryPolicy, WorkflowIDReusePolicy
|
8
7
|
from temporalio.service import RPCError, RPCStatusCode
|
9
8
|
|
9
|
+
from agentex.lib.utils.logging import make_logger
|
10
|
+
from agentex.lib.utils.model_utils import BaseModel
|
10
11
|
from agentex.lib.core.clients.temporal.types import (
|
11
|
-
DuplicateWorkflowPolicy,
|
12
|
-
RetryPolicy,
|
13
12
|
TaskStatus,
|
13
|
+
RetryPolicy,
|
14
14
|
WorkflowState,
|
15
|
+
DuplicateWorkflowPolicy,
|
15
16
|
)
|
16
17
|
from agentex.lib.core.clients.temporal.utils import get_temporal_client
|
17
|
-
from agentex.lib.utils.logging import make_logger
|
18
|
-
from agentex.lib.utils.model_utils import BaseModel
|
19
18
|
|
20
19
|
logger = make_logger(__name__)
|
21
20
|
|
22
|
-
DEFAULT_RETRY_POLICY = RetryPolicy(
|
21
|
+
DEFAULT_RETRY_POLICY = RetryPolicy(
|
22
|
+
maximum_attempts=1,
|
23
|
+
initial_interval=timedelta(seconds=1),
|
24
|
+
backoff_coefficient=2.0,
|
25
|
+
maximum_interval=timedelta(minutes=10),
|
26
|
+
)
|
23
27
|
|
24
28
|
|
25
29
|
TEMPORAL_STATUS_TO_UPLOAD_STATUS_AND_REASON = {
|
@@ -36,8 +40,7 @@ TEMPORAL_STATUS_TO_UPLOAD_STATUS_AND_REASON = {
|
|
36
40
|
),
|
37
41
|
WorkflowExecutionStatus.FAILED: WorkflowState(
|
38
42
|
status=TaskStatus.FAILED,
|
39
|
-
reason="Task encountered terminal failure. "
|
40
|
-
"Please contact support if retrying does not resolve the issue.",
|
43
|
+
reason="Task encountered terminal failure. Please contact support if retrying does not resolve the issue.",
|
41
44
|
is_terminal=True,
|
42
45
|
),
|
43
46
|
WorkflowExecutionStatus.RUNNING: WorkflowState(
|
@@ -72,9 +75,16 @@ DUPLICATE_POLICY_TO_ID_REUSE_POLICY = {
|
|
72
75
|
|
73
76
|
class TemporalClient:
|
74
77
|
def __init__(self, temporal_client: Client | None = None, plugins: list[Any] = []):
|
75
|
-
self._client: Client = temporal_client
|
78
|
+
self._client: Client | None = temporal_client
|
76
79
|
self._plugins = plugins
|
77
80
|
|
81
|
+
@property
|
82
|
+
def client(self) -> Client:
|
83
|
+
"""Get the temporal client, raising an error if not initialized."""
|
84
|
+
if self._client is None:
|
85
|
+
raise RuntimeError("Temporal client not initialized - ensure temporal_address is properly configured")
|
86
|
+
return self._client
|
87
|
+
|
78
88
|
@classmethod
|
79
89
|
async def create(cls, temporal_address: str, plugins: list[Any] = []):
|
80
90
|
if temporal_address in [
|
@@ -89,18 +99,13 @@ class TemporalClient:
|
|
89
99
|
]:
|
90
100
|
_client = None
|
91
101
|
else:
|
92
|
-
_client = await get_temporal_client(
|
93
|
-
temporal_address,
|
94
|
-
plugins=plugins
|
95
|
-
)
|
102
|
+
_client = await get_temporal_client(temporal_address, plugins=plugins)
|
96
103
|
return cls(_client, plugins)
|
97
104
|
|
98
105
|
async def setup(self, temporal_address: str):
|
99
|
-
self._client = await self._get_temporal_client(
|
100
|
-
temporal_address=temporal_address
|
101
|
-
)
|
106
|
+
self._client = await self._get_temporal_client(temporal_address=temporal_address)
|
102
107
|
|
103
|
-
async def _get_temporal_client(self, temporal_address: str) -> Client:
|
108
|
+
async def _get_temporal_client(self, temporal_address: str) -> Client | None:
|
104
109
|
if temporal_address in [
|
105
110
|
"false",
|
106
111
|
"False",
|
@@ -113,10 +118,7 @@ class TemporalClient:
|
|
113
118
|
]:
|
114
119
|
return None
|
115
120
|
else:
|
116
|
-
return await get_temporal_client(
|
117
|
-
temporal_address,
|
118
|
-
plugins=self._plugins
|
119
|
-
)
|
121
|
+
return await get_temporal_client(temporal_address, plugins=self._plugins)
|
120
122
|
|
121
123
|
async def start_workflow(
|
122
124
|
self,
|
@@ -127,10 +129,8 @@ class TemporalClient:
|
|
127
129
|
execution_timeout: timedelta = timedelta(seconds=86400),
|
128
130
|
**kwargs: Any,
|
129
131
|
) -> str:
|
130
|
-
temporal_retry_policy = TemporalRetryPolicy(
|
131
|
-
|
132
|
-
)
|
133
|
-
workflow_handle = await self._client.start_workflow(
|
132
|
+
temporal_retry_policy = TemporalRetryPolicy(**retry_policy.model_dump(exclude_unset=True))
|
133
|
+
workflow_handle = await self.client.start_workflow(
|
134
134
|
*args,
|
135
135
|
retry_policy=temporal_retry_policy,
|
136
136
|
task_timeout=task_timeout,
|
@@ -146,8 +146,8 @@ class TemporalClient:
|
|
146
146
|
signal: str | Callable[[dict[str, Any] | list[Any] | str | int | float | bool | BaseModel], Any],
|
147
147
|
payload: dict[str, Any] | list[Any] | str | int | float | bool | BaseModel,
|
148
148
|
) -> None:
|
149
|
-
handle = self.
|
150
|
-
await handle.signal(signal, payload)
|
149
|
+
handle = self.client.get_workflow_handle(workflow_id=workflow_id)
|
150
|
+
await handle.signal(signal, payload) # type: ignore[misc]
|
151
151
|
|
152
152
|
async def query_workflow(
|
153
153
|
self,
|
@@ -164,12 +164,12 @@ class TemporalClient:
|
|
164
164
|
Returns:
|
165
165
|
The result of the query
|
166
166
|
"""
|
167
|
-
handle = self.
|
167
|
+
handle = self.client.get_workflow_handle(workflow_id=workflow_id)
|
168
168
|
return await handle.query(query)
|
169
169
|
|
170
170
|
async def get_workflow_status(self, workflow_id: str) -> WorkflowState:
|
171
171
|
try:
|
172
|
-
handle = self.
|
172
|
+
handle = self.client.get_workflow_handle(workflow_id=workflow_id)
|
173
173
|
description = await handle.describe()
|
174
174
|
return TEMPORAL_STATUS_TO_UPLOAD_STATUS_AND_REASON[description.status]
|
175
175
|
except RPCError as e:
|
@@ -182,7 +182,7 @@ class TemporalClient:
|
|
182
182
|
raise
|
183
183
|
|
184
184
|
async def terminate_workflow(self, workflow_id: str) -> None:
|
185
|
-
return await self.
|
185
|
+
return await self.client.get_workflow_handle(workflow_id).terminate()
|
186
186
|
|
187
187
|
async def cancel_workflow(self, workflow_id: str) -> None:
|
188
|
-
return await self.
|
188
|
+
return await self.client.get_workflow_handle(workflow_id).cancel()
|
@@ -1,7 +1,8 @@
|
|
1
1
|
from typing import Any
|
2
|
+
|
2
3
|
from temporalio.client import Client, Plugin as ClientPlugin
|
4
|
+
from temporalio.runtime import Runtime, TelemetryConfig, OpenTelemetryConfig
|
3
5
|
from temporalio.contrib.pydantic import pydantic_data_converter
|
4
|
-
from temporalio.runtime import OpenTelemetryConfig, Runtime, TelemetryConfig
|
5
6
|
|
6
7
|
# class DateTimeJSONEncoder(AdvancedJSONEncoder):
|
7
8
|
# def default(self, o: Any) -> Any:
|
@@ -42,10 +43,10 @@ from temporalio.runtime import OpenTelemetryConfig, Runtime, TelemetryConfig
|
|
42
43
|
def validate_client_plugins(plugins: list[Any]) -> None:
|
43
44
|
"""
|
44
45
|
Validate that all items in the plugins list are valid Temporal client plugins.
|
45
|
-
|
46
|
+
|
46
47
|
Args:
|
47
48
|
plugins: List of plugins to validate
|
48
|
-
|
49
|
+
|
49
50
|
Raises:
|
50
51
|
TypeError: If any plugin is not a valid ClientPlugin instance
|
51
52
|
"""
|
@@ -57,26 +58,22 @@ def validate_client_plugins(plugins: list[Any]) -> None:
|
|
57
58
|
)
|
58
59
|
|
59
60
|
|
60
|
-
async def get_temporal_client(
|
61
|
-
temporal_address: str,
|
62
|
-
metrics_url: str = None,
|
63
|
-
plugins: list[Any] = []
|
64
|
-
) -> Client:
|
61
|
+
async def get_temporal_client(temporal_address: str, metrics_url: str | None = None, plugins: list[Any] = []) -> Client:
|
65
62
|
"""
|
66
63
|
Create a Temporal client with plugin integration.
|
67
|
-
|
64
|
+
|
68
65
|
Args:
|
69
66
|
temporal_address: Temporal server address
|
70
|
-
metrics_url: Optional metrics endpoint URL
|
67
|
+
metrics_url: Optional metrics endpoint URL
|
71
68
|
plugins: List of Temporal plugins to include
|
72
|
-
|
69
|
+
|
73
70
|
Returns:
|
74
71
|
Configured Temporal client
|
75
72
|
"""
|
76
73
|
# Validate plugins if any are provided
|
77
74
|
if plugins:
|
78
75
|
validate_client_plugins(plugins)
|
79
|
-
|
76
|
+
|
80
77
|
if not metrics_url:
|
81
78
|
client = await Client.connect(
|
82
79
|
target_host=temporal_address,
|
@@ -1,18 +1,18 @@
|
|
1
1
|
from typing import Any, List, cast
|
2
2
|
|
3
3
|
from agentex import AsyncAgentex
|
4
|
-
from agentex.
|
4
|
+
from agentex.types.task import Task
|
5
|
+
from agentex.types.event import Event
|
5
6
|
from agentex.lib.utils.logging import make_logger
|
6
7
|
from agentex.lib.utils.temporal import heartbeat_if_in_workflow
|
7
|
-
from agentex.types.event import Event
|
8
|
-
from agentex.types.task import Task
|
9
8
|
from agentex.types.task_message import TaskMessage
|
10
|
-
from agentex.types.task_message_content import TaskMessageContent
|
11
|
-
from agentex.types.task_message_content_param import TaskMessageContentParam
|
12
9
|
from agentex.types.agent_rpc_params import (
|
13
|
-
ParamsCancelTaskRequest as RpcParamsCancelTaskRequest,
|
14
10
|
ParamsSendEventRequest as RpcParamsSendEventRequest,
|
11
|
+
ParamsCancelTaskRequest as RpcParamsCancelTaskRequest,
|
15
12
|
)
|
13
|
+
from agentex.lib.core.tracing.tracer import AsyncTracer
|
14
|
+
from agentex.types.task_message_content import TaskMessageContent
|
15
|
+
from agentex.types.task_message_content_param import TaskMessageContentParam
|
16
16
|
|
17
17
|
logger = make_logger(__name__)
|
18
18
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from agentex import AsyncAgentex
|
2
|
-
from agentex.lib.core.tracing.tracer import AsyncTracer
|
3
2
|
from agentex.lib.utils.logging import make_logger
|
3
|
+
from agentex.lib.core.tracing.tracer import AsyncTracer
|
4
4
|
from agentex.types.agent_task_tracker import AgentTaskTracker
|
5
5
|
|
6
6
|
logger = make_logger(__name__)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
from typing import Optional
|
2
2
|
|
3
3
|
from agentex import AsyncAgentex
|
4
|
-
from agentex.lib.core.tracing.tracer import AsyncTracer
|
5
4
|
from agentex.types.agent import Agent
|
6
5
|
from agentex.lib.utils.logging import make_logger
|
7
6
|
from agentex.lib.utils.temporal import heartbeat_if_in_workflow
|
7
|
+
from agentex.lib.core.tracing.tracer import AsyncTracer
|
8
8
|
|
9
9
|
logger = make_logger(__name__)
|
10
10
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from agentex import AsyncAgentex
|
2
|
-
from agentex.lib.core.tracing.tracer import AsyncTracer
|
3
2
|
from agentex.types.event import Event
|
4
3
|
from agentex.lib.utils.logging import make_logger
|
4
|
+
from agentex.lib.core.tracing.tracer import AsyncTracer
|
5
5
|
|
6
6
|
logger = make_logger(__name__)
|
7
7
|
|
@@ -1,14 +1,13 @@
|
|
1
1
|
import asyncio
|
2
|
-
from typing import Any, Coroutine
|
2
|
+
from typing import Any, Coroutine
|
3
3
|
|
4
4
|
from agentex import AsyncAgentex
|
5
|
-
from agentex.lib.core.services.adk.streaming import StreamingService
|
6
|
-
from agentex.lib.core.tracing.tracer import AsyncTracer
|
7
|
-
from agentex.types.task_message_update import StreamTaskMessageFull, TaskMessageUpdate
|
8
|
-
from agentex.types.task_message import TaskMessage, TaskMessageContent
|
9
5
|
from agentex.lib.utils.logging import make_logger
|
10
6
|
from agentex.lib.utils.temporal import heartbeat_if_in_workflow
|
11
|
-
from agentex.types.
|
7
|
+
from agentex.types.task_message import TaskMessage, TaskMessageContent
|
8
|
+
from agentex.lib.core.tracing.tracer import AsyncTracer
|
9
|
+
from agentex.types.task_message_update import TaskMessageUpdate, StreamTaskMessageFull
|
10
|
+
from agentex.lib.core.services.adk.streaming import StreamingService
|
12
11
|
|
13
12
|
logger = make_logger(__name__)
|
14
13
|
|
@@ -1,23 +1,23 @@
|
|
1
1
|
from collections.abc import AsyncGenerator
|
2
2
|
|
3
3
|
from agentex import AsyncAgentex
|
4
|
-
from agentex.lib.
|
5
|
-
from agentex.lib.
|
6
|
-
from agentex.
|
4
|
+
from agentex.lib.utils import logging
|
5
|
+
from agentex.lib.utils.temporal import heartbeat_if_in_workflow
|
6
|
+
from agentex.types.task_message import TaskMessage
|
7
|
+
from agentex.lib.utils.completions import concat_completion_chunks
|
7
8
|
from agentex.lib.types.llm_messages import (
|
8
|
-
Completion,
|
9
9
|
LLMConfig,
|
10
|
+
Completion,
|
10
11
|
)
|
12
|
+
from agentex.lib.core.tracing.tracer import AsyncTracer
|
13
|
+
from agentex.types.task_message_delta import TextDelta
|
11
14
|
from agentex.types.task_message_update import (
|
12
|
-
StreamTaskMessageDelta,
|
13
15
|
StreamTaskMessageFull,
|
16
|
+
StreamTaskMessageDelta,
|
14
17
|
)
|
15
|
-
from agentex.types.task_message_delta import TextDelta
|
16
|
-
from agentex.types.task_message import TaskMessage
|
17
18
|
from agentex.types.task_message_content import TextContent
|
18
|
-
from agentex.lib.
|
19
|
-
from agentex.lib.
|
20
|
-
from agentex.lib.utils.temporal import heartbeat_if_in_workflow
|
19
|
+
from agentex.lib.core.services.adk.streaming import StreamingService
|
20
|
+
from agentex.lib.core.adapters.llm.adapter_litellm import LiteLLMGateway
|
21
21
|
|
22
22
|
logger = logging.make_logger(__name__)
|
23
23
|
|