Pasula commited on
Commit
df22e93
·
verified ·
1 Parent(s): a901bff

Create app.py file

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ from groq import Groq # Ensure Groq library supports this usage
4
+ from dotenv import load_dotenv
5
+
6
+ load_dotenv()
7
+
8
+ os.getenv("GROQ_API_KEY")
9
+ def fetch_response(user_input):
10
+ client = Groq(api_key=os.getenv("GROQ_API_KEY"))
11
+ chat_completion = client.chat.completions.create(
12
+ messages=[
13
+ {"role": "system", "content": "you are a helpful assistant. Take the input from the users and try to provide as detailed response as possible. Provide proper expamples to help the user. Try to mention references or provide citations to make it more detail oriented."},
14
+ {"role": "user", "content": user_input},
15
+ ],
16
+ model="mixtral-8x7b-32768",
17
+ temperature=0.5,
18
+ max_tokens=1024,
19
+ top_p=1,
20
+ stop=None,
21
+ stream=False
22
+ )
23
+ return chat_completion.choices[0].message.content
24
+
25
+ iface = gr.Interface(fn=fetch_response, inputs="text", outputs="text", title="Fastest AI Chatbot By Klizos", description="Ask a question and get a response.")
26
+ iface.launch()