bohr-agent-sdk 0.1.17__py3-none-any.whl → 0.1.18__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bohr-agent-sdk
3
- Version: 0.1.17
3
+ Version: 0.1.18
4
4
  Summary: SDK for scientific agents
5
5
  Home-page: https://github.com/dptech-corp/bohr-agent-sdk/
6
6
  Author: DP Technology
@@ -1,7 +1,7 @@
1
1
  dp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  dp/agent/__init__.py,sha256=4kwF1khocxEkqJjnVhBV5cCsWkR_MBGrUthuHk44pT8,153
3
3
  dp/agent/adapter/adk/__init__.py,sha256=x3OZoxHzBcSP3_LAK9oDulRN1vYkEfMEm5ZdocTLlQA,395
4
- dp/agent/adapter/adk/utils.py,sha256=S6Y9IuQngKXMg0fy8mcCiuAUvOGKYm0xzFFYicgc41I,7025
4
+ dp/agent/adapter/adk/utils.py,sha256=Hf6zZOmNi0YSI9t5acmR5kzowWaYr-UfyPiN8fefPkI,7359
5
5
  dp/agent/adapter/adk/client/__init__.py,sha256=F1xfFNa4ZG8jV9adeGI2D3YBiSX-5RkvqEdTqNdJce4,209
6
6
  dp/agent/adapter/adk/client/calculation_mcp_tool.py,sha256=njEf4DvZt7HaAMpMZ1od2emWwlFUP5FtebBJ17pi20U,11774
7
7
  dp/agent/adapter/camel/__init__.py,sha256=RN1NhdmsJyN43fTxTXFld4UKZksjpSV0b2QvFn5gK7o,77
@@ -32,8 +32,8 @@ dp/agent/server/storage/bohrium_storage.py,sha256=iJqssa6JX3crlaTYGdpmzgOa0X_AbF
32
32
  dp/agent/server/storage/http_storage.py,sha256=KiySq7g9-iJr12XQCKKyJLn8wJoDnSRpQAR5_qPJ1ZU,1471
33
33
  dp/agent/server/storage/local_storage.py,sha256=t1wfjByjXew9ws3PuUxWxmZQ0-Wt1a6t4wmj3fW62GI,1352
34
34
  dp/agent/server/storage/oss_storage.py,sha256=pgjmi7Gir3Y5wkMDCvU4fvSls15fXT7Ax-h9MYHFPK0,3359
35
- bohr_agent_sdk-0.1.17.dist-info/METADATA,sha256=Wn0wUU7TBvmlJZeswoD6wtr7tiYX8WRDDbaVI-Ilwt4,6329
36
- bohr_agent_sdk-0.1.17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
- bohr_agent_sdk-0.1.17.dist-info/entry_points.txt,sha256=5n5kneF5IbDQtoQ2WfF-QuBjDtsimJte9Rv9baSGgc0,86
38
- bohr_agent_sdk-0.1.17.dist-info/top_level.txt,sha256=87xLUDhu_1nQHoGLwlhJ6XlO7OsjILh6i1nX6ljFzDo,3
39
- bohr_agent_sdk-0.1.17.dist-info/RECORD,,
35
+ bohr_agent_sdk-0.1.18.dist-info/METADATA,sha256=ok3x3E4bx8pvAceeRduWQEhVMu4311OquVUG0dE68AU,6329
36
+ bohr_agent_sdk-0.1.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
+ bohr_agent_sdk-0.1.18.dist-info/entry_points.txt,sha256=5n5kneF5IbDQtoQ2WfF-QuBjDtsimJte9Rv9baSGgc0,86
38
+ bohr_agent_sdk-0.1.18.dist-info/top_level.txt,sha256=87xLUDhu_1nQHoGLwlhJ6XlO7OsjILh6i1nX6ljFzDo,3
39
+ bohr_agent_sdk-0.1.18.dist-info/RECORD,,
@@ -116,6 +116,7 @@ def search_error_in_memory_handler(toolset):
116
116
  def extract_job_info(events: List[Event]) -> dict:
117
117
  jobs = {}
118
118
  artifacts = {}
119
+ events.sort(key=lambda event: event.timestamp)
119
120
  for event in events:
120
121
  if event.content and event.content.parts:
121
122
  for part in event.content.parts:
@@ -135,39 +136,42 @@ def extract_job_info(events: List[Event]) -> dict:
135
136
  }
136
137
  job = jobs[resp.id]
137
138
  job["timestamp"] = event.timestamp
138
- if "result" in resp.response and isinstance(
139
- resp.response["result"], types.CallToolResult):
140
- res = resp.response["result"]
139
+ res = resp.response.get("result")
140
+ if isinstance(res, dict) and "content" in res \
141
+ and "isError" in res:
142
+ res = types.CallToolResult(
143
+ content=res["content"], isError=res["isError"])
144
+ if isinstance(res, types.CallToolResult):
141
145
  if res.isError:
142
146
  err_msg = res.content[0].text
143
147
  if err_msg.startswith("Error executing tool"):
144
148
  err_msg = err_msg[err_msg.find(":")+2:]
145
149
  job["err_msg"] = err_msg
146
- else:
150
+ elif hasattr(res.content[0], "text"):
147
151
  result = jsonpickle.loads(res.content[0].text)
148
152
  if "job_id" not in result:
149
153
  job["result"] = result
150
- if hasattr(res.content[0], "job_info"):
151
- job_info = res.content[0].job_info
152
- job.update(job_info)
153
- for name, art in job_info.get(
154
- "input_artifacts", {}).items():
155
- if art["uri"] not in artifacts:
156
- artifacts[art["uri"]] = {
157
- "type": "input",
158
- "name": name,
159
- "job_id": job_info["job_id"],
160
- **art,
161
- }
162
- for name, art in job_info.get(
163
- "output_artifacts", {}).items():
164
- if art["uri"] not in artifacts:
165
- artifacts[art["uri"]] = {
166
- "type": "output",
167
- "name": name,
168
- "job_id": job_info["job_id"],
169
- **art,
170
- }
154
+ if hasattr(res.content[0], "job_info"):
155
+ job_info = res.content[0].job_info
156
+ job.update(job_info)
157
+ for name, art in job_info.get(
158
+ "input_artifacts", {}).items():
159
+ if art["uri"] not in artifacts:
160
+ artifacts[art["uri"]] = {
161
+ "type": "input",
162
+ "name": name,
163
+ "job_id": job_info["job_id"],
164
+ **art,
165
+ }
166
+ for name, art in job_info.get(
167
+ "output_artifacts", {}).items():
168
+ if art["uri"] not in artifacts:
169
+ artifacts[art["uri"]] = {
170
+ "type": "output",
171
+ "name": name,
172
+ "job_id": job_info["job_id"],
173
+ **art,
174
+ }
171
175
  return {
172
176
  "jobs": list(jobs.values()),
173
177
  "artifacts": list(artifacts.values()),