File size: 899 Bytes
7878b06
d892914
ce28ce5
7878b06
d892914
 
7878b06
ce28ce5
7ed9aa3
7878b06
 
 
7ed9aa3
 
7878b06
7ed9aa3
 
 
7878b06
7ed9aa3
7878b06
7ed9aa3
 
d892914
7ed9aa3
7878b06
7ed9aa3
7878b06
7ed9aa3
d892914
 
ce28ce5
7ed9aa3
7878b06
d892914
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import gradio as gr
import os
from groq import Groq

# 🔐 Load API key from HF Secrets
client = Groq(api_key=os.environ["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"])

SYSTEM_PROMPT = """
You are BioinformaticsAI expert in DNA, RNA, proteins, BLAST, FASTA.
"""

def chat(message, history):
    try:
        messages = [{"role": "system", "content": SYSTEM_PROMPT}]

        for u, b in history:
            messages.append({"role": "user", "content": u})
            messages.append({"role": "assistant", "content": b})

        messages.append({"role": "user", "content": message})

        response = client.chat.completions.create(
            model="llama-3.1-70b-versatile",
            messages=messages
        )

        return response.choices[0].message.content

    except Exception as e:
        return f"Error: {str(e)}"


demo = gr.ChatInterface(fn=chat)

demo.launch()