Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,12 +12,15 @@ from langchain_community.vectorstores import FAISS
|
|
| 12 |
from langchain_core.embeddings import Embeddings
|
| 13 |
from langchain_core.documents import Document
|
| 14 |
from collections import defaultdict
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
embedding_model = "e5-mistral-7b-instruct"
|
| 17 |
generation_model = "meta-llama-3-70b-instruct"
|
| 18 |
# --- Configuration ---
|
| 19 |
API_CONFIG = {
|
| 20 |
-
"api_key": "
|
| 21 |
"base_url": "https://chat-ai.academiccloud.de/v1"
|
| 22 |
}
|
| 23 |
CHUNK_SIZE = 800
|
|
@@ -194,14 +197,31 @@ def chat_interface(question: str, history: List[Tuple[str, str]]):
|
|
| 194 |
response = generate_response(question)
|
| 195 |
return "", history + [(question, response)]
|
| 196 |
|
| 197 |
-
with gr.Blocks(title="
|
| 198 |
-
gr.Markdown("
|
|
|
|
|
|
|
| 199 |
with gr.Row():
|
| 200 |
-
chatbot = gr.Chatbot(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
with gr.Row():
|
| 202 |
-
question = gr.Textbox(
|
| 203 |
-
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
|
| 206 |
question.submit(chat_interface, [question, chatbot], [question, chatbot])
|
| 207 |
clear_btn.click(lambda: [], None, chatbot)
|
|
|
|
| 12 |
from langchain_core.embeddings import Embeddings
|
| 13 |
from langchain_core.documents import Document
|
| 14 |
from collections import defaultdict
|
| 15 |
+
import os
|
| 16 |
+
|
| 17 |
+
|
| 18 |
|
| 19 |
embedding_model = "e5-mistral-7b-instruct"
|
| 20 |
generation_model = "meta-llama-3-70b-instruct"
|
| 21 |
# --- Configuration ---
|
| 22 |
API_CONFIG = {
|
| 23 |
+
"api_key": os.getenv("API_KEY"),
|
| 24 |
"base_url": "https://chat-ai.academiccloud.de/v1"
|
| 25 |
}
|
| 26 |
CHUNK_SIZE = 800
|
|
|
|
| 197 |
response = generate_response(question)
|
| 198 |
return "", history + [(question, response)]
|
| 199 |
|
| 200 |
+
with gr.Blocks(title="AskNature BioStrategy Interface", theme=gr.themes.Soft()) as demo:
|
| 201 |
+
gr.Markdown("""
|
| 202 |
+
# 🍃 AskNature BioDialogue """)
|
| 203 |
+
|
| 204 |
with gr.Row():
|
| 205 |
+
chatbot = gr.Chatbot(
|
| 206 |
+
label="Organism Strategy Dialogue",
|
| 207 |
+
height=500,
|
| 208 |
+
bubble_full_width=False,
|
| 209 |
+
avatar_images=("🧬", "🌐") # DNA + Earth icons
|
| 210 |
+
)
|
| 211 |
+
|
| 212 |
with gr.Row():
|
| 213 |
+
question = gr.Textbox(
|
| 214 |
+
placeholder="Explore biological strategiess (e.g., 'How are TISSIUM polymers inspired by skin and used in medicine?')...",
|
| 215 |
+
label="Biological Inquiry",
|
| 216 |
+
scale=4
|
| 217 |
+
)
|
| 218 |
+
clear_btn = gr.Button("🌱 New Exploration Thread", variant="secondary")
|
| 219 |
+
|
| 220 |
+
gr.Markdown("""
|
| 221 |
+
<div style="text-align: center; color: #4a7c59;">
|
| 222 |
+
<small>Powered by AskNature's Database |
|
| 223 |
+
Explore nature's blueprints at <a href="https://asknature.org">asknature.org</a></small>
|
| 224 |
+
</div>""")
|
| 225 |
|
| 226 |
question.submit(chat_interface, [question, chatbot], [question, chatbot])
|
| 227 |
clear_btn.click(lambda: [], None, chatbot)
|