mathpal123 commited on
Commit
4f6ebb0
·
verified ·
1 Parent(s): 0b92a85

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_API_KEY')
6
+ client = Groq(api_key = key)
7
+
8
+ def chat(message, history):
9
+
10
+ chat_completion = client.chat.completions.create(
11
+ #
12
+ # Required parameters
13
+ #
14
+ messages=[
15
+ {
16
+ "role": "system",
17
+ "content": "you are a helpful assistant."
18
+ },
19
+ # Set a user message for the assistant to respond to.
20
+ {
21
+ "role": "user",
22
+ "content": message,
23
+ }
24
+ ],
25
+
26
+ # The language model which will generate the completion.
27
+ model = "llama3-8b-8192",
28
+ temperature = 0.5,
29
+
30
+ max_tokens = 1024,
31
+
32
+ top_p = 1,
33
+
34
+ stop = None,
35
+ stream = False,
36
+ )
37
+
38
+ return chat_completion.choices[0].message.content
39
+
40
+ demo = gr.ChatInterface(fn=chat, title="Open Source chatbot")
41
+ demo.launch(debug=True)