Skip to content

Commit 2782c8c

Browse files
authored
Fix/windows compatibility (#1303)
* Update anthropicmsgs.py * Update anthropicmsgs.py * Update anthropicmsgs.py * Update anthropicmsgs.py * Update anthropicmsgs.py
1 parent 13e29a9 commit 2782c8c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/provider/modelmgr/requesters/anthropicmsgs.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import json
55
import traceback
66
import base64
7+
import platform
8+
import socket
79

810
import anthropic
911
import httpx
@@ -23,6 +25,12 @@ class AnthropicMessages(requester.LLMAPIRequester):
2325
client: anthropic.AsyncAnthropic
2426

2527
async def initialize(self):
28+
# 兼容 Windows 缺失 TCP_KEEPINTVL 和 TCP_KEEPCNT 的问题
29+
if platform.system() == "Windows":
30+
if not hasattr(socket, "TCP_KEEPINTVL"):
31+
socket.TCP_KEEPINTVL = 0
32+
if not hasattr(socket, "TCP_KEEPCNT"):
33+
socket.TCP_KEEPCNT = 0
2634

2735
httpx_client = anthropic._base_client.AsyncHttpxClientWrapper(
2836
base_url=self.ap.provider_cfg.data['requester']['anthropic-messages']['base-url'].replace(' ', ''),

0 commit comments

Comments
 (0)