net2asif commited on
Commit
b728c4e
·
verified ·
1 Parent(s): ad9ee97

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +41 -0
main.py CHANGED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
7
+ def chat(message, history):
8
+
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="AGroq-Ai-Chabot")
41
+ demo.launch(debug= True)