geeksiddhant commited on
Commit
ef2a646
·
verified ·
1 Parent(s): d6a9623

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+ import gradio as gr
3
+ import os
4
+ from groq import Groq
5
+
6
+ client = Groq(
7
+ api_key=os.environ.get("GROQ_API_KEY"),
8
+ )
9
+
10
+ #backend
11
+ def llm_call(message, history):
12
+ # LLM
13
+ chat_completion = client.chat.completions.create(
14
+ messages=[
15
+ {
16
+ "role": "user",
17
+ "content": message,
18
+ }
19
+ ],
20
+ model="llama-3.3-70b-versatile",
21
+ )
22
+
23
+ print(chat_completion.choices[0].message.content)
24
+ return chat_completion.choices[0].message.content
25
+
26
+ # UI
27
+ demo = gr.ChatInterface(llm_call, type="messages", autofocus=False)
28
+
29
+ if __name__ == "__main__":
30
+ demo.launch()
31
+
32
+
33
+
34
+