Files
iov_data_analysis_agent/test.py

23 lines
484 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
"""
快速测试 LLM 连接是否正常
"""
import os
from dotenv import load_dotenv
2026-01-31 18:00:05 +08:00
from openai import OpenAI
2026-01-09 16:52:45 +08:00
load_dotenv()
2026-01-31 18:00:05 +08:00
client = OpenAI(
base_url=os.getenv("OPENAI_BASE_URL", "http://127.0.0.1:9999/v1"),
api_key=os.getenv("OPENAI_API_KEY", ""),
2026-01-09 16:52:45 +08:00
)
response = client.chat.completions.create(
model=os.getenv("OPENAI_MODEL", "gpt-3.5-turbo"),
messages=[{"role": "user", "content": "Hello"}],
2026-01-09 16:52:45 +08:00
)
2026-01-31 18:00:05 +08:00
print(response.choices[0].message.content)