Spaces:
Sleeping
Sleeping
save
Browse files
app.py
CHANGED
@@ -62,10 +62,15 @@ def extract_text_and_images(file_path):
|
|
62 |
def generate_ai_response(text_content, image_urls, text_prompt):
|
63 |
try:
|
64 |
if image_urls:
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
68 |
]
|
|
|
|
|
69 |
|
70 |
else:
|
71 |
messages = [{"role": "user", "content": f"{text_prompt} Analyze the text: {text_content}"}]
|
|
|
62 |
def generate_ai_response(text_content, image_urls, text_prompt):
|
63 |
try:
|
64 |
if image_urls:
|
65 |
+
messages = [
|
66 |
+
{
|
67 |
+
"role": "user",
|
68 |
+
"content": [
|
69 |
+
{"type": "text", "text": text_prompt},
|
70 |
+
*[{"type": "image_url", "image_url": {"url": url}} for url in image_urls]
|
71 |
]
|
72 |
+
}
|
73 |
+
]
|
74 |
|
75 |
else:
|
76 |
messages = [{"role": "user", "content": f"{text_prompt} Analyze the text: {text_content}"}]
|