local-openai2anthropic 0.2.8__py3-none-any.whl → 0.2.9__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.
@@ -179,6 +179,19 @@ async def _stream_response(
179
179
  if choice.get("finish_reason"):
180
180
  finish_reason = choice["finish_reason"]
181
181
 
182
+ # When finish_reason is tool_calls, we need to close the current block
183
+ # and prepare to send message_delta
184
+ if finish_reason == "tool_calls" and content_block_started:
185
+ stop_block = {
186
+ "type": "content_block_stop",
187
+ "index": content_block_index,
188
+ }
189
+ logger.debug(
190
+ f"[Anthropic Stream Event] content_block_stop (tool_calls): {json.dumps(stop_block, ensure_ascii=False)}"
191
+ )
192
+ yield f"event: content_block_stop\ndata: {json.dumps(stop_block)}\n\n"
193
+ content_block_started = False
194
+
182
195
  # Handle reasoning content (thinking)
183
196
  if delta.get("reasoning_content"):
184
197
  reasoning = delta["reasoning_content"]
@@ -253,6 +266,8 @@ async def _stream_response(
253
266
  if tool_calls:
254
267
  tool_call = tool_calls[0]
255
268
 
269
+ # Handle new tool call (with id) - use separate if, not elif
270
+ # because a chunk may have both id AND arguments
256
271
  if tool_call.get("id"):
257
272
  if content_block_started:
258
273
  yield f"event: content_block_stop\ndata: {json.dumps({'type': 'content_block_stop', 'index': content_block_index})}\n\n"
@@ -264,7 +279,9 @@ async def _stream_response(
264
279
  content_block_started = True
265
280
  current_block_type = "tool_use"
266
281
 
267
- elif (tool_call.get("function") or {}).get("arguments"):
282
+ # Handle tool call arguments - always check separately
283
+ # Note: This is intentionally NOT elif, as a single chunk may contain both
284
+ if (tool_call.get("function") or {}).get("arguments"):
268
285
  args = (tool_call.get("function") or {}).get("arguments", "")
269
286
  yield f"event: content_block_delta\ndata: {json.dumps({'type': 'content_block_delta', 'index': content_block_index, 'delta': {'type': 'input_json_delta', 'partial_json': args}})}\n\n"
270
287
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: local-openai2anthropic
3
- Version: 0.2.8
3
+ Version: 0.2.9
4
4
  Summary: A lightweight proxy server that converts Anthropic Messages API to OpenAI API
5
5
  Project-URL: Homepage, https://github.com/dongfangzan/local-openai2anthropic
6
6
  Project-URL: Repository, https://github.com/dongfangzan/local-openai2anthropic
@@ -7,13 +7,13 @@ local_openai2anthropic/daemon_runner.py,sha256=rguOH0PgpbjqNsKYei0uCQX8JQOQ1wmtQ
7
7
  local_openai2anthropic/main.py,sha256=FK5JBBpzB_T44y3N16lPl1hK4ht4LEQqRKzVmkIjIoo,9866
8
8
  local_openai2anthropic/openai_types.py,sha256=jFdCvLwtXYoo5gGRqOhbHQcVaxcsxNnCP_yFPIv7rG4,3823
9
9
  local_openai2anthropic/protocol.py,sha256=vUEgxtRPFll6jEtLc4DyxTLCBjrWIEScZXhEqe4uibk,5185
10
- local_openai2anthropic/router.py,sha256=SCmwXSh02E8QX_oNCSXC5JvMDDI8Zfso0YBnPIykBss,42853
10
+ local_openai2anthropic/router.py,sha256=YZkpncYX9bI1VYtUE7srSImF3o0FZLAfM1Lfc2G-AeI,43927
11
11
  local_openai2anthropic/tavily_client.py,sha256=QsBhnyF8BFWPAxB4XtWCCpHCquNL5SW93-zjTTi4Meg,3774
12
12
  local_openai2anthropic/server_tools/__init__.py,sha256=QlJfjEta-HOCtLe7NaY_fpbEKv-ZpInjAnfmSqE9tbk,615
13
13
  local_openai2anthropic/server_tools/base.py,sha256=pNFsv-jSgxVrkY004AHAcYMNZgVSO8ZOeCzQBUtQ3vU,5633
14
14
  local_openai2anthropic/server_tools/web_search.py,sha256=1C7lX_cm-tMaN3MsCjinEZYPJc_Hj4yAxYay9h8Zbvs,6543
15
- local_openai2anthropic-0.2.8.dist-info/METADATA,sha256=VfHnmWbI52pgbH9kzjimeUJ3r0XVwvdMnTodX8-3nH4,11240
16
- local_openai2anthropic-0.2.8.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
17
- local_openai2anthropic-0.2.8.dist-info/entry_points.txt,sha256=hdc9tSJUNxyNLXcTYye5SuD2K0bEQhxBhGnWTFup6ZM,116
18
- local_openai2anthropic-0.2.8.dist-info/licenses/LICENSE,sha256=X3_kZy3lJvd_xp8IeyUcIAO2Y367MXZc6aaRx8BYR_s,11369
19
- local_openai2anthropic-0.2.8.dist-info/RECORD,,
15
+ local_openai2anthropic-0.2.9.dist-info/METADATA,sha256=tDbUvOtBGJo5DXRzVfxm7UH7XgGzRTLvokU_XcrKnkA,11240
16
+ local_openai2anthropic-0.2.9.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
17
+ local_openai2anthropic-0.2.9.dist-info/entry_points.txt,sha256=hdc9tSJUNxyNLXcTYye5SuD2K0bEQhxBhGnWTFup6ZM,116
18
+ local_openai2anthropic-0.2.9.dist-info/licenses/LICENSE,sha256=X3_kZy3lJvd_xp8IeyUcIAO2Y367MXZc6aaRx8BYR_s,11369
19
+ local_openai2anthropic-0.2.9.dist-info/RECORD,,