init
This commit is contained in:
commit
2be8de47fa
87 changed files with 11501 additions and 0 deletions
28
scripts/data_generator/test_api.py
Normal file
28
scripts/data_generator/test_api.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import os
|
||||
from dotenv import load_dotenv
|
||||
from openai import OpenAI
|
||||
import openai
|
||||
|
||||
load_dotenv()
|
||||
|
||||
client = OpenAI(
|
||||
api_key=os.getenv("API_KEY"),
|
||||
base_url=os.getenv("BASE_URL")
|
||||
)
|
||||
|
||||
print(f"DEBUG: BASE_URL='{os.getenv('BASE_URL')}'")
|
||||
print(f"DEBUG: API_KEY='{os.getenv('API_KEY')[:10]}...'")
|
||||
|
||||
try:
|
||||
print("Testing simple 'Hello' prompt...")
|
||||
response = client.chat.completions.create(
|
||||
model=os.getenv("MODEL_NAME"),
|
||||
messages=[{"role": "user", "content": "Hello, are you working?"}],
|
||||
max_tokens=50
|
||||
)
|
||||
print("Success!")
|
||||
print(response.choices[0].message.content)
|
||||
except openai.APIStatusError as e:
|
||||
print(f"Error HTTP {e.status_code}: {e.body}")
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue