Skip to content
Snippets Groups Projects
Commit 124f516f authored by Jan Frenzel's avatar Jan Frenzel
Browse files

Let base example fail if file my_key is missing


Co-authored-by: default avatarAndrei Politov <andrei.politov@tu-dresden.de>
parent d2f3f678
No related branches found
No related tags found
1 merge request!1Base example
......@@ -2,8 +2,13 @@
# Find instructions how to install dependencies and how to run this script in README.md
from openai import OpenAI
my_api_key = ""
with open("my_key") as keyfile:
my_api_key = keyfile.readline()[:-1]
try:
with open("my_key") as keyfile:
my_api_key = keyfile.readline().strip()
except FileNotFoundError:
print("Error: The file 'my_key' was not found. Please make sure the file exists and contains your API key.")
exit(1)
client = OpenAI(base_url="https://llm.scads.ai/v1",api_key=my_api_key)
# Get models
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment