Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -52,7 +52,6 @@ And ARKA? He is simply the reminder.
|
|
| 52 |
That even in the dark, we are made to glow.
|
| 53 |
"""
|
| 54 |
|
| 55 |
-
# Hardcoded FAQs (remains the same)
|
| 56 |
# Hardcoded FAQs
|
| 57 |
FAQ_ANSWERS = {
|
| 58 |
"What is SAB-EK?": {
|
|
@@ -478,8 +477,8 @@ That is the moment it becomes real."""
|
|
| 478 |
|
| 479 |
FAQ_QUESTIONS = list(FAQ_ANSWERS.keys())
|
| 480 |
|
| 481 |
-
#
|
| 482 |
-
API_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/models/gemini-
|
| 483 |
|
| 484 |
# --- NEW: FAQ Matcher Class using Sentence Transformers ---
|
| 485 |
class FAQMatcher:
|
|
@@ -533,7 +532,6 @@ faq_matcher = FAQMatcher(FAQ_QUESTIONS)
|
|
| 533 |
def query_gemini_api(contents_payload, api_key):
|
| 534 |
"""
|
| 535 |
Sends a structured contents payload to the Gemini API and returns the generated text.
|
| 536 |
-
(This function remains largely the same)
|
| 537 |
"""
|
| 538 |
if not api_key:
|
| 539 |
return "Error: GEMINI_API_KEY is not set. Please set it in your environment."
|
|
@@ -602,9 +600,6 @@ def respond_as_arka(message, chat_history):
|
|
| 602 |
|
| 603 |
# Prepare conversation history
|
| 604 |
gemini_chat_contents = [
|
| 605 |
-
# Note: The new Gemini API prefers the system instruction outside the 'contents' list.
|
| 606 |
-
# However, for compatibility with the older model/API structure, we keep it here.
|
| 607 |
-
# A more modern approach would use a 'system_instruction' key at the top level of the payload.
|
| 608 |
{"role": "user", "parts": [{"text": system_instruction}]},
|
| 609 |
{"role": "model", "parts": [{"text": "I understand. I am ARKA. I await the seeker's question."}]}
|
| 610 |
]
|
|
|
|
| 52 |
That even in the dark, we are made to glow.
|
| 53 |
"""
|
| 54 |
|
|
|
|
| 55 |
# Hardcoded FAQs
|
| 56 |
FAQ_ANSWERS = {
|
| 57 |
"What is SAB-EK?": {
|
|
|
|
| 477 |
|
| 478 |
FAQ_QUESTIONS = list(FAQ_ANSWERS.keys())
|
| 479 |
|
| 480 |
+
# --- FIX: Corrected the Gemini API model name in the URL ---
|
| 481 |
+
API_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent"
|
| 482 |
|
| 483 |
# --- NEW: FAQ Matcher Class using Sentence Transformers ---
|
| 484 |
class FAQMatcher:
|
|
|
|
| 532 |
def query_gemini_api(contents_payload, api_key):
|
| 533 |
"""
|
| 534 |
Sends a structured contents payload to the Gemini API and returns the generated text.
|
|
|
|
| 535 |
"""
|
| 536 |
if not api_key:
|
| 537 |
return "Error: GEMINI_API_KEY is not set. Please set it in your environment."
|
|
|
|
| 600 |
|
| 601 |
# Prepare conversation history
|
| 602 |
gemini_chat_contents = [
|
|
|
|
|
|
|
|
|
|
| 603 |
{"role": "user", "parts": [{"text": system_instruction}]},
|
| 604 |
{"role": "model", "parts": [{"text": "I understand. I am ARKA. I await the seeker's question."}]}
|
| 605 |
]
|