Spaces:
Runtime error
Runtime error
Download app.py from Asyagul1993/BioAI: direct link, hf CLI and curl.
- Browser
- Download file 899 Bytes
-
https://huggingface.co/spaces/Asyagul1993/BioAI/resolve/main/app.py
- Command line
-
hf download hf://spaces/Asyagul1993/BioAI/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Asyagul1993/BioAI/resolve/main/app.py
899 Bytes
| 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() |