geeksiddhant commited on
Commit
f8ffc7f
1 Parent(s): 419bde3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ def chat_with_groq(user_input, additional_info=None):
10
+ chat_completion = client.chat.completions.create(
11
+ messages=[
12
+ {
13
+ "role": "user",
14
+ "content": user_input,
15
+ }
16
+ ],
17
+ model="llama-3.1-8b-instant",
18
+ )
19
+ return chat_completion.choices[0].message.content
20
+
21
+
22
+ # add the UI
23
+ iface = gr.ChatInterface(
24
+ fn=chat_with_groq,
25
+ title="Groq Chatbot",
26
+ description="Ask anything to the Groq-powered chatbot."
27
+ )
28
+
29
+ if __name__ == "__main__":
30
+ iface.launch(share=True)