-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_test_model.py
More file actions
34 lines (30 loc) · 913 Bytes
/
_test_model.py
File metadata and controls
34 lines (30 loc) · 913 Bytes
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
28
29
30
31
32
33
34
"""Quick test: which model works with JSON structured output?"""
import os
import sys
import json
from openai import OpenAI
from dotenv import load_dotenv
sys.stdout.reconfigure(encoding='utf-8')
load_dotenv()
client = OpenAI(
base_url="https://integrate.api.nvidia.com/v1",
api_key=os.getenv("NVIDIA_API_KEY"),
)
MODELS_TO_TEST = [
"mistralai/mistral-nemotron",
"nv-mistralai/mistral-nemo-12b-instruct",
"z-ai/glm4.7",
]
for model in MODELS_TO_TEST:
print(f"\nTesting: {model}")
try:
r = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": 'Respond with JSON: {"greeting": "hello"}'}],
response_format={"type": "json_object"},
max_tokens=50,
temperature=0.1,
)
print(f" OK: {r.choices[0].message.content}")
except Exception as e:
print(f" FAIL: {e}")