lionagi 0.12.7__py3-none-any.whl → 0.12.8__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.
@@ -83,11 +83,11 @@ ENDPOINT_CONFIG = EndpointConfig(
83
83
  endpoint="query",
84
84
  api_key="dummy",
85
85
  request_options=ClaudeCodeRequest,
86
+ timeout=3000,
86
87
  )
87
88
 
88
89
 
89
90
  class ClaudeCodeEndpoint(Endpoint):
90
-
91
91
  def __init__(self, config=ENDPOINT_CONFIG, **kwargs):
92
92
  super().__init__(config=config, **kwargs)
93
93
 
@@ -146,95 +146,51 @@ class ClaudeCodeEndpoint(Endpoint):
146
146
  When Claude Code uses tools, the ResultMessage.result may be None.
147
147
  In that case, we need to look at the tool results in UserMessages.
148
148
  """
149
- result_message = None
150
- model = "claude-code"
151
- assistant_text_content = []
152
- tool_results = []
149
+ results = {
150
+ "session_id": None,
151
+ "model": "claude-code",
152
+ "result": "",
153
+ "tool_results": [],
154
+ "is_error": False,
155
+ "num_turns": None,
156
+ "cost_usd": None,
157
+ "total_cost_usd": None,
158
+ "usage": {
159
+ "prompt_tokens": 0,
160
+ "completion_tokens": 0,
161
+ "total_tokens": 0,
162
+ },
163
+ }
164
+
165
+ from claude_code_sdk import types
153
166
 
154
- # Process all messages
155
167
  for response in responses:
156
- class_name = response.__class__.__name__
157
-
158
- if class_name == "SystemMessage" and hasattr(response, "data"):
159
- model = response.data.get("model", "claude-code")
160
-
161
- elif class_name == "AssistantMessage":
162
- # Extract text content from assistant messages
163
- if hasattr(response, "content") and response.content:
164
- for block in response.content:
165
- if hasattr(block, "text"):
166
- assistant_text_content.append(block.text)
167
- elif isinstance(block, dict) and "text" in block:
168
- assistant_text_content.append(block["text"])
169
-
170
- elif class_name == "UserMessage":
171
- # Extract tool results from user messages
172
- if hasattr(response, "content") and response.content:
173
- for item in response.content:
174
- if (
175
- isinstance(item, dict)
176
- and item.get("type") == "tool_result"
177
- ):
178
- tool_results.append(item.get("content", ""))
179
-
180
- elif class_name == "ResultMessage":
181
- result_message = response
182
-
183
- # Determine the final content
184
- final_content = ""
185
- if (
186
- result_message
187
- and hasattr(result_message, "result")
188
- and result_message.result
189
- ):
190
- # Use ResultMessage.result if available
191
- final_content = result_message.result
192
- elif assistant_text_content:
193
- # Use assistant text content if available
194
- final_content = "\n".join(assistant_text_content)
195
- elif tool_results:
196
- # If only tool results are available, use a generic summary
197
- # (Claude Code typically provides its own summary after tool use)
198
- final_content = (
199
- "I've completed the requested task using the available tools."
200
- )
201
-
202
- # Build the clean chat completions response
203
- result = {
204
- "model": model,
205
- "choices": [
206
- {
207
- "index": 0,
208
- "message": {"role": "assistant", "content": final_content},
209
- "finish_reason": (
210
- "stop"
211
- if not (
212
- result_message
213
- and hasattr(result_message, "is_error")
214
- and result_message.is_error
168
+ if isinstance(response, types.SystemMessage):
169
+ results["session_id"] = response.data.get("session_id")
170
+ results["model"] = response.data.get("model", "claude-code")
171
+ if isinstance(response, types.AssistantMessage):
172
+ for block in response.content:
173
+ if isinstance(block, types.TextBlock):
174
+ results["result"] += block.text.strip() + "\n"
175
+ if isinstance(block, types.ToolResultBlock):
176
+ results["tool_results"].append(
177
+ {
178
+ "tool_use_id": block.tool_use_id,
179
+ "content": block.content,
180
+ "is_error": block.is_error,
181
+ }
215
182
  )
216
- else "error"
217
- ),
218
- }
219
- ],
220
- }
221
-
222
- # Add usage information if available
223
- if result_message and hasattr(result_message, "usage"):
224
- result["usage"] = result_message.usage
225
-
226
- # Add only essential Claude Code metadata
227
- if result_message:
228
- if hasattr(result_message, "cost_usd"):
229
- result["usage"]["cost_usd"] = result_message.cost_usd
230
- if hasattr(result_message, "session_id"):
231
- result["session_id"] = result_message.session_id
232
- if hasattr(result_message, "is_error"):
233
- result["is_error"] = result_message.is_error
234
- if hasattr(result_message, "num_turns"):
235
- result["num_turns"] = result_message.num_turns
236
-
237
- return result
183
+ if isinstance(response, types.ResultMessage):
184
+ results["result"] += response.result.strip() or ""
185
+ results["usage"] = response.usage
186
+ results["cost_usd"] = response.cost_usd
187
+ results["is_error"] = response.is_error
188
+ results["total_cost_usd"] = response.total_cost_usd
189
+ results["num_turns"] = response.num_turns
190
+ results["duration_ms"] = response.duration_ms
191
+ results["duration_api_ms"] = response.duration_api_ms
192
+
193
+ return results
238
194
 
239
195
  async def _call(
240
196
  self,
@@ -98,10 +98,21 @@ GROQ_CHAT_ENDPOINT_CONFIG = EndpointConfig(
98
98
 
99
99
 
100
100
  REASONING_MODELS = (
101
- "o3-mini-2025-01-31",
102
- "o3-mini",
103
101
  "o1",
104
102
  "o1-2024-12-17",
103
+ "o1-preview-2024-09-12",
104
+ "o1-pro",
105
+ "o1-pro-2025-03-19",
106
+ "o3-pro",
107
+ "o3-pro-2025-06-10",
108
+ "o3",
109
+ "o3-2025-04-16",
110
+ "o4-mini",
111
+ "o4-mini-2025-04-16",
112
+ "o3-mini",
113
+ "o3-mini-2025-01-31",
114
+ "o1-mini",
115
+ "o1-mini-2024-09-12",
105
116
  )
106
117
 
107
118
  REASONING_NOT_SUPPORT_PARAMS = (
lionagi/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.12.7"
1
+ __version__ = "0.12.8"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lionagi
3
- Version: 0.12.7
3
+ Version: 0.12.8
4
4
  Summary: An Intelligence Operating System.
5
5
  Author-email: HaiyangLi <quantocean.li@gmail.com>, Liangbingyan Luo <llby_luo@outlook.com>
6
6
  License: Apache License
@@ -6,7 +6,7 @@ lionagi/config.py,sha256=dAhDFKtaaSfn6WT9dwX9Vd4TWWs6-Su1FgYIrFgYcgc,3709
6
6
  lionagi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  lionagi/settings.py,sha256=W52mM34E6jXF3GyqCFzVREKZrmnUqtZm_BVDsUiDI_s,1627
8
8
  lionagi/utils.py,sha256=uLTJKl7aTnFXV6ehA6zwiwEB7G2nQYKsO2pZ6mqFzUk,78908
9
- lionagi/version.py,sha256=WvcWmk-c-I-XXiq6oM9Y1VYwNWFe64tXpnG_RI47HhE,23
9
+ lionagi/version.py,sha256=F7xxYe0dXryqS1cGEXFikx8AI7-UsZzdi89hJdyx-b0,23
10
10
  lionagi/fields/__init__.py,sha256=8oU7Vfk-fKiULFKqhM6VpJMqdZcVXPTM7twVfNDN_SQ,603
11
11
  lionagi/fields/action.py,sha256=iWSApCM77jS0Oc28lb7G601Etkp-yjx5U1hfI_FQgfA,5792
12
12
  lionagi/fields/base.py,sha256=5CJc7j8kTTWzXwpYzkSAFzx4BglABfx3AElIATKB7bg,3857
@@ -177,9 +177,9 @@ lionagi/service/connections/header_factory.py,sha256=22sG4ian3MiNklF6SdQqkEYgtWK
177
177
  lionagi/service/connections/match_endpoint.py,sha256=mEZPDkK1qtvjTGN9-PZsK7w_yB7642nZiJsb0l5QUx4,1827
178
178
  lionagi/service/connections/providers/__init__.py,sha256=3lzOakDoBWmMaNnT2g-YwktPKa_Wme4lnPRSmOQfayY,105
179
179
  lionagi/service/connections/providers/anthropic_.py,sha256=SUPnw2UqjY5wuHXLHas6snMTzhQ-UuixvPYbkVnXn34,3083
180
- lionagi/service/connections/providers/claude_code_.py,sha256=1kCLHjc-bqjCsG6HieaJQWy6SCV6PzBZGjTneLPhCY0,8845
180
+ lionagi/service/connections/providers/claude_code_.py,sha256=o7tfhCcOxkOKe3dwdzIme6ov0B3Os1Xiu9uewIw2pg0,7182
181
181
  lionagi/service/connections/providers/exa_.py,sha256=GGWaD9jd5gKM257OfUaIBBKIqR1NrNcBE67p_7JbK7g,938
182
- lionagi/service/connections/providers/oai_.py,sha256=rKZdGufX4vpj88rr98KqoOHzHa7HgH_pCVWjCqAq-XU,4971
182
+ lionagi/service/connections/providers/oai_.py,sha256=hH5oEMvS9A0Kbvh-lSFm5dLiqPV2gfRra6zzDOq78P0,5191
183
183
  lionagi/service/connections/providers/ollama_.py,sha256=jdx6dGeChwVk5TFfFRbpnrpKzj8YQZw6D5iWJ6zYmfk,4096
184
184
  lionagi/service/connections/providers/perplexity_.py,sha256=9MH9YmMy9Jg7JDMJHQxxMYHyjJ4NP0OlN7sCuhla85I,917
185
185
  lionagi/service/third_party/README.md,sha256=qFjWnI8rmLivIyr6Tc-hRZh-rQwntROp76af4MBNJJc,2214
@@ -198,7 +198,7 @@ lionagi/tools/types.py,sha256=XtJLY0m-Yi_ZLWhm0KycayvqMCZd--HxfQ0x9vFUYDE,230
198
198
  lionagi/tools/file/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
199
199
  lionagi/tools/file/reader.py,sha256=0TdnfVGVCKuM58MmGM-NyVjhU9BFoitkNYEepdc0z_Y,9529
200
200
  lionagi/tools/memory/tools.py,sha256=zTGBenVsF8Wuh303kWntmQSGlAFKonHNdh5ePuQ26KE,15948
201
- lionagi-0.12.7.dist-info/METADATA,sha256=6cpK8bMdHTYDG78vn9Gl09ENET3A4vYkfaot81uoAa0,20200
202
- lionagi-0.12.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
203
- lionagi-0.12.7.dist-info/licenses/LICENSE,sha256=VXFWsdoN5AAknBCgFqQNgPWYx7OPp-PFEP961zGdOjc,11288
204
- lionagi-0.12.7.dist-info/RECORD,,
201
+ lionagi-0.12.8.dist-info/METADATA,sha256=8cD7ID0yI0CK3JqF0MelRZPsodoqUS1GyQJsnW44yZs,20200
202
+ lionagi-0.12.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
203
+ lionagi-0.12.8.dist-info/licenses/LICENSE,sha256=VXFWsdoN5AAknBCgFqQNgPWYx7OPp-PFEP961zGdOjc,11288
204
+ lionagi-0.12.8.dist-info/RECORD,,