# ========================= # 🧬 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)