mirror of https://github.com/jumpserver/jumpserver
Merge pull request #12369 from jumpserver/pr@dev@chat_ai_test
fix: chatAI代理配置错误,服务器报错500pull/12371/head
commit
2b41486f2a
|
@ -47,16 +47,17 @@ class ChatAITestingAPI(GenericAPIView):
|
||||||
'base_url': config['GPT_BASE_URL'] or None,
|
'base_url': config['GPT_BASE_URL'] or None,
|
||||||
'api_key': config['GPT_API_KEY'],
|
'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:
|
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(
|
client.chat.completions.create(
|
||||||
messages=[
|
messages=[
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue