Can someone please explian to me if its possible to use upload urls to the asssintant API and get the image description back, this did 100 percent work and now for the life of me all i seem to get is fabricated responses,
if live_url:
# Construct the content structure for the image
media_content = {
"type": "image_url",
"image_url": {
"url": live_url
}
}
# If there is associated text, include it; otherwise, use a default prompt
if text_content:
message_details.append({
'role':
'user',
'content': [{
"type": "text",
"text": text_content
}, media_content]
})
else:
message_details.append({
'role':
'user',
'content': [{
"type": "text",
"text": "describe this image"
}, media_content]
})
try:
text_element = msg.find_element(By.CSS_SELECTOR,
".b-chat__message__text")
text_content = text_element.text
except NoSuchElementException:
logging.info(
f"No text content found for message with ID: {msg.get_attribute('id')}"
)
except Exception as e:
logging.error(
f"Error retrieving text content for message with ID {msg.get_attribute('id')}: {e}"
)
# Handle text-only messages if no image was found
if not live_url:
message_details.append({
'role':
'user',
'content': [{
"type": "text",
"text": text_content
}]
})
logging.info(f"Extracted message details: {message_details}")
return message_details
then - # If no data prepared, create a default data structure
if not isinstance(send_data, dict):
send_data = {
"thread_id": thread_id,
"message": message_details
}
# Ensure the send_data has non-empty message content
if not send_data.get("message"):
logging.error("Message content must be non-empty.")
continue
try:
# Send the prepared data to the chat server
response = requests.post(CHAT_URL, json=send_data)
if response.status_code == 200:
data_json = response.json()
run_id = data_json["run_id"]
time.sleep(5)
logging.info(f"Run id {run_id}")
send_message_to = ""
while True:
send_data = {
"thread_id": thread_id,
"run_id": run_id
}
response = requests.post(CHECK_URL, json=send_data)
if response.status_code == 200:
data_json = response.json()
logging.info(
f"Checking run status {data_json}")
time.sleep(5)
if data_json["status"] == "completed":
send_message_to = data_json["response"]
break
else:
logging.error(
f"Failed to check run status: {response.text}"
)
time.sleep(5)
if send_message_to != "":
send_message(driver,
message=send_message_to,
chat_id=chat_id)
logging.info(f"Message sent to {send_message_to}")
time.sleep(5)
# Log the last message details from the other side
last_message_from_os = json.dumps(
message_details[-1]
['content']) if message_details else ''
last_message_from_os_logged_time = datetime.datetime.now(
).isoformat()
#
and heres how it looks in the threads in openai platform, -
Messages
User
31 Jul 2024, 06:00
[{‘role’: ‘user’, ‘content’: [{‘type’: ‘text’, ‘text’: ‘tell me what u see?’}, {‘type’: ‘image_url’, ‘image_url’: {‘url’: 'https://ab564fc0-4745-41ff-9791-a4f7aa77dfd5-00-3hyc0o005r91n.riker.replit.dev/uploads/TCI_2714301_chat_2714301
Please help somebody ( please not the url image is now dead but when executing its a live image accessible to the www. thanks