glaip-sdk 0.6.5b9__py3-none-any.whl → 0.6.6__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.
- glaip_sdk/agents/base.py +7 -43
- glaip_sdk/cli/slash/accounts_controller.py +110 -32
- glaip_sdk/cli/slash/agent_session.py +4 -1
- glaip_sdk/cli/slash/prompt.py +11 -0
- glaip_sdk/cli/slash/session.py +35 -6
- glaip_sdk/cli/slash/tui/accounts_app.py +4 -0
- glaip_sdk/cli/transcript/viewer.py +4 -2
- glaip_sdk/client/tools.py +5 -3
- glaip_sdk/registry/tool.py +11 -4
- glaip_sdk/utils/runtime_config.py +0 -116
- {glaip_sdk-0.6.5b9.dist-info → glaip_sdk-0.6.6.dist-info}/METADATA +3 -17
- {glaip_sdk-0.6.5b9.dist-info → glaip_sdk-0.6.6.dist-info}/RECORD +14 -28
- {glaip_sdk-0.6.5b9.dist-info → glaip_sdk-0.6.6.dist-info}/WHEEL +1 -1
- glaip_sdk/runner/__init__.py +0 -59
- glaip_sdk/runner/base.py +0 -84
- glaip_sdk/runner/deps.py +0 -115
- glaip_sdk/runner/langgraph.py +0 -597
- glaip_sdk/runner/mcp_adapter/__init__.py +0 -13
- glaip_sdk/runner/mcp_adapter/base_mcp_adapter.py +0 -43
- glaip_sdk/runner/mcp_adapter/langchain_mcp_adapter.py +0 -158
- glaip_sdk/runner/mcp_adapter/mcp_config_builder.py +0 -95
- glaip_sdk/runner/tool_adapter/__init__.py +0 -18
- glaip_sdk/runner/tool_adapter/base_tool_adapter.py +0 -44
- glaip_sdk/runner/tool_adapter/langchain_tool_adapter.py +0 -177
- glaip_sdk/utils/a2a/__init__.py +0 -34
- glaip_sdk/utils/a2a/event_processor.py +0 -188
- glaip_sdk/utils/tool_detection.py +0 -33
- {glaip_sdk-0.6.5b9.dist-info → glaip_sdk-0.6.6.dist-info}/entry_points.txt +0 -0
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
"""A2A event stream processing utilities.
|
|
2
|
-
|
|
3
|
-
This module provides helpers for processing the A2AEvent stream emitted by
|
|
4
|
-
agent execution backends (e.g., `arun_a2a_stream()`).
|
|
5
|
-
|
|
6
|
-
The MVP implementation focuses on extracting final response text;
|
|
7
|
-
full A2AConnector-equivalent normalization is deferred to follow-up PRs.
|
|
8
|
-
|
|
9
|
-
Authors:
|
|
10
|
-
Christian Trisno Sen Long Chen (christian.t.s.l.chen@gdplabs.id)
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
from __future__ import annotations
|
|
14
|
-
|
|
15
|
-
from dataclasses import dataclass
|
|
16
|
-
from typing import Any
|
|
17
|
-
|
|
18
|
-
from gllm_core.utils import LoggerManager
|
|
19
|
-
|
|
20
|
-
logger = LoggerManager().get_logger(__name__)
|
|
21
|
-
|
|
22
|
-
# A2A event type constants (matching aip_agents.schema.a2a.A2AStreamEventType)
|
|
23
|
-
EVENT_TYPE_FINAL_RESPONSE = "final_response"
|
|
24
|
-
EVENT_TYPE_STATUS_UPDATE = "status_update"
|
|
25
|
-
EVENT_TYPE_TOOL_CALL = "tool_call"
|
|
26
|
-
EVENT_TYPE_TOOL_RESULT = "tool_result"
|
|
27
|
-
EVENT_TYPE_ERROR = "error"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
@dataclass(frozen=True, slots=True)
|
|
31
|
-
class A2AEventStreamProcessor:
|
|
32
|
-
"""Processor for `arun_a2a_stream()` event dictionaries.
|
|
33
|
-
|
|
34
|
-
The SDK uses lightweight dictionaries to represent A2A stream events.
|
|
35
|
-
This helper centralizes event-type normalization and MVP final-text extraction.
|
|
36
|
-
|
|
37
|
-
Example:
|
|
38
|
-
>>> processor = A2AEventStreamProcessor()
|
|
39
|
-
>>> events = [{"event_type": "final_response", "content": "Hello!", "is_final": True}]
|
|
40
|
-
>>> result = processor.extract_final_response(events)
|
|
41
|
-
>>> print(result)
|
|
42
|
-
Hello!
|
|
43
|
-
"""
|
|
44
|
-
|
|
45
|
-
def extract_final_response(self, events: list[dict[str, Any]]) -> str:
|
|
46
|
-
"""Extract the final response text from a list of A2AEvents.
|
|
47
|
-
|
|
48
|
-
Scans the event list for the final_response event and returns its content.
|
|
49
|
-
If no final_response is found, raises a RuntimeError.
|
|
50
|
-
|
|
51
|
-
Args:
|
|
52
|
-
events: List of A2AEvent dictionaries from arun_a2a_stream().
|
|
53
|
-
|
|
54
|
-
Returns:
|
|
55
|
-
The content string from the final_response event.
|
|
56
|
-
|
|
57
|
-
Raises:
|
|
58
|
-
RuntimeError: If no final_response event is found in the stream.
|
|
59
|
-
"""
|
|
60
|
-
for event in reversed(events):
|
|
61
|
-
if self._is_final_response_event(event):
|
|
62
|
-
content = event.get("content", "")
|
|
63
|
-
logger.debug("Extracted final response: %d characters", len(str(content)))
|
|
64
|
-
return str(content)
|
|
65
|
-
|
|
66
|
-
# Fallback: check for events with is_final=True
|
|
67
|
-
for event in reversed(events):
|
|
68
|
-
if event.get("is_final", False):
|
|
69
|
-
content = event.get("content", "")
|
|
70
|
-
if content:
|
|
71
|
-
logger.debug("Extracted final from is_final flag: %d chars", len(str(content)))
|
|
72
|
-
return str(content)
|
|
73
|
-
|
|
74
|
-
raise RuntimeError(
|
|
75
|
-
"No final response received from the agent. The agent execution completed without producing a final answer."
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
def get_event_type(self, event: dict[str, Any]) -> str:
|
|
79
|
-
"""Get the normalized event type string from an A2AEvent.
|
|
80
|
-
|
|
81
|
-
Args:
|
|
82
|
-
event: An A2AEvent dictionary.
|
|
83
|
-
|
|
84
|
-
Returns:
|
|
85
|
-
The event type as a lowercase string.
|
|
86
|
-
"""
|
|
87
|
-
event_type = event.get("event_type", "unknown")
|
|
88
|
-
if isinstance(event_type, str):
|
|
89
|
-
return event_type.lower()
|
|
90
|
-
# Handle enum types (A2AStreamEventType)
|
|
91
|
-
return getattr(event_type, "value", str(event_type)).lower()
|
|
92
|
-
|
|
93
|
-
def is_tool_event(self, event: dict[str, Any]) -> bool:
|
|
94
|
-
"""Check if an event is a tool-related event.
|
|
95
|
-
|
|
96
|
-
Args:
|
|
97
|
-
event: An A2AEvent dictionary.
|
|
98
|
-
|
|
99
|
-
Returns:
|
|
100
|
-
True if this is a tool_call or tool_result event.
|
|
101
|
-
"""
|
|
102
|
-
event_type = self.get_event_type(event)
|
|
103
|
-
return event_type in (EVENT_TYPE_TOOL_CALL, EVENT_TYPE_TOOL_RESULT)
|
|
104
|
-
|
|
105
|
-
def is_error_event(self, event: dict[str, Any]) -> bool:
|
|
106
|
-
"""Check if an event is an error event.
|
|
107
|
-
|
|
108
|
-
Args:
|
|
109
|
-
event: An A2AEvent dictionary.
|
|
110
|
-
|
|
111
|
-
Returns:
|
|
112
|
-
True if this is an error event.
|
|
113
|
-
"""
|
|
114
|
-
return self.get_event_type(event) == EVENT_TYPE_ERROR
|
|
115
|
-
|
|
116
|
-
def _is_final_response_event(self, event: dict[str, Any]) -> bool:
|
|
117
|
-
"""Check if an event is a final_response event.
|
|
118
|
-
|
|
119
|
-
Args:
|
|
120
|
-
event: An A2AEvent dictionary.
|
|
121
|
-
|
|
122
|
-
Returns:
|
|
123
|
-
True if this is a final_response event, False otherwise.
|
|
124
|
-
"""
|
|
125
|
-
return self.get_event_type(event) == EVENT_TYPE_FINAL_RESPONSE
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
# Default processor instance for convenience functions
|
|
129
|
-
_DEFAULT_PROCESSOR = A2AEventStreamProcessor()
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
def extract_final_response(events: list[dict[str, Any]]) -> str:
|
|
133
|
-
"""Extract the final response text from a list of A2AEvents.
|
|
134
|
-
|
|
135
|
-
Convenience function that uses the default A2AEventStreamProcessor.
|
|
136
|
-
|
|
137
|
-
Args:
|
|
138
|
-
events: List of A2AEvent dictionaries from arun_a2a_stream().
|
|
139
|
-
|
|
140
|
-
Returns:
|
|
141
|
-
The content string from the final_response event.
|
|
142
|
-
|
|
143
|
-
Raises:
|
|
144
|
-
RuntimeError: If no final_response event is found in the stream.
|
|
145
|
-
"""
|
|
146
|
-
return _DEFAULT_PROCESSOR.extract_final_response(events)
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
def get_event_type(event: dict[str, Any]) -> str:
|
|
150
|
-
"""Get the normalized event type string from an A2AEvent.
|
|
151
|
-
|
|
152
|
-
Convenience function that uses the default A2AEventStreamProcessor.
|
|
153
|
-
|
|
154
|
-
Args:
|
|
155
|
-
event: An A2AEvent dictionary.
|
|
156
|
-
|
|
157
|
-
Returns:
|
|
158
|
-
The event type as a lowercase string.
|
|
159
|
-
"""
|
|
160
|
-
return _DEFAULT_PROCESSOR.get_event_type(event)
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
def is_tool_event(event: dict[str, Any]) -> bool:
|
|
164
|
-
"""Check if an event is a tool-related event.
|
|
165
|
-
|
|
166
|
-
Convenience function that uses the default A2AEventStreamProcessor.
|
|
167
|
-
|
|
168
|
-
Args:
|
|
169
|
-
event: An A2AEvent dictionary.
|
|
170
|
-
|
|
171
|
-
Returns:
|
|
172
|
-
True if this is a tool_call or tool_result event.
|
|
173
|
-
"""
|
|
174
|
-
return _DEFAULT_PROCESSOR.is_tool_event(event)
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
def is_error_event(event: dict[str, Any]) -> bool:
|
|
178
|
-
"""Check if an event is an error event.
|
|
179
|
-
|
|
180
|
-
Convenience function that uses the default A2AEventStreamProcessor.
|
|
181
|
-
|
|
182
|
-
Args:
|
|
183
|
-
event: An A2AEvent dictionary.
|
|
184
|
-
|
|
185
|
-
Returns:
|
|
186
|
-
True if this is an error event.
|
|
187
|
-
"""
|
|
188
|
-
return _DEFAULT_PROCESSOR.is_error_event(event)
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"""Shared utilities for tool type detection.
|
|
2
|
-
|
|
3
|
-
Authors:
|
|
4
|
-
Christian Trisno Sen Long Chen (christian.t.s.l.chen@gdplabs.id)
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
from typing import Any
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def is_langchain_tool(ref: Any) -> bool:
|
|
11
|
-
"""Check if ref is a LangChain BaseTool class or instance.
|
|
12
|
-
|
|
13
|
-
Shared by:
|
|
14
|
-
- ToolRegistry._is_custom_tool() (for upload detection)
|
|
15
|
-
- LangChainToolAdapter._is_langchain_tool() (for adaptation)
|
|
16
|
-
|
|
17
|
-
Args:
|
|
18
|
-
ref: Object to check.
|
|
19
|
-
|
|
20
|
-
Returns:
|
|
21
|
-
True if ref is a LangChain BaseTool class or instance.
|
|
22
|
-
"""
|
|
23
|
-
try:
|
|
24
|
-
from langchain_core.tools import BaseTool # noqa: PLC0415
|
|
25
|
-
|
|
26
|
-
if isinstance(ref, type) and issubclass(ref, BaseTool):
|
|
27
|
-
return True
|
|
28
|
-
if isinstance(ref, BaseTool):
|
|
29
|
-
return True
|
|
30
|
-
except ImportError:
|
|
31
|
-
pass
|
|
32
|
-
|
|
33
|
-
return False
|
|
File without changes
|