local-openai2anthropic 0.2.0__tar.gz → 0.2.2__tar.gz
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.
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/PKG-INFO +1 -1
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/pyproject.toml +1 -1
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/converter.py +29 -2
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/router.py +18 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/.env.example +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/.github/workflows/publish.yml +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/.gitignore +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/LICENSE +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/README.md +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/README_zh.md +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/debug_request.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/examples/basic_chat.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/examples/streaming.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/examples/thinking_mode.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/examples/tool_calling.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/examples/vision.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/examples/web_search.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/__init__.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/__main__.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/config.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/daemon.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/daemon_runner.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/main.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/protocol.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/server_tools/__init__.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/server_tools/base.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/server_tools/web_search.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/tavily_client.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/tests/__init__.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/tests/test_converter.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/tests/test_integration.py +0 -0
- {local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/tests/test_router.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: local-openai2anthropic
|
|
3
|
-
Version: 0.2.
|
|
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
|
|
@@ -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:
|
{local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/router.py
RENAMED
|
@@ -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}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/__init__.py
RENAMED
|
File without changes
|
{local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/__main__.py
RENAMED
|
File without changes
|
{local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/config.py
RENAMED
|
File without changes
|
{local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/daemon.py
RENAMED
|
File without changes
|
|
File without changes
|
{local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/main.py
RENAMED
|
File without changes
|
{local_openai2anthropic-0.2.0 → local_openai2anthropic-0.2.2}/src/local_openai2anthropic/protocol.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|