Spaces:
Running
Running
mrbeliever
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ from openai import OpenAI
|
|
5 |
# Initialize the Nebius OpenAI client
|
6 |
client = OpenAI(
|
7 |
base_url="https://api.studio.nebius.ai/v1/",
|
8 |
-
api_key=os.getenv("
|
9 |
)
|
10 |
|
11 |
# Function to process input and return the response
|
@@ -23,9 +23,12 @@ def analyze_image(image_url):
|
|
23 |
max_tokens=300,
|
24 |
)
|
25 |
|
26 |
-
# Extract
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
29 |
except Exception as e:
|
30 |
return f"Error: {str(e)}"
|
31 |
|
|
|
5 |
# Initialize the Nebius OpenAI client
|
6 |
client = OpenAI(
|
7 |
base_url="https://api.studio.nebius.ai/v1/",
|
8 |
+
api_key=os.getenv("NEBIUS_API_KEY"), # Use the environment variable
|
9 |
)
|
10 |
|
11 |
# Function to process input and return the response
|
|
|
23 |
max_tokens=300,
|
24 |
)
|
25 |
|
26 |
+
# Extract the AI response
|
27 |
+
if response.choices and "message" in response.choices[0]:
|
28 |
+
return response.choices[0]["message"]["content"]
|
29 |
+
else:
|
30 |
+
return "No valid response received from the API."
|
31 |
+
|
32 |
except Exception as e:
|
33 |
return f"Error: {str(e)}"
|
34 |
|