Engineer786 commited on
Commit
443d818
·
verified ·
1 Parent(s): a865167

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -21
app.py CHANGED
@@ -7,24 +7,24 @@ API_KEY = "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"
7
 
8
  # Function to interact with the model
9
  def get_model_response(prompt):
10
- try:
11
- client = Groq(api_key=API_KEY)
12
- chat_completion = client.chat.completions.create(
13
- messages=[
14
- {
15
- "role": "user",
16
- "content": prompt,
17
- }
18
- ],
19
- model="llama3-8b-8192", # Update with your desired model
20
- )
21
- response = chat_completion.choices[0].message.content
22
- return response
23
- except Exception as e:
24
- return f"An error occurred: {str(e)}"
25
 
26
  # Streamlit App
27
- st.set_page_config(page_title="AI Chat Interface", page_icon='https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRDtq0iX3NP1eu6DiEnnmm1moWENvPHYNsMZQ&s', layout="wide")
28
 
29
  # Add a header with logo (optional)
30
  st.markdown("""
@@ -36,14 +36,13 @@ st.markdown("""
36
 
37
  # Progress bar animation for loading
38
  with st.spinner("Thinking..."):
39
- time.sleep(2) # Simulate processing time
40
 
41
  # User input with placeholder and help text
42
  user_input = st.text_input("Your Prompt", placeholder="Type your question here...", help="Feel free to ask anything!")
43
 
44
  # Display "Thinking..." animation while fetching response
45
  if st.button("Get Response"):
46
- with st.spinner("Fetching Response..."):
47
- response = get_model_response(user_input)
48
- st.write(f" {response}")
49
-
 
7
 
8
  # Function to interact with the model
9
  def get_model_response(prompt):
10
+ try:
11
+ client = Groq(api_key=API_KEY)
12
+ chat_completion = client.chat.completions.create(
13
+ messages=[
14
+ {
15
+ "role": "user",
16
+ "content": prompt,
17
+ }
18
+ ],
19
+ model="llama3-8b-8192", # Update with your desired model
20
+ )
21
+ response = chat_completion.choices[0].message.content
22
+ return response
23
+ except Exception as e:
24
+ return f"An error occurred: {str(e)}"
25
 
26
  # Streamlit App
27
+ st.set_page_config(page_title="AI Chat Interface", page_icon="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRDtq0iX3NP1eu6DiEnnmm1moWENvPHYNsMZQ&s", layout="wide") # Removed semicolon
28
 
29
  # Add a header with logo (optional)
30
  st.markdown("""
 
36
 
37
  # Progress bar animation for loading
38
  with st.spinner("Thinking..."):
39
+ time.sleep(2) # Simulate processing time
40
 
41
  # User input with placeholder and help text
42
  user_input = st.text_input("Your Prompt", placeholder="Type your question here...", help="Feel free to ask anything!")
43
 
44
  # Display "Thinking..." animation while fetching response
45
  if st.button("Get Response"):
46
+ with st.spinner("Fetching Response..."):
47
+ response = get_model_response(user_input)
48
+ st.write(f" {response}")