local-openai2anthropic 0.2.9__tar.gz → 0.3.0__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.9 → local_openai2anthropic-0.3.0}/PKG-INFO +1 -1
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/pyproject.toml +1 -1
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/router.py +52 -6
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/.github/workflows/publish.yml +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/.gitignore +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/LICENSE +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/README.md +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/README_zh.md +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/examples/basic_chat.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/examples/streaming.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/examples/thinking_mode.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/examples/tool_calling.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/examples/vision.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/examples/web_search.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/__init__.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/__main__.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/config.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/converter.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/daemon.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/daemon_runner.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/main.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/openai_types.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/protocol.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/server_tools/__init__.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/server_tools/base.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/server_tools/web_search.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/tavily_client.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/tests/__init__.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/tests/test_converter.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/tests/test_integration.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/tests/test_router.py +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/tests/test_upstream.sh +0 -0
- {local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: local-openai2anthropic
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
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
|
{local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/router.py
RENAMED
|
@@ -512,8 +512,9 @@ async def _handle_with_server_tools(
|
|
|
512
512
|
)
|
|
513
513
|
|
|
514
514
|
completion_data = response.json()
|
|
515
|
-
|
|
516
|
-
|
|
515
|
+
# Log raw OpenAI response for server tools
|
|
516
|
+
logger.info(
|
|
517
|
+
f"[OpenAI Response (Server Tools)] {json.dumps(completion_data, ensure_ascii=False, indent=2)[:2000]}"
|
|
517
518
|
)
|
|
518
519
|
from openai.types.chat import ChatCompletion
|
|
519
520
|
|
|
@@ -531,7 +532,12 @@ async def _handle_with_server_tools(
|
|
|
531
532
|
if tool_calls:
|
|
532
533
|
for tc in tool_calls:
|
|
533
534
|
func_name = tc.function.name if tc.function else ""
|
|
535
|
+
func_args = tc.function.arguments if tc.function else "{}"
|
|
534
536
|
logger.info(f" Tool call: {func_name}")
|
|
537
|
+
logger.info(f" Tool ID: {tc.id}")
|
|
538
|
+
logger.info(
|
|
539
|
+
f" Arguments: {func_args[:200]}"
|
|
540
|
+
) # Log first 200 chars
|
|
535
541
|
|
|
536
542
|
# Generate Anthropic-style ID for server tools
|
|
537
543
|
is_server = handler.is_server_tool_call(
|
|
@@ -859,20 +865,60 @@ async def create_message(
|
|
|
859
865
|
)
|
|
860
866
|
|
|
861
867
|
openai_completion = response.json()
|
|
862
|
-
|
|
863
|
-
|
|
868
|
+
# Log raw OpenAI response
|
|
869
|
+
logger.info(
|
|
870
|
+
f"[OpenAI Raw Response] {json.dumps(openai_completion, ensure_ascii=False, indent=2)[:2000]}"
|
|
864
871
|
)
|
|
865
872
|
|
|
873
|
+
# Log response details
|
|
874
|
+
if openai_completion.get("choices"):
|
|
875
|
+
choice = openai_completion["choices"][0]
|
|
876
|
+
message = choice.get("message", {})
|
|
877
|
+
finish_reason = choice.get("finish_reason")
|
|
878
|
+
content_preview = (
|
|
879
|
+
message.get("content", "")[:100]
|
|
880
|
+
if message.get("content")
|
|
881
|
+
else ""
|
|
882
|
+
)
|
|
883
|
+
tool_calls_count = (
|
|
884
|
+
len(message.get("tool_calls", []))
|
|
885
|
+
if message.get("tool_calls")
|
|
886
|
+
else 0
|
|
887
|
+
)
|
|
888
|
+
logger.info(
|
|
889
|
+
f"[OpenAI Response Details] finish_reason={finish_reason}, "
|
|
890
|
+
f"content_length={len(message.get('content', ''))}, "
|
|
891
|
+
f"tool_calls={tool_calls_count}, "
|
|
892
|
+
f"content_preview={content_preview[:50]!r}"
|
|
893
|
+
)
|
|
894
|
+
|
|
866
895
|
from openai.types.chat import ChatCompletion
|
|
867
896
|
|
|
868
897
|
completion = ChatCompletion.model_validate(openai_completion)
|
|
869
898
|
anthropic_message = convert_openai_to_anthropic(completion, model)
|
|
870
899
|
|
|
871
900
|
anthropic_response = anthropic_message.model_dump()
|
|
872
|
-
|
|
873
|
-
|
|
901
|
+
# Log converted Anthropic response
|
|
902
|
+
logger.info(
|
|
903
|
+
f"[Anthropic Converted Response] {json.dumps(anthropic_response, ensure_ascii=False, indent=2)[:2000]}"
|
|
874
904
|
)
|
|
875
905
|
|
|
906
|
+
# Log Anthropic response details
|
|
907
|
+
content_blocks = anthropic_response.get("content", [])
|
|
908
|
+
stop_reason = anthropic_response.get("stop_reason")
|
|
909
|
+
usage = anthropic_response.get("usage", {})
|
|
910
|
+
logger.info(
|
|
911
|
+
f"[Anthropic Response Details] stop_reason={stop_reason}, "
|
|
912
|
+
f"content_blocks={len(content_blocks)}, "
|
|
913
|
+
f"input_tokens={usage.get('input_tokens')}, "
|
|
914
|
+
f"output_tokens={usage.get('output_tokens')}"
|
|
915
|
+
)
|
|
916
|
+
|
|
917
|
+
# Log content block types
|
|
918
|
+
if content_blocks:
|
|
919
|
+
block_types = [block.get("type") for block in content_blocks]
|
|
920
|
+
logger.info(f"[Anthropic Content Blocks] types={block_types}")
|
|
921
|
+
|
|
876
922
|
return JSONResponse(content=anthropic_response)
|
|
877
923
|
|
|
878
924
|
except httpx.TimeoutException:
|
|
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.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/__init__.py
RENAMED
|
File without changes
|
{local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/__main__.py
RENAMED
|
File without changes
|
{local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/config.py
RENAMED
|
File without changes
|
|
File without changes
|
{local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/daemon.py
RENAMED
|
File without changes
|
|
File without changes
|
{local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/src/local_openai2anthropic/main.py
RENAMED
|
File without changes
|
|
File without changes
|
{local_openai2anthropic-0.2.9 → local_openai2anthropic-0.3.0}/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
|
|
File without changes
|
|
File without changes
|