fix: chatAI代理配置错误,服务器报错500

pull/12369/head
feng 2023-12-19 15:39:22 +08:00
parent 1335556272
commit 59d9a3d4ec
1 changed files with 10 additions and 9 deletions

View File

@ -47,16 +47,17 @@ class ChatAITestingAPI(GenericAPIView):
'base_url': config['GPT_BASE_URL'] or None,
'api_key': config['GPT_API_KEY'],
}
if proxy:
kwargs['http_client'] = httpx.Client(
proxies=proxy,
transport=httpx.HTTPTransport(local_address='0.0.0.0')
)
client = openai.OpenAI(**kwargs)
ok = False
error = ''
try:
if proxy:
kwargs['http_client'] = httpx.Client(
proxies=proxy,
transport=httpx.HTTPTransport(local_address='0.0.0.0')
)
client = openai.OpenAI(**kwargs)
ok = False
error = ''
client.chat.completions.create(
messages=[
{