GovindRoy commited on
Commit
fc93611
·
verified ·
1 Parent(s): 8d12687

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+
4
+ from groq import Groq
5
+
6
+ # Initialize the Groq client
7
+ client = Groq(
8
+ api_key=os.environ.get("GROQ_API_KEY"),
9
+ )
10
+
11
+ ## backend
12
+ def random_response(message, history):
13
+ ##LLM
14
+ chat_completion = client.chat.completions.create(
15
+ messages=[
16
+ {
17
+ "role": "user",
18
+ "content": message,
19
+ }
20
+ ],
21
+ model="meta-llama/llama-4-maverick-17b-128e-instruct",
22
+ )
23
+ return chat_completion.choices[0].message.content
24
+
25
+
26
+ #frontend
27
+ print("Starting Gradio application...")
28
+ demo = gr.ChatInterface(random_response, type="messages", autofocus=False)
29
+
30
+ if __name__ == "__main__":
31
+ print("Launching Gradio interface...")
32
+ demo.launch(share=True)
33
+
34
+
35
+
36
+
37
+
38
+