AhmedSaghir commited on
Commit
6a70a07
·
verified ·
1 Parent(s): 72bacda

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from groq import Groq
3
+ import os
4
+
5
+ key = os.getenv("groq")
6
+ client = Groq(api_key = key)
7
+
8
+ def chat(message, history):
9
+
10
+ chat_completion = client.chat.completions.create(
11
+
12
+ messages=[
13
+
14
+ {
15
+ "role": "system",
16
+ "content": "you are a helpful assistant."
17
+ },
18
+ # Set a user message for the assistant to respond to.
19
+ {
20
+ "role": "user",
21
+ "content": message,
22
+ }
23
+ ],
24
+
25
+ model="llama3-8b-8192",
26
+
27
+ temperature=0.5,
28
+
29
+ max_tokens=1024,
30
+
31
+ top_p=1,
32
+
33
+ stop=None,
34
+
35
+ stream=False,
36
+ )
37
+
38
+ return chat_completion.choices[0].message.content
39
+
40
+ demo = gr.ChatInterface(fn=chat, title="Groq Chatbot")
41
+ demo.launch(debug= True)