shivace007 commited on
Commit
062af14
·
verified ·
1 Parent(s): 1556eaf

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +13 -7
src/streamlit_app.py CHANGED
@@ -1,5 +1,4 @@
1
  import streamlit as st
2
- #import openai
3
  from dotenv import load_dotenv
4
  import os
5
  from groq import Groq
@@ -21,8 +20,16 @@ st.markdown("Upload an image or provide an image URL to get AI-generated comment
21
  # Load environment variables
22
  load_dotenv()
23
 
24
- # Initialize Groq client
25
- client = Groq(api_key=os.getenv("GROQ_API_KEY"))
 
 
 
 
 
 
 
 
26
 
27
  # Create input field for image URL
28
  image_url = st.text_input("Enter Image URL", "https://static.seekingalpha.com/uploads/2016/1/19/saupload_fredgraph.jpg")
@@ -49,7 +56,7 @@ if st.button("Analyze Image"):
49
 
50
  # Create the completion request
51
  completion = client.chat.completions.create(
52
- model="meta-llama/llama-4-scout-17b-16e-instruct",
53
  messages=[
54
  {
55
  "role": "user",
@@ -68,10 +75,9 @@ if st.button("Analyze Image"):
68
  }
69
  ],
70
  temperature=1,
71
- max_completion_tokens=300,
72
  top_p=1,
73
- stream=False,
74
- stop=None,
75
  )
76
 
77
  # Display the image
 
1
  import streamlit as st
 
2
  from dotenv import load_dotenv
3
  import os
4
  from groq import Groq
 
20
  # Load environment variables
21
  load_dotenv()
22
 
23
+ # Initialize Groq client with the correct configuration
24
+ api_key = os.getenv("GROQ_API_KEY")
25
+ if not api_key:
26
+ st.error("Please set your GROQ_API_KEY in the .env file")
27
+ st.stop()
28
+
29
+ client = Groq(
30
+ api_key=api_key,
31
+ base_url="https://api.groq.com/v1"
32
+ )
33
 
34
  # Create input field for image URL
35
  image_url = st.text_input("Enter Image URL", "https://static.seekingalpha.com/uploads/2016/1/19/saupload_fredgraph.jpg")
 
56
 
57
  # Create the completion request
58
  completion = client.chat.completions.create(
59
+ model="llama2-70b-4096", # Updated model name
60
  messages=[
61
  {
62
  "role": "user",
 
75
  }
76
  ],
77
  temperature=1,
78
+ max_tokens=300, # Updated parameter name
79
  top_p=1,
80
+ stream=False
 
81
  )
82
 
83
  # Display the image