Spaces:
Build error
Build error
Commit
·
0886e95
1
Parent(s):
42ec7c7
app.py
CHANGED
|
@@ -262,6 +262,10 @@ def get_ai_response(query: str, context: str, model: str) -> str:
|
|
| 262 |
if result is None:
|
| 263 |
result = "Failed to get response from llama3-70b-8192"
|
| 264 |
# Append the model name to the response for clarity
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
result += f"\n\n**Model:** {model}"
|
| 266 |
return result
|
| 267 |
except Exception as e:
|
|
@@ -302,7 +306,6 @@ def get_groq_llama3_response(query: str) -> str:
|
|
| 302 |
except requests.exceptions.RequestException as e:
|
| 303 |
logger.error(f"Groq API Error: {str(e)}")
|
| 304 |
return "An error occurred while contacting Groq's Llama 3 model."
|
| 305 |
-
|
| 306 |
# --- Pipeline ---
|
| 307 |
documents = load_and_chunk_data(data_file_name)
|
| 308 |
retriever = EnhancedRetriever(documents)
|
|
@@ -327,6 +330,7 @@ def chat_interface(question: str, history: List[Tuple[str, str]], display_model:
|
|
| 327 |
model = model_mapping.get(display_model, "gemini-2.0-flash") # Default to Gemini if not found
|
| 328 |
response = generate_response(question, model)
|
| 329 |
return "", history + [(question, response)]
|
|
|
|
| 330 |
with gr.Blocks(title="AskNature BioRAG Expert", theme=gr.themes.Soft()) as demo:
|
| 331 |
gr.Markdown("# 🌿 AskNature RAG-based Chatbot")
|
| 332 |
with gr.Row():
|
|
|
|
| 262 |
if result is None:
|
| 263 |
result = "Failed to get response from llama3-70b-8192"
|
| 264 |
# Append the model name to the response for clarity
|
| 265 |
+
# get the key name model from model mapping
|
| 266 |
+
for key, value in model_mapping.items():
|
| 267 |
+
if value == model:
|
| 268 |
+
model = key
|
| 269 |
result += f"\n\n**Model:** {model}"
|
| 270 |
return result
|
| 271 |
except Exception as e:
|
|
|
|
| 306 |
except requests.exceptions.RequestException as e:
|
| 307 |
logger.error(f"Groq API Error: {str(e)}")
|
| 308 |
return "An error occurred while contacting Groq's Llama 3 model."
|
|
|
|
| 309 |
# --- Pipeline ---
|
| 310 |
documents = load_and_chunk_data(data_file_name)
|
| 311 |
retriever = EnhancedRetriever(documents)
|
|
|
|
| 330 |
model = model_mapping.get(display_model, "gemini-2.0-flash") # Default to Gemini if not found
|
| 331 |
response = generate_response(question, model)
|
| 332 |
return "", history + [(question, response)]
|
| 333 |
+
|
| 334 |
with gr.Blocks(title="AskNature BioRAG Expert", theme=gr.themes.Soft()) as demo:
|
| 335 |
gr.Markdown("# 🌿 AskNature RAG-based Chatbot")
|
| 336 |
with gr.Row():
|