Engineer786 commited on
Commit
d06a9da
·
verified ·
1 Parent(s): 0b60293

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from groq import Groq
3
+
4
+ # API Key (replace with yours)
5
+ API_KEY = "YOUR_GROQ_API_KEY"
6
+
7
+ # Function to interact with the model
8
+ def get_model_response(prompt):
9
+ try:
10
+ client = Groq(api_key=API_KEY)
11
+ chat_completion = client.chat.completions.create(
12
+ messages=[
13
+ {
14
+ "role": "user",
15
+ "content": prompt,
16
+ }
17
+ ],
18
+ model="llama3-8b-8192", # Update with your desired model
19
+ )
20
+ response = chat_completion.choices[0].message.content
21
+ return response
22
+ except Exception as e:
23
+ return f"An error occurred: {str(e)}"
24
+
25
+ # Streamlit App
26
+ st.title("AI Chat Interface")
27
+ st.write("This app allows you to interact with a Groq-powered AI model.")
28
+
29
+ user_input = st.text_input("Your Prompt", placeholder="Type your question here...")
30
+ if st.button("Get Response"):
31
+ response = get_model_response(user_input)
32
+ st.write(f"Model Response: {response}")