Asyagul1993 commited on
Commit
d0caaea
·
verified ·
1 Parent(s): 055dd7c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -0
app.py CHANGED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from groq import Groq
3
+
4
+ # 🔑 Add your Groq API key here
5
+ client = Groq(api_key="YOUR_GROQ_API_KEY")
6
+
7
+ # 🧬 System prompt for Bioinformatics expert AI
8
+ SYSTEM_PROMPT = """
9
+ You are a professional Bioinformatics AI assistant.
10
+
11
+ You help with:
12
+ - DNA, RNA, and protein sequences
13
+ - Gene function and mutation analysis
14
+ - BLAST explanation
15
+ - FASTA format understanding
16
+ - Molecular biology concepts
17
+ - Genomics, proteomics, and computational biology
18
+
19
+ Explain answers in simple, clear, and student-friendly language.
20
+ Always give examples when possible.
21
+ """
22
+
23
+ def bio_chatbot(message, history):
24
+ messages = [{"role": "system", "content": SYSTEM_PROMPT}]
25
+
26
+ # Add previous chat history
27
+ for user, bot in history:
28
+ messages.append({"role": "user", "content": user})
29
+ messages.append({"role": "assistant", "content": bot})
30
+
31
+ # Add new user message
32
+ messages.append({"role": "user", "content": message})
33
+
34
+ # Call Groq API
35
+ chat_completion = client.chat.completions.create(
36
+ messages=messages,
37
+ model="llama-3.3-70b-versatile",
38
+ )
39
+
40
+ return chat_completion.choices[0].message.content
41
+
42
+
43
+ # 🎨 Gradio UI
44
+ demo = gr.ChatInterface(
45
+ fn=bio_chatbot,
46
+ title="🧬 Bioinformatics AI Chatbot",
47
+ description="Ask anything about DNA, RNA, genes, proteins, BLAST, FASTA, and bioinformatics!",
48
+ )
49
+
50
+ # 🚀 Launch app
51
+ demo.launch(share=True)
52
+ !pip install groq gradio