Spaces:
Sleeping
Sleeping
file modified
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ import os
|
|
8 |
import logging
|
9 |
|
10 |
# Set up logger
|
11 |
-
logger = logging.getLogger(
|
12 |
logger.setLevel(logging.DEBUG)
|
13 |
console_handler = logging.StreamHandler()
|
14 |
file_handler = logging.FileHandler('chatbot_log.log')
|
@@ -80,17 +80,21 @@ def customLLMBot(user_input, uploaded_image, chat_history):
|
|
80 |
logger.debug(f"Image received, size: {len(base64_image)} bytes")
|
81 |
|
82 |
# Create a message for the image prompt
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
89 |
|
90 |
logger.info("Sending image to Groq API for processing...")
|
91 |
response = client.chat.completions.create(
|
92 |
model="llama-3.2-11b-vision-preview",
|
93 |
-
messages=
|
94 |
)
|
95 |
logger.info("Image processed successfully.")
|
96 |
else:
|
@@ -112,6 +116,7 @@ def customLLMBot(user_input, uploaded_image, chat_history):
|
|
112 |
|
113 |
# Append the bot's response to the chat history
|
114 |
chat_history.append(("bot", LLM_reply))
|
|
|
115 |
|
116 |
# Generate audio for response
|
117 |
audio_file = f"response_{uuid.uuid4().hex}.mp3"
|
@@ -181,9 +186,7 @@ def chatbot_ui():
|
|
181 |
|
182 |
return demo
|
183 |
|
184 |
-
|
185 |
# Launch the interface
|
186 |
chatbot_ui().launch(server_name="0.0.0.0", server_port=7860)
|
187 |
|
188 |
-
|
189 |
#chatbot_ui().launch(server_name="localhost", server_port=7860)
|
|
|
8 |
import logging
|
9 |
|
10 |
# Set up logger
|
11 |
+
logger = logging.getLogger(_name_)
|
12 |
logger.setLevel(logging.DEBUG)
|
13 |
console_handler = logging.StreamHandler()
|
14 |
file_handler = logging.FileHandler('chatbot_log.log')
|
|
|
80 |
logger.debug(f"Image received, size: {len(base64_image)} bytes")
|
81 |
|
82 |
# Create a message for the image prompt
|
83 |
+
# Create a message specifically for image prompts
|
84 |
+
messages_image=[
|
85 |
+
{
|
86 |
+
"role": "user",
|
87 |
+
"content": [
|
88 |
+
{"type": "text", "text": "What's in this image?"},
|
89 |
+
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{base64_image}"}}
|
90 |
+
]
|
91 |
+
}
|
92 |
+
]
|
93 |
|
94 |
logger.info("Sending image to Groq API for processing...")
|
95 |
response = client.chat.completions.create(
|
96 |
model="llama-3.2-11b-vision-preview",
|
97 |
+
messages=messages_image,
|
98 |
)
|
99 |
logger.info("Image processed successfully.")
|
100 |
else:
|
|
|
116 |
|
117 |
# Append the bot's response to the chat history
|
118 |
chat_history.append(("bot", LLM_reply))
|
119 |
+
messages.append({"role":"assistant","content":LLM_reply})
|
120 |
|
121 |
# Generate audio for response
|
122 |
audio_file = f"response_{uuid.uuid4().hex}.mp3"
|
|
|
186 |
|
187 |
return demo
|
188 |
|
|
|
189 |
# Launch the interface
|
190 |
chatbot_ui().launch(server_name="0.0.0.0", server_port=7860)
|
191 |
|
|
|
192 |
#chatbot_ui().launch(server_name="localhost", server_port=7860)
|