mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-08 14:56:03 +00:00
perf: 完善openai异常处理
This commit is contained in:
25
tests/models_api_compability/compability.py
Normal file
25
tests/models_api_compability/compability.py
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
import os
|
||||
|
||||
import openai
|
||||
|
||||
client = openai.Client(
|
||||
api_key=os.environ["OPENAI_API_KEY"],
|
||||
)
|
||||
|
||||
openai.proxies = {
|
||||
'http': 'http://127.0.0.1:7890',
|
||||
'https': 'http://127.0.0.1:7890',
|
||||
}
|
||||
|
||||
resp = client.chat.completions.create(
|
||||
model="code-davinci-002",
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hello, how are you?",
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
print(resp)
|
||||
Reference in New Issue
Block a user