Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,7 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 13 |
class BasicAgent:
|
| 14 |
def __init__(self):
|
| 15 |
-
|
| 16 |
if not self.api_key:
|
| 17 |
raise ValueError("❌ GEMINI_API_KEY не найден в переменных окружения.")
|
| 18 |
self.api_url = "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent"
|
|
@@ -40,7 +40,6 @@ class BasicAgent:
|
|
| 40 |
response = requests.post(self.api_url, headers=headers, json=payload, timeout=20)
|
| 41 |
response.raise_for_status()
|
| 42 |
result = response.json()
|
| 43 |
-
# Получение текста ответа
|
| 44 |
reply = result["candidates"][0]["content"]["parts"][0]["text"]
|
| 45 |
print(f"✅ Ответ: {reply[:50]}...")
|
| 46 |
return reply
|
|
|
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 13 |
class BasicAgent:
|
| 14 |
def __init__(self):
|
| 15 |
+
self.api_key = os.getenv("GEMINI_API_KEY")
|
| 16 |
if not self.api_key:
|
| 17 |
raise ValueError("❌ GEMINI_API_KEY не найден в переменных окружения.")
|
| 18 |
self.api_url = "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent"
|
|
|
|
| 40 |
response = requests.post(self.api_url, headers=headers, json=payload, timeout=20)
|
| 41 |
response.raise_for_status()
|
| 42 |
result = response.json()
|
|
|
|
| 43 |
reply = result["candidates"][0]["content"]["parts"][0]["text"]
|
| 44 |
print(f"✅ Ответ: {reply[:50]}...")
|
| 45 |
return reply
|