decodingdatascience commited on
Commit
40507eb
·
verified ·
1 Parent(s): 938d8d4

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
+ from groq import Groq
3
+ import gradio as gr
4
+
5
+
6
+ groq_api_key = os.getenv("GROQ_API_KEY")
7
+
8
+
9
+
10
+
11
+ def chat_with_groq(message):
12
+ client = Groq(
13
+ api_key=groq_api_key,
14
+ )
15
+ chat_completion = client.chat.completions.create(
16
+ messages=[
17
+ {
18
+ "role": "user",
19
+ "content": message,
20
+ }
21
+ ],
22
+ model="llama-3.3-70b-versatile", # Using the same model as before
23
+ )
24
+ return chat_completion.choices[0].message.content
25
+
26
+ iface = gr.Interface(fn=chat_with_groq, inputs="textbox", outputs="textbox", title="Groq Chat with Llama 3.3 DDS")
27
+ iface.launch()