abdullahzunorain commited on
Commit
8be5cf4
·
verified ·
1 Parent(s): dd9989c

Create app.py

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