Spaces:
Sleeping
Sleeping
Download app.py from Asyagul1993/Bioinforms: direct link, hf CLI and curl.
- Browser
- Download file 1.67 kB
-
https://huggingface.co/spaces/Asyagul1993/Bioinforms/resolve/main/app.py
- Command line
-
hf download hf://spaces/Asyagul1993/Bioinforms/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Asyagul1993/Bioinforms/resolve/main/app.py
1.67 kB
| # ========================= | |
| # 𧬠BIOINFORMATICS CHATBOT (GROQ + GRADIO) | |
| # ========================= | |
| import os | |
| import gradio as gr | |
| from groq import Groq | |
| # ========================= | |
| # π SET YOUR GROQ API KEY | |
| # ========================= | |
| os.environ["GROQ_API_KEY"] = "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" | |
| client = Groq( | |
| api_key=os.environ.get("GROQ_API_KEY") | |
| ) | |
| # ========================= | |
| # π§ SYSTEM PROMPT | |
| # ========================= | |
| SYSTEM_PROMPT = """ | |
| You are a professional Bioinformatics AI assistant. | |
| You help users with: | |
| - DNA, RNA, protein sequences | |
| - Gene mutation analysis | |
| - FASTA/FASTQ formats | |
| - BLAST explanation | |
| - Genomics and proteomics | |
| Always explain in simple, clear, and accurate way. | |
| """ | |
| # ========================= | |
| # π€ CHAT FUNCTION | |
| # ========================= | |
| def chat(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 UI | |
| # ========================= | |
| demo = gr.ChatInterface( | |
| fn=chat, | |
| title="𧬠Bioinformatics AI Chatbot", | |
| description="Ask about DNA, RNA, genes, proteins, mutations, FASTA, BLAST etc." | |
| ) | |
| # ========================= | |
| # π RUN APP | |
| # ========================= | |
| demo.launch(share=True) |