meshagent-anthropic 0.22.2__py3-none-any.whl → 0.24.0__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.
- meshagent/anthropic/messages_adapter.py +60 -40
- meshagent/anthropic/version.py +1 -1
- {meshagent_anthropic-0.22.2.dist-info → meshagent_anthropic-0.24.0.dist-info}/METADATA +4 -4
- {meshagent_anthropic-0.22.2.dist-info → meshagent_anthropic-0.24.0.dist-info}/RECORD +7 -7
- {meshagent_anthropic-0.22.2.dist-info → meshagent_anthropic-0.24.0.dist-info}/WHEEL +1 -1
- {meshagent_anthropic-0.22.2.dist-info → meshagent_anthropic-0.24.0.dist-info}/licenses/LICENSE +0 -0
- {meshagent_anthropic-0.22.2.dist-info → meshagent_anthropic-0.24.0.dist-info}/top_level.txt +0 -0
|
@@ -153,50 +153,56 @@ class AnthropicMessagesToolResponseAdapter(ToolResponseAdapter):
|
|
|
153
153
|
return [{"role": "user", "content": response.outputs}]
|
|
154
154
|
|
|
155
155
|
tool_result_content: list[dict]
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
156
|
+
try:
|
|
157
|
+
if isinstance(response, FileResponse):
|
|
158
|
+
mime_type = (response.mime_type or "").lower()
|
|
159
|
+
|
|
160
|
+
if mime_type == "image/jpg":
|
|
161
|
+
mime_type = "image/jpeg"
|
|
162
|
+
|
|
163
|
+
if mime_type.startswith("image/"):
|
|
164
|
+
allowed = {"image/jpeg", "image/png", "image/gif", "image/webp"}
|
|
165
|
+
if mime_type not in allowed:
|
|
166
|
+
output = f"{response.name} was returned as {response.mime_type}, which Anthropic does not accept as an image block"
|
|
167
|
+
tool_result_content = [_text_block(output)]
|
|
168
|
+
else:
|
|
169
|
+
tool_result_content = [
|
|
170
|
+
{
|
|
171
|
+
"type": "image",
|
|
172
|
+
"source": {
|
|
173
|
+
"type": "base64",
|
|
174
|
+
"media_type": mime_type,
|
|
175
|
+
"data": base64.b64encode(response.data).decode(
|
|
176
|
+
"utf-8"
|
|
177
|
+
),
|
|
178
|
+
},
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
|
|
182
|
+
elif mime_type == "application/pdf":
|
|
169
183
|
tool_result_content = [
|
|
170
184
|
{
|
|
171
|
-
"type": "
|
|
185
|
+
"type": "document",
|
|
186
|
+
"title": response.name,
|
|
172
187
|
"source": {
|
|
173
188
|
"type": "base64",
|
|
174
|
-
"media_type":
|
|
189
|
+
"media_type": "application/pdf",
|
|
175
190
|
"data": base64.b64encode(response.data).decode("utf-8"),
|
|
176
191
|
},
|
|
177
192
|
}
|
|
178
193
|
]
|
|
179
194
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
"type": "document",
|
|
184
|
-
"title": response.name,
|
|
185
|
-
"source": {
|
|
186
|
-
"type": "base64",
|
|
187
|
-
"media_type": "application/pdf",
|
|
188
|
-
"data": base64.b64encode(response.data).decode("utf-8"),
|
|
189
|
-
},
|
|
190
|
-
}
|
|
191
|
-
]
|
|
195
|
+
else:
|
|
196
|
+
output = await self.to_plain_text(room=room, response=response)
|
|
197
|
+
tool_result_content = [_text_block(output)]
|
|
192
198
|
|
|
193
199
|
else:
|
|
194
200
|
output = await self.to_plain_text(room=room, response=response)
|
|
195
201
|
tool_result_content = [_text_block(output)]
|
|
196
202
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
tool_result_content = [_text_block(
|
|
203
|
+
except Exception as ex:
|
|
204
|
+
logger.error("unable to process tool call results", exc_info=ex)
|
|
205
|
+
tool_result_content = [_text_block(f"Error: {ex}")]
|
|
200
206
|
|
|
201
207
|
message = {
|
|
202
208
|
"role": "user",
|
|
@@ -533,16 +539,30 @@ class AnthropicMessagesAdapter(LLMAdapter[dict]):
|
|
|
533
539
|
on_behalf_of=on_behalf_of,
|
|
534
540
|
caller_context={"chat": context.to_json()},
|
|
535
541
|
)
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
542
|
+
try:
|
|
543
|
+
tool_response = await tool_bundle.execute(
|
|
544
|
+
context=tool_context,
|
|
545
|
+
tool_use=tool_use,
|
|
546
|
+
)
|
|
547
|
+
return await tool_adapter.create_messages(
|
|
548
|
+
context=context,
|
|
549
|
+
tool_call=tool_use,
|
|
550
|
+
room=room,
|
|
551
|
+
response=tool_response,
|
|
552
|
+
)
|
|
553
|
+
except Exception as ex:
|
|
554
|
+
tool_result_content = [_text_block(f"Error: {ex}")]
|
|
555
|
+
message = {
|
|
556
|
+
"role": "user",
|
|
557
|
+
"content": [
|
|
558
|
+
{
|
|
559
|
+
"type": "tool_result",
|
|
560
|
+
"tool_use_id": tool_use.get("id"),
|
|
561
|
+
"content": tool_result_content,
|
|
562
|
+
}
|
|
563
|
+
],
|
|
564
|
+
}
|
|
565
|
+
return [message]
|
|
546
566
|
|
|
547
567
|
for tool_use in tool_uses:
|
|
548
568
|
tasks.append(asyncio.create_task(do_tool(tool_use)))
|
meshagent/anthropic/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.
|
|
1
|
+
__version__ = "0.24.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: meshagent-anthropic
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.24.0
|
|
4
4
|
Summary: Anthropic Building Blocks for Meshagent
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Project-URL: Documentation, https://docs.meshagent.com
|
|
@@ -11,9 +11,9 @@ Description-Content-Type: text/markdown
|
|
|
11
11
|
License-File: LICENSE
|
|
12
12
|
Requires-Dist: pytest~=8.4
|
|
13
13
|
Requires-Dist: pytest-asyncio~=0.26
|
|
14
|
-
Requires-Dist: meshagent-api~=0.
|
|
15
|
-
Requires-Dist: meshagent-agents~=0.
|
|
16
|
-
Requires-Dist: meshagent-tools~=0.
|
|
14
|
+
Requires-Dist: meshagent-api~=0.24.0
|
|
15
|
+
Requires-Dist: meshagent-agents~=0.24.0
|
|
16
|
+
Requires-Dist: meshagent-tools~=0.24.0
|
|
17
17
|
Requires-Dist: anthropic<1.0,>=0.25
|
|
18
18
|
Dynamic: license-file
|
|
19
19
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
meshagent/anthropic/__init__.py,sha256=2VOFYIp1DY2ed8YfstSB1kV8n7hSX72v8d7gapm9INE,542
|
|
2
2
|
meshagent/anthropic/mcp.py,sha256=9yDMOPo9wihMmPIpQUKXdAYDPTkZmCfRuW-OyWVPvLA,3218
|
|
3
|
-
meshagent/anthropic/messages_adapter.py,sha256=
|
|
3
|
+
meshagent/anthropic/messages_adapter.py,sha256=WzVXpCWkrl5-fVM8PAAMSULQdy5wwB1ClQUy7AZpexk,24037
|
|
4
4
|
meshagent/anthropic/openai_responses_stream_adapter.py,sha256=ODtWusjnPDNedE_Nx5dTdEAhihpWmAXyEbYHuF42D8M,15763
|
|
5
|
-
meshagent/anthropic/version.py,sha256=
|
|
5
|
+
meshagent/anthropic/version.py,sha256=DxtMZD542lg_xb6icrE2d5JOY8oUi-v34i2Ar63ddvs,23
|
|
6
6
|
meshagent/anthropic/proxy/__init__.py,sha256=_E4wvJC90tmMnatDodkD0kIB8zsDZ4_zFd-5s86WQ8c,106
|
|
7
7
|
meshagent/anthropic/proxy/proxy.py,sha256=nQ_P2c3GWAbfQswlc11DTyIRJzZWaOm1Wg08HpCTl_k,2827
|
|
8
8
|
meshagent/anthropic/tests/anthropic_live_test.py,sha256=t8Uy8za0He4p4oXhnVFAx6vsuCVcFFthtwsiN-AwVT0,4571
|
|
9
9
|
meshagent/anthropic/tests/mcp_test.py,sha256=fT_dDiBNMraGOLtUuu2F4q3Yf4QPfZN-ypZq2iZTQoc,2140
|
|
10
10
|
meshagent/anthropic/tests/messages_adapter_test.py,sha256=BQV1zOB1xM1-wRuGyvmIdeMhubmgmZH_1-tQLFXZLi8,5265
|
|
11
11
|
meshagent/anthropic/tests/openai_responses_stream_adapter_test.py,sha256=WLkF5wSRYKV83n3GgIDoKI4EQdNJS6_EqC1_7RlMNHs,2842
|
|
12
|
-
meshagent_anthropic-0.
|
|
13
|
-
meshagent_anthropic-0.
|
|
14
|
-
meshagent_anthropic-0.
|
|
15
|
-
meshagent_anthropic-0.
|
|
16
|
-
meshagent_anthropic-0.
|
|
12
|
+
meshagent_anthropic-0.24.0.dist-info/licenses/LICENSE,sha256=TRD-XzqhdrBbIpokiGa61wuDTBc_ElKoFP9HSNihODc,10255
|
|
13
|
+
meshagent_anthropic-0.24.0.dist-info/METADATA,sha256=oiHC_L6oYgwRxSdrFrGDs8Qecq33deol2efjqFHrt0Q,1595
|
|
14
|
+
meshagent_anthropic-0.24.0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
15
|
+
meshagent_anthropic-0.24.0.dist-info/top_level.txt,sha256=GlcXnHtRP6m7zlG3Df04M35OsHtNXy_DY09oFwWrH74,10
|
|
16
|
+
meshagent_anthropic-0.24.0.dist-info/RECORD,,
|
{meshagent_anthropic-0.22.2.dist-info → meshagent_anthropic-0.24.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|