File size: 587 Bytes
d9124ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ae0f633
d9124ae
 
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
import os
import gradio as gr
from groq import Groq

client = Groq(
    api_key=os.environ.get("GROQ_API_KEY"),
)


def chat_with_groq(user_input, additional_context=None):
    chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": user_input,
        }
    ],
    model="llama-3.1-8b-instant",
)
    return chat_completion.choices[0].message.content




demo = gr.ChatInterface(fn=chat_with_groq, title="Echo Bot", description="This is a chatbot that can chat with you")
if __name__ == "__main__":
    demo.launch()