local-openai2anthropic 0.2.0__py3-none-any.whl → 0.2.2__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.
@@ -529,12 +529,39 @@ async def convert_openai_stream_to_anthropic(
529
529
 
530
530
  choice = chunk.choices[0]
531
531
  delta = choice.delta
532
-
532
+
533
533
  # Track finish reason
534
534
  if choice.finish_reason:
535
535
  finish_reason = choice.finish_reason
536
536
  continue
537
-
537
+
538
+ # Handle reasoning content (thinking)
539
+ if delta.reasoning_content:
540
+ reasoning = delta.reasoning_content
541
+ # Start thinking content block if not already started
542
+ if not content_block_started or content_block_index == 0:
543
+ # We need a separate index for thinking block
544
+ if content_block_started:
545
+ # Close previous block
546
+ yield {
547
+ "type": "content_block_stop",
548
+ "index": content_block_index,
549
+ }
550
+ content_block_index += 1
551
+ yield {
552
+ "type": "content_block_start",
553
+ "index": content_block_index,
554
+ "content_block": {"type": "thinking", "thinking": ""},
555
+ }
556
+ content_block_started = True
557
+
558
+ yield {
559
+ "type": "content_block_delta",
560
+ "index": content_block_index,
561
+ "delta": {"type": "thinking_delta", "thinking": reasoning},
562
+ }
563
+ continue
564
+
538
565
  # Handle content
539
566
  if delta.content:
540
567
  if not content_block_started:
@@ -148,6 +148,23 @@ async def _stream_response(
148
148
  finish_reason = choice["finish_reason"]
149
149
  continue
150
150
 
151
+ # Handle reasoning content (thinking)
152
+ if delta.get("reasoning_content"):
153
+ reasoning = delta["reasoning_content"]
154
+ # Start thinking content block if not already started
155
+ if not content_block_started or content_block_index == 0:
156
+ # We need a separate index for thinking block
157
+ # For simplicity, we treat thinking as a separate block before text
158
+ if content_block_started:
159
+ # Close previous block
160
+ yield f"event: content_block_stop\ndata: {json.dumps({'type': 'content_block_stop', 'index': content_block_index})}\n\n"
161
+ content_block_index += 1
162
+ yield f"event: content_block_start\ndata: {json.dumps({'type': 'content_block_start', 'index': content_block_index, 'content_block': {'type': 'thinking', 'thinking': ''}})}\n\n"
163
+ content_block_started = True
164
+
165
+ yield f"event: content_block_delta\ndata: {json.dumps({'type': 'content_block_delta', 'index': content_block_index, 'delta': {'type': 'thinking_delta', 'thinking': reasoning}})}\n\n"
166
+ continue
167
+
151
168
  # Handle content
152
169
  if delta.get("content"):
153
170
  if not content_block_started:
@@ -562,6 +579,7 @@ async def create_message(
562
579
  try:
563
580
  body_bytes = await request.body()
564
581
  body_json = json.loads(body_bytes.decode("utf-8"))
582
+ logger.info(f"Received body: {body_json}")
565
583
  anthropic_params = body_json
566
584
  except json.JSONDecodeError as e:
567
585
  logger.error(f"Invalid JSON in request body: {e}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: local-openai2anthropic
3
- Version: 0.2.0
3
+ Version: 0.2.2
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
@@ -1,18 +1,18 @@
1
1
  local_openai2anthropic/__init__.py,sha256=jgIoIwQXIXS83WbRUx2CF1x0A8DloLduoUIUGXwWhSU,1059
2
2
  local_openai2anthropic/__main__.py,sha256=K21u5u7FN8-DbO67TT_XDF0neGqJeFrVNkteRauCRQk,179
3
3
  local_openai2anthropic/config.py,sha256=jkPqZZ_uaEjG9uOTEyLnrJS74VVONJdKvgab2XzMTDs,1917
4
- local_openai2anthropic/converter.py,sha256=0Zx_CmYsr9i4315lEPy9O2YV5o05ZYhWtW5n6uQ38Qk,21668
4
+ local_openai2anthropic/converter.py,sha256=u5YaeuOZZfcx4vAxAyXS52TKDory9w_nVwkOhEOBme4,22757
5
5
  local_openai2anthropic/daemon.py,sha256=pZnRojGFcuIpR8yLDNjV-b0LJRBVhgRAa-dKeRRse44,10017
6
6
  local_openai2anthropic/daemon_runner.py,sha256=rguOH0PgpbjqNsKYei0uCQX8JQOQ1wmtQH1CtW95Dbw,3274
7
7
  local_openai2anthropic/main.py,sha256=5tdgPel8RSCn1iK0d7hYAmcTM9vYHlepgQujaEXA2ic,9866
8
8
  local_openai2anthropic/protocol.py,sha256=vUEgxtRPFll6jEtLc4DyxTLCBjrWIEScZXhEqe4uibk,5185
9
- local_openai2anthropic/router.py,sha256=Er2LGA0KY_qJDFSd7-23zrnADqIxrlz8bJ36C5ENXLY,31352
9
+ local_openai2anthropic/router.py,sha256=xgZiH7Nnb74OJ2_PSIfO9oOgVtUG4akEciUAuuJozJ4,32673
10
10
  local_openai2anthropic/tavily_client.py,sha256=QsBhnyF8BFWPAxB4XtWCCpHCquNL5SW93-zjTTi4Meg,3774
11
11
  local_openai2anthropic/server_tools/__init__.py,sha256=QlJfjEta-HOCtLe7NaY_fpbEKv-ZpInjAnfmSqE9tbk,615
12
12
  local_openai2anthropic/server_tools/base.py,sha256=pNFsv-jSgxVrkY004AHAcYMNZgVSO8ZOeCzQBUtQ3vU,5633
13
13
  local_openai2anthropic/server_tools/web_search.py,sha256=1C7lX_cm-tMaN3MsCjinEZYPJc_Hj4yAxYay9h8Zbvs,6543
14
- local_openai2anthropic-0.2.0.dist-info/METADATA,sha256=hNw_gZZ5LCr63bIbzHYQI07rUCkE3T6I3qC2imRnxvI,10040
15
- local_openai2anthropic-0.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
16
- local_openai2anthropic-0.2.0.dist-info/entry_points.txt,sha256=hdc9tSJUNxyNLXcTYye5SuD2K0bEQhxBhGnWTFup6ZM,116
17
- local_openai2anthropic-0.2.0.dist-info/licenses/LICENSE,sha256=X3_kZy3lJvd_xp8IeyUcIAO2Y367MXZc6aaRx8BYR_s,11369
18
- local_openai2anthropic-0.2.0.dist-info/RECORD,,
14
+ local_openai2anthropic-0.2.2.dist-info/METADATA,sha256=1LDwStgAm9IYC4MV52b9VxgjNQCY8eR2gUd2Ini7ET8,10040
15
+ local_openai2anthropic-0.2.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
16
+ local_openai2anthropic-0.2.2.dist-info/entry_points.txt,sha256=hdc9tSJUNxyNLXcTYye5SuD2K0bEQhxBhGnWTFup6ZM,116
17
+ local_openai2anthropic-0.2.2.dist-info/licenses/LICENSE,sha256=X3_kZy3lJvd_xp8IeyUcIAO2Y367MXZc6aaRx8BYR_s,11369
18
+ local_openai2anthropic-0.2.2.dist-info/RECORD,,