adriiita commited on
Commit
d9124ae
·
verified ·
1 Parent(s): 3e424fe

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from groq import Groq
4
+
5
+ client = Groq(
6
+ api_key=os.environ.get("GROQ_API_KEY"),
7
+ )
8
+
9
+
10
+ def chat_with_groq(user_input, additional_context=None):
11
+ chat_completion = client.chat.completions.create(
12
+ messages=[
13
+ {
14
+ "role": "user",
15
+ "content": user_input,
16
+ }
17
+ ],
18
+ model="llama-3.1-8b-instant",
19
+ )
20
+ return chat_completion.choices[0].message.content
21
+
22
+
23
+
24
+
25
+ demo = gr.ChatInterface(fn=chat_with_groq, title="Echo Bot", description="This is a chatbot that can chat with you")
26
+ if __name__ == "__main__":
27
+ demo.launch()