Spaces:
Runtime error
Runtime error
Download app.py from Asyagul1993/Biochatbot: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/spaces/Asyagul1993/Biochatbot/resolve/main/app.py
- Command line
-
hf download hf://spaces/Asyagul1993/Biochatbot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Asyagul1993/Biochatbot/resolve/main/app.py
1.38 kB
| import os | |
| import gradio as gr | |
| # 🔑 SET YOUR GROQ API KEY HERE (IMPORTANT) | |
| os.environ["GROQ_API_KEY"] = "YOUR_GROQ_API_KEY" | |
| client = Groq( | |
| api_key=os.environ["GROQ_API_KEY"] | |
| ) | |
| # 🧬 Bioinformatics AI System Prompt | |
| SYSTEM_PROMPT = """ | |
| You are a professional Bioinformatics AI assistant. | |
| You help users with: | |
| - DNA, RNA, and protein sequence analysis | |
| - Gene function and mutation explanation | |
| - FASTA / FASTQ format understanding | |
| - BLAST and alignment concepts | |
| - Molecular biology and genomics | |
| - Bioinformatics tools and pipelines | |
| Always answer in a simple, clear, and educational way. | |
| """ | |
| # 💬 Chat function | |
| def chat_with_bioai(message, history): | |
| messages = [{"role": "system", "content": SYSTEM_PROMPT}] | |
| for user_msg, bot_msg in history: | |
| messages.append({"role": "user", "content": user_msg}) | |
| messages.append({"role": "assistant", "content": bot_msg}) | |
| messages.append({"role": "user", "content": message}) | |
| response = client.chat.completions.create( | |
| model="llama-3.3-70b-versatile", | |
| messages=messages, | |
| temperature=0.7 | |
| ) | |
| return response.choices[0].message.content | |
| # 🎛️ Gradio Interface | |
| demo = gr.ChatInterface( | |
| fn=chat_with_bioai, | |
| title="🧬 Bioinformatics AI Chatbot", | |
| description="Ask anything about DNA, RNA, proteins, genes, and bioinformatics!" | |
| ) | |
| demo.launch(share=True) |