net2asif commited on
Commit
86073a0
·
verified ·
1 Parent(s): a9153e3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from groq import Groq
3
+ import os
4
+ groq_api=os.getenv("groq_api_key")
5
+ client = Groq(api_key = groq_api)
6
+ def chat(message, history):
7
+
8
+
9
+ chat_completion = client.chat.completions.create(
10
+ #
11
+ # Required parameters
12
+ #
13
+ messages=[
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
+ # The language model which will generate the completion.
26
+ model="llama3-8b-8192",
27
+ temperature=0.5,
28
+
29
+ max_tokens=1024,
30
+
31
+ top_p=1,
32
+
33
+ stop=None,
34
+ stream=False,
35
+ )
36
+
37
+ return chat_completion.choices[0].message.content
38
+
39
+ demo = gr.ChatInterface(fn=chat, title="AGroq-Ai-Chabot")
40
+ demo.launch(debug= True)