gpt-eng / docs /examples /open_llms /openai_api_interface.py
kakumusic's picture
Upload folder using huggingface_hub
e7c3249 verified
raw
history blame contribute delete
No virus
481 Bytes
import os
from openai import OpenAI
client = OpenAI(
base_url=os.getenv("OPENAI_API_BASE"), api_key=os.getenv("OPENAI_API_KEY")
)
response = client.chat.completions.create(
model=os.getenv("MODEL_NAME"),
messages=[
{
"role": "user",
"content": "Provide me with only the code for a simple python function that sums two numbers.",
},
],
temperature=0.7,
max_tokens=200,
)
print(response.choices[0].message.content)