Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,6 @@ import os
|
|
| 6 |
import json
|
| 7 |
import logging
|
| 8 |
import re
|
| 9 |
-
import pickle
|
| 10 |
from typing import List, Tuple
|
| 11 |
import gradio as gr
|
| 12 |
from openai import OpenAI
|
|
@@ -315,7 +314,15 @@ def generate_response(question: str, model: str) -> str:
|
|
| 315 |
return "An error occurred processing your request."
|
| 316 |
|
| 317 |
# --- Gradio Interface ---
|
| 318 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
response = generate_response(question, model)
|
| 320 |
return "", history + [(question, response)]
|
| 321 |
|
|
@@ -325,7 +332,7 @@ with gr.Blocks(title="AskNature BioRAG Expert", theme=gr.themes.Soft()) as demo:
|
|
| 325 |
chatbot = gr.Chatbot(label="Dialogue History", height=500)
|
| 326 |
with gr.Row():
|
| 327 |
question = gr.Textbox(placeholder="Ask about biomimicry (e.g. 'How does Werewool use coral proteins to make fibers?')", label="Inquiry", scale=4)
|
| 328 |
-
model_selector = gr.Dropdown(choices=
|
| 329 |
clear_btn = gr.Button("Clear History", variant="secondary")
|
| 330 |
|
| 331 |
gr.Markdown("""
|
|
@@ -338,4 +345,4 @@ with gr.Blocks(title="AskNature BioRAG Expert", theme=gr.themes.Soft()) as demo:
|
|
| 338 |
clear_btn.click(lambda: [], None, chatbot)
|
| 339 |
|
| 340 |
if __name__ == "__main__":
|
| 341 |
-
demo.launch(show_error=True)
|
|
|
|
| 6 |
import json
|
| 7 |
import logging
|
| 8 |
import re
|
|
|
|
| 9 |
from typing import List, Tuple
|
| 10 |
import gradio as gr
|
| 11 |
from openai import OpenAI
|
|
|
|
| 314 |
return "An error occurred processing your request."
|
| 315 |
|
| 316 |
# --- Gradio Interface ---
|
| 317 |
+
# Define the mapping from display names to actual model identifiers
|
| 318 |
+
model_mapping = {
|
| 319 |
+
"Gemini-2.0-Flash": "gemini-2.0-flash",
|
| 320 |
+
"Meta-llama-3-70b-instruct(GWDG)": "meta-llama-3-70b-instruct",
|
| 321 |
+
"llama3-70b-8192(Groq)": "llama3-70b-8192"
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
def chat_interface(question: str, history: List[Tuple[str, str]], display_model: str):
|
| 325 |
+
model = model_mapping.get(display_model, "gemini-2.0-flash") # Default to Gemini if not found
|
| 326 |
response = generate_response(question, model)
|
| 327 |
return "", history + [(question, response)]
|
| 328 |
|
|
|
|
| 332 |
chatbot = gr.Chatbot(label="Dialogue History", height=500)
|
| 333 |
with gr.Row():
|
| 334 |
question = gr.Textbox(placeholder="Ask about biomimicry (e.g. 'How does Werewool use coral proteins to make fibers?')", label="Inquiry", scale=4)
|
| 335 |
+
model_selector = gr.Dropdown(choices=list(model_mapping.keys()), label="Generation Model", value="Gemini-2.0-Flash")
|
| 336 |
clear_btn = gr.Button("Clear History", variant="secondary")
|
| 337 |
|
| 338 |
gr.Markdown("""
|
|
|
|
| 345 |
clear_btn.click(lambda: [], None, chatbot)
|
| 346 |
|
| 347 |
if __name__ == "__main__":
|
| 348 |
+
demo.launch(show_error=True)
|