forked from mishl-dev/Discord-AI-Chatbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
27 lines (25 loc) · 809 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
from openai import Client
from dotenv import load_dotenv
from bot_utilities.config_loader import config
load_dotenv()
client = Client(
base_url=config['API_BASE_URL'],
api_key=os.environ.get("API_KEY"),
)
models = client.models.list()
for model in models.data:
if model.active:
try:
response = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Say this is a test",
}
],
model=model.id
)
print(f"{model.id} responded with : {response.choices[0].message.content}\n\n")
except Exception:
print(f'{model.id} failed : {response}\n\n')