Spaces:
Sleeping
Sleeping
Commit ·
727cfb3
1
Parent(s): e35ef75
Added minimal selection of vision models; needs expansion
Browse files
app.py
CHANGED
|
@@ -18,7 +18,7 @@ def encode_image(uploaded_file):
|
|
| 18 |
base64_image = base64.b64encode(bytes_data).decode('utf-8')
|
| 19 |
return f"data:image/{uploaded_file.type.split('/')[-1]};base64,{base64_image}"
|
| 20 |
|
| 21 |
-
def generate_response(messages, current_image=None):
|
| 22 |
# Create a copy of messages for the API call
|
| 23 |
api_messages = messages.copy()
|
| 24 |
|
|
@@ -35,7 +35,7 @@ def generate_response(messages, current_image=None):
|
|
| 35 |
]
|
| 36 |
}
|
| 37 |
|
| 38 |
-
model = "llama-3.2-
|
| 39 |
|
| 40 |
stream = client.chat.completions.create(
|
| 41 |
model=model,
|
|
@@ -53,6 +53,12 @@ def generate_response(messages, current_image=None):
|
|
| 53 |
|
| 54 |
st.title("Groq Chat")
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
# Display chat history
|
| 57 |
for message in st.session_state.messages:
|
| 58 |
with st.chat_message(message["role"]):
|
|
@@ -84,7 +90,7 @@ if user_input:
|
|
| 84 |
|
| 85 |
# Stream the response
|
| 86 |
with st.spinner("Generating response..."):
|
| 87 |
-
for content in generate_response(st.session_state.messages, current_image):
|
| 88 |
full_response += content
|
| 89 |
response_placeholder.markdown(full_response + "▌")
|
| 90 |
response_placeholder.markdown(full_response)
|
|
|
|
| 18 |
base64_image = base64.b64encode(bytes_data).decode('utf-8')
|
| 19 |
return f"data:image/{uploaded_file.type.split('/')[-1]};base64,{base64_image}"
|
| 20 |
|
| 21 |
+
def generate_response(messages, model, current_image=None):
|
| 22 |
# Create a copy of messages for the API call
|
| 23 |
api_messages = messages.copy()
|
| 24 |
|
|
|
|
| 35 |
]
|
| 36 |
}
|
| 37 |
|
| 38 |
+
model = "llama-3.2-90b-vision-preview"
|
| 39 |
|
| 40 |
stream = client.chat.completions.create(
|
| 41 |
model=model,
|
|
|
|
| 53 |
|
| 54 |
st.title("Groq Chat")
|
| 55 |
|
| 56 |
+
model = st.selectbox(
|
| 57 |
+
"Select a model",
|
| 58 |
+
["llama-3.2-90b-vision-preview", "llama-3.2-11b-vision-preview"],
|
| 59 |
+
index=0,
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
# Display chat history
|
| 63 |
for message in st.session_state.messages:
|
| 64 |
with st.chat_message(message["role"]):
|
|
|
|
| 90 |
|
| 91 |
# Stream the response
|
| 92 |
with st.spinner("Generating response..."):
|
| 93 |
+
for content in generate_response(st.session_state.messages, model, current_image):
|
| 94 |
full_response += content
|
| 95 |
response_placeholder.markdown(full_response + "▌")
|
| 96 |
response_placeholder.markdown(full_response)
|