Spaces:
Build error
Build error
Commit
Β·
61ef0a5
1
Parent(s):
0886e95
- app.py +2 -2
- main.ipynb +9 -60
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# Combined Gemini Flash and Meta-LLAMA 3 GWDG and Groq Chatbot
|
| 2 |
# For Gemini Flash rate limit is 15 requests per minute
|
| 3 |
# For Groq rate 30 RPM , 14400 RPD, 6K TPM and 500K TPD
|
| 4 |
-
|
| 5 |
import os
|
| 6 |
import json
|
| 7 |
import logging
|
|
@@ -337,7 +337,7 @@ with gr.Blocks(title="AskNature BioRAG Expert", theme=gr.themes.Soft()) as demo:
|
|
| 337 |
chatbot = gr.Chatbot(label="Dialogue History", height=500)
|
| 338 |
with gr.Row():
|
| 339 |
question = gr.Textbox(placeholder="Ask about biomimicry (e.g. 'How does Werewool use coral proteins to make fibers?')", label="Inquiry", scale=4)
|
| 340 |
-
model_selector = gr.Dropdown(choices=list(model_mapping.keys()), label="Generation Model", value="
|
| 341 |
clear_btn = gr.Button("Clear History", variant="secondary")
|
| 342 |
|
| 343 |
gr.Markdown("""
|
|
|
|
| 1 |
# Combined Gemini Flash and Meta-LLAMA 3 GWDG and Groq Chatbot
|
| 2 |
# For Gemini Flash rate limit is 15 requests per minute
|
| 3 |
# For Groq rate 30 RPM , 14400 RPD, 6K TPM and 500K TPD
|
| 4 |
+
# For GWDG Llama3 60 /min 3000 /h 75000 /day 2000000 /month
|
| 5 |
import os
|
| 6 |
import json
|
| 7 |
import logging
|
|
|
|
| 337 |
chatbot = gr.Chatbot(label="Dialogue History", height=500)
|
| 338 |
with gr.Row():
|
| 339 |
question = gr.Textbox(placeholder="Ask about biomimicry (e.g. 'How does Werewool use coral proteins to make fibers?')", label="Inquiry", scale=4)
|
| 340 |
+
model_selector = gr.Dropdown(choices=list(model_mapping.keys()), label="Generation Model", value="Meta-llama-3-70b-instruct(GWDG)")
|
| 341 |
clear_btn = gr.Button("Clear History", variant="secondary")
|
| 342 |
|
| 343 |
gr.Markdown("""
|
main.ipynb
CHANGED
|
@@ -1211,6 +1211,7 @@
|
|
| 1211 |
"name": "stderr",
|
| 1212 |
"output_type": "stream",
|
| 1213 |
"text": [
|
|
|
|
| 1214 |
"INFO:httpx:HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events \"HTTP/1.1 200 OK\"\n",
|
| 1215 |
"INFO:httpx:HTTP Request: HEAD http://127.0.0.1:7860/ \"HTTP/1.1 200 OK\"\n"
|
| 1216 |
]
|
|
@@ -1239,67 +1240,11 @@
|
|
| 1239 |
"name": "stderr",
|
| 1240 |
"output_type": "stream",
|
| 1241 |
"text": [
|
| 1242 |
-
"INFO:httpx:HTTP Request: GET https://api.gradio.app/pkg-version \"HTTP/1.1 200 OK\"\n",
|
| 1243 |
"INFO:httpx:HTTP Request: POST https://chat-ai.academiccloud.de/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
|
| 1244 |
"Embedding Progress: 0%| | 0/1 [00:00<?, ?it/s]INFO:httpx:HTTP Request: POST https://chat-ai.academiccloud.de/v1/embeddings \"HTTP/1.1 200 OK\"\n",
|
| 1245 |
-
"Embedding Progress: 100%|ββββββββββ| 1/1 [00:00<00:00,
|
| 1246 |
-
"INFO:__main__:Response from gemini-2.0-flash: Hello! I will provide detailed technical insights based on the biomimicry examples you've provided.\n",
|
| 1247 |
-
"\n",
|
| 1248 |
-
"**1. Biodegradable Fibers Inspired by Discosoma Coral**\n",
|
| 1249 |
-
"\n",
|
| 1250 |
-
"The textile industry's significant environmental impact, including high CO2 emissions, wastewater pollution from dyes, and microplastic pollution from synthetic fibers, necessitates sustainable alternatives [1]. **Werewool** addresses this by creating biodegradable fibers inspired by the **protein-based pigmentation** found in Discosoma coral [1].\n",
|
| 1251 |
-
"\n",
|
| 1252 |
-
"* **Technical Details**: Werewool designs fibers at the **DNA level**, utilizing **biotechnology** to imbue them with inherent properties like color. This approach eliminates the need for toxic chemical dyes [1]. The use of **red fluorescent protein** from corals allows for vibrant, sustainable coloration [1].\n",
|
| 1253 |
-
"* **Innovation**: The innovation lies in engineering fibers with tailored aesthetic and performance properties directly at the genetic level, resulting in fully **biodegradable fibers** [1].\n",
|
| 1254 |
-
"* **Sustainability**: Reduces CO2 emissions, eliminates toxic dye usage, and mitigates microplastic pollution [1].\n",
|
| 1255 |
-
"\n",
|
| 1256 |
-
"**2. Impact Resistance Inspired by Pummelo Peel**\n",
|
| 1257 |
-
"\n",
|
| 1258 |
-
"The pummelo fruit exhibits exceptional impact resistance due to the **hierarchical organization** of its peel (**pericarp**) [2].\n",
|
| 1259 |
-
"\n",
|
| 1260 |
-
"* **Technical Details**: The pericarp's structure provides excellent **damping properties**, allowing the fruit to withstand drops from significant heights without damage [2]. The **Young's modulus** and **structural composition** contribute to its ability to absorb and dissipate energy [2].\n",
|
| 1261 |
-
"* **Potential Applications**: The **composite materials** design principles from the pummelo peel can be applied to create impact-resistant materials in various industries, such as protective gear, packaging, and construction [2].\n",
|
| 1262 |
-
"* **Sustainability**: Developing materials based on natural hierarchical structures can lead to more durable and sustainable products, reducing the need for frequent replacements and minimizing waste [2].\n",
|
| 1263 |
-
"\n",
|
| 1264 |
-
"**3. Wind-Powered HVAC Inspired by Leaf-Cutting Ant Nests**\n",
|
| 1265 |
-
"\n",
|
| 1266 |
-
"Leaf-cutter ants construct nest structures with turrets that facilitate **wind-driven ventilation** [3].\n",
|
| 1267 |
-
"\n",
|
| 1268 |
-
"* **Technical Details**: The turret-like structures optimize airflow, enhancing ventilation within the nest. This principle can be applied in **HVAC engineering** to improve energy efficiency in buildings [3].\n",
|
| 1269 |
-
"* **Applications**: Mimicking the ant nest design can enhance ventilation in greenhouses, indoor farms, and buildings, reducing the reliance on fossil fuels for cooling and ventilation [3].\n",
|
| 1270 |
-
"* **Sustainability**: Implementing **biomimicry** in building design reduces energy consumption, lowers costs, and decreases the carbon footprint associated with traditional HVAC systems [3].\n",
|
| 1271 |
-
"\n",
|
| 1272 |
-
"**4. Sound Wave Concentration Inspired by Mammalian Ear-Flaps**\n",
|
| 1273 |
-
"\n",
|
| 1274 |
-
"Mammals' external ear-flaps concentrate sound waves, enhancing hearing [4].\n",
|
| 1275 |
-
"\n",
|
| 1276 |
-
"* **Technical Details**: The **ear-flap anatomy** is designed to efficiently collect and focus sound waves toward the inner ear, improving auditory perception [4].\n",
|
| 1277 |
-
"* **Potential Applications**: This principle can inspire the design of more efficient microphones, hearing aids, and acoustic sensors [4].\n",
|
| 1278 |
-
"* **Innovation**: Enhancing sound capture and directionality through biomimicry could lead to advancements in audio technology and assistive devices [4].\n",
|
| 1279 |
-
"\n",
|
| 1280 |
-
"**5. Coordinated Movements in Starlings: Application to Edible Digital Detox**\n",
|
| 1281 |
-
"\n",
|
| 1282 |
-
"While the provided context discusses macrophage response and immune cell communication inspired by starlings, the application \"edible digital detox\" is not directly supported by the provided text [5]. The information relates more to designing response guidelines for threatening situations by observing how immune cells react dynamically to threats [5].\n",
|
| 1283 |
-
"\n",
|
| 1284 |
-
"* **Technical Details**: Observing how **macrophages** ensure immune systems don't overreact and how immune cells coordinate their efforts can provide insights for managing complex scenarios [5].\n",
|
| 1285 |
-
"* **Potential Applications**: The principles of coordinated response can be applied to emergency evacuation protocols or managing systemic responses in various fields [5].\n",
|
| 1286 |
-
"\n",
|
| 1287 |
-
"**Conclusion**\n",
|
| 1288 |
-
"\n",
|
| 1289 |
-
"Biomimicry offers innovative and sustainable solutions by emulating nature's designs and processes. From biodegradable textiles inspired by coral proteins to energy-efficient ventilation systems based on ant nests, these technologies can significantly reduce environmental impact and improve resource utilization. The key benefits include reduced CO2 emissions, decreased reliance on toxic chemicals, and enhanced energy efficiency.\n",
|
| 1290 |
-
"\n",
|
| 1291 |
-
"**References**\n",
|
| 1292 |
-
"\n",
|
| 1293 |
-
"1. [discosoma coral's protein](https://asknature.org/innovation/colorful-fibers-inspired-by-proteins-found-in-discosoma-coral/)\n",
|
| 1294 |
-
"2. [pummelo peel](https://asknature.org/strategy/hierarchical-organization-of-peel-confers-impact-resistance/)\n",
|
| 1295 |
-
"3. [leaf-cutting ant's nest](https://asknature.org/strategy/turrets-ventilate-nest/)\n",
|
| 1296 |
-
"4. [mammals' external earβflaps](https://asknature.org/strategy/ear-flaps-concentrate-sound-waves/)\n",
|
| 1297 |
-
"5. [starlings](https://asknature.org/strategy/starlings-coordinate-movements-within-a-flock/)\n",
|
| 1298 |
-
"\n",
|
| 1299 |
"INFO:httpx:HTTP Request: POST https://chat-ai.academiccloud.de/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
|
| 1300 |
-
"INFO:__main__:Response from meta-llama-3-70b-instruct: ChatCompletion(id='chat-
|
| 1301 |
-
"INFO:__main__:Groq API Response: {'id': 'chatcmpl-a5a2cc71-464e-4d16-9cd7-74226d93cbbf', 'object': 'chat.completion', 'created': 1739188697, 'model': 'llama3-70b-8192', 'choices': [{'index': 0, 'message': {'role': 'assistant', 'content': \"Hello! It's nice to meet you. Is there something I can help you with, or would you like to chat?\"}, 'logprobs': None, 'finish_reason': 'stop'}], 'usage': {'queue_time': 0.259490815, 'prompt_tokens': 11, 'prompt_time': 0.003311302, 'completion_tokens': 26, 'completion_time': 0.076609847, 'total_tokens': 37, 'total_time': 0.079921149}, 'system_fingerprint': 'fp_753a4aecf6', 'x_groq': {'id': 'req_01jkqvjxpvek4bvzmsq09wkacs'}}\n",
|
| 1302 |
-
"INFO:__main__:Response from llama3-70b-8192: Hello! It's nice to meet you. Is there something I can help you with, or would you like to chat?\n"
|
| 1303 |
]
|
| 1304 |
}
|
| 1305 |
],
|
|
@@ -1307,7 +1252,7 @@
|
|
| 1307 |
"# Combined Gemini Flash and Meta-LLAMA 3 GWDG and Groq Chatbot\n",
|
| 1308 |
"# For Gemini Flash rate limit is 15 requests per minute\n",
|
| 1309 |
"# For Groq rate 30 RPM , 14400 RPD, 6K TPM and 500K TPD\n",
|
| 1310 |
-
"\n",
|
| 1311 |
"import os\n",
|
| 1312 |
"import json\n",
|
| 1313 |
"import logging\n",
|
|
@@ -1568,6 +1513,10 @@
|
|
| 1568 |
" if result is None:\n",
|
| 1569 |
" result = \"Failed to get response from llama3-70b-8192\"\n",
|
| 1570 |
" # Append the model name to the response for clarity\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1571 |
" result += f\"\\n\\n**Model:** {model}\"\n",
|
| 1572 |
" return result\n",
|
| 1573 |
" except Exception as e:\n",
|
|
@@ -1639,7 +1588,7 @@
|
|
| 1639 |
" chatbot = gr.Chatbot(label=\"Dialogue History\", height=500)\n",
|
| 1640 |
" with gr.Row():\n",
|
| 1641 |
" question = gr.Textbox(placeholder=\"Ask about biomimicry (e.g. 'How does Werewool use coral proteins to make fibers?')\", label=\"Inquiry\", scale=4)\n",
|
| 1642 |
-
" model_selector = gr.Dropdown(choices=list(model_mapping.keys()), label=\"Generation Model\", value=\"
|
| 1643 |
" clear_btn = gr.Button(\"Clear History\", variant=\"secondary\")\n",
|
| 1644 |
"\n",
|
| 1645 |
" gr.Markdown(\"\"\"\n",
|
|
|
|
| 1211 |
"name": "stderr",
|
| 1212 |
"output_type": "stream",
|
| 1213 |
"text": [
|
| 1214 |
+
"INFO:httpx:HTTP Request: GET https://api.gradio.app/pkg-version \"HTTP/1.1 200 OK\"\n",
|
| 1215 |
"INFO:httpx:HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events \"HTTP/1.1 200 OK\"\n",
|
| 1216 |
"INFO:httpx:HTTP Request: HEAD http://127.0.0.1:7860/ \"HTTP/1.1 200 OK\"\n"
|
| 1217 |
]
|
|
|
|
| 1240 |
"name": "stderr",
|
| 1241 |
"output_type": "stream",
|
| 1242 |
"text": [
|
|
|
|
| 1243 |
"INFO:httpx:HTTP Request: POST https://chat-ai.academiccloud.de/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
|
| 1244 |
"Embedding Progress: 0%| | 0/1 [00:00<?, ?it/s]INFO:httpx:HTTP Request: POST https://chat-ai.academiccloud.de/v1/embeddings \"HTTP/1.1 200 OK\"\n",
|
| 1245 |
+
"Embedding Progress: 100%|ββββββββββ| 1/1 [00:00<00:00, 4.23it/s]\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1246 |
"INFO:httpx:HTTP Request: POST https://chat-ai.academiccloud.de/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
|
| 1247 |
+
"INFO:__main__:Response from meta-llama-3-70b-instruct: ChatCompletion(id='chat-86b881962781487d8d9067b08011c115', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content=\"Hello. I'm excited to explore the fascinating realm of biomimicry with you. Biomimicry is an interdisciplinary field that involves the study of nature and its processes to develop innovative solutions for human challenges. By emulating the strategies and mechanisms employed by living organisms, we can create more sustainable, efficient, and effective technologies.\\n\\nIn the context of the provided sources, we can see how nature has evolved remarkable solutions to various problems. For instance, the Discosoma coral's protein-based pigmentation [1] has inspired the development of biodegradable fibers with tailored aesthetic and performance properties. This innovation has the potential to revolutionize the textile industry, which is currently responsible for significant environmental impacts, including greenhouse gas emissions and microplastic pollution.\\n\\nAnother example is the pummelo peel's hierarchical organization [2], which confers impact resistance due to its unique structural composition. This natural material has excellent damping properties, making it an attractive model for the development of composite materials with enhanced mechanical properties.\\n\\nThe concept of geometric laws and allometry [3] is also relevant to biomimicry, as it highlights the importance of scaling theory in understanding the relationships between an organism's size and its physical properties. This knowledge can be applied to the design of more efficient and sustainable systems.\\n\\nFurthermore, the anatomy of mammals' external ear-flaps [4] has evolved to concentrate sound waves, allowing for more effective hearing. This natural design can inspire the development of novel sound collection and concentration technologies.\\n\\nLastly, the behavior of starlings [5] has been studied in the context of immune cell communication and response scaling. This research can inform the design of response guidelines for various threatening situations, such as emergency evacuations.\\n\\nIn conclusion, biomimicry offers a wealth of opportunities for innovation and sustainability. By studying nature's strategies and mechanisms, we can develop more efficient, effective, and environmentally friendly solutions to various human challenges.\\n\\nReferences:\\n\\n[1] https://asknature.org/innovation/colorful-fibers-inspired-by-proteins-found-in-discosoma-coral/\\n[2] https://asknature.org/strategy/hierarchical-organization-of-peel-confers-impact-resistance/\\n[3] https://asknature.org/strategy/environment-tailors-growth/\\n[4] https://asknature.org/strategy/ear-flaps-concentrate-sound-waves/\\n[5] https://asknature.org/strategy/starlings-coordinate-movements-within-a-flock/\", refusal=None, role='assistant', audio=None, function_call=None, tool_calls=[]), stop_reason=None)], created=1739304894, model='meta-llama-3.1-70b-instruct', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=503, prompt_tokens=1036, total_tokens=1539, completion_tokens_details=None, prompt_tokens_details=None), prompt_logprobs=None)\n"
|
|
|
|
|
|
|
| 1248 |
]
|
| 1249 |
}
|
| 1250 |
],
|
|
|
|
| 1252 |
"# Combined Gemini Flash and Meta-LLAMA 3 GWDG and Groq Chatbot\n",
|
| 1253 |
"# For Gemini Flash rate limit is 15 requests per minute\n",
|
| 1254 |
"# For Groq rate 30 RPM , 14400 RPD, 6K TPM and 500K TPD\n",
|
| 1255 |
+
"# For GWDG Llama3 60 /min 3000 /h 75000 /day 2000000 /month\n",
|
| 1256 |
"import os\n",
|
| 1257 |
"import json\n",
|
| 1258 |
"import logging\n",
|
|
|
|
| 1513 |
" if result is None:\n",
|
| 1514 |
" result = \"Failed to get response from llama3-70b-8192\"\n",
|
| 1515 |
" # Append the model name to the response for clarity\n",
|
| 1516 |
+
" # get the key name model from model mapping\n",
|
| 1517 |
+
" for key, value in model_mapping.items():\n",
|
| 1518 |
+
" if value == model:\n",
|
| 1519 |
+
" model = key\n",
|
| 1520 |
" result += f\"\\n\\n**Model:** {model}\"\n",
|
| 1521 |
" return result\n",
|
| 1522 |
" except Exception as e:\n",
|
|
|
|
| 1588 |
" chatbot = gr.Chatbot(label=\"Dialogue History\", height=500)\n",
|
| 1589 |
" with gr.Row():\n",
|
| 1590 |
" question = gr.Textbox(placeholder=\"Ask about biomimicry (e.g. 'How does Werewool use coral proteins to make fibers?')\", label=\"Inquiry\", scale=4)\n",
|
| 1591 |
+
" model_selector = gr.Dropdown(choices=list(model_mapping.keys()), label=\"Generation Model\", value=\"Meta-llama-3-70b-instruct(GWDG)\")\n",
|
| 1592 |
" clear_btn = gr.Button(\"Clear History\", variant=\"secondary\")\n",
|
| 1593 |
"\n",
|
| 1594 |
" gr.Markdown(\"\"\"\n",
|