Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -399,23 +399,15 @@ def markdown_to_html(markdown_text: str) -> str:
|
|
399 |
# On rend le prompt pour get_image_description paramétrable
|
400 |
async def get_image_description(base64_image: str, prompt: str) -> str:
|
401 |
try:
|
|
|
|
|
|
|
402 |
response = await client.chat.completions.create(
|
403 |
model="gpt-4o-mini",
|
404 |
messages=[
|
405 |
{
|
406 |
"role": "user",
|
407 |
-
"content":
|
408 |
-
{
|
409 |
-
"type": "text",
|
410 |
-
"text": prompt,
|
411 |
-
},
|
412 |
-
{
|
413 |
-
"type": "image_url",
|
414 |
-
"image_url": {
|
415 |
-
"url": f"data:image/jpeg;base64,{base64_image}"
|
416 |
-
},
|
417 |
-
},
|
418 |
-
],
|
419 |
}
|
420 |
],
|
421 |
)
|
@@ -424,6 +416,7 @@ async def get_image_description(base64_image: str, prompt: str) -> str:
|
|
424 |
except Exception as e:
|
425 |
logging.error(f"Erreur lors de l'appel à l'API OpenAI : {str(e)}")
|
426 |
return "Description indisponible."
|
|
|
427 |
# MODIFICATIONS END
|
428 |
|
429 |
async def rewrite_html_accessible(html_content: str) -> str:
|
|
|
399 |
# On rend le prompt pour get_image_description paramétrable
|
400 |
async def get_image_description(base64_image: str, prompt: str) -> str:
|
401 |
try:
|
402 |
+
# Intégrer l'image dans le contenu en utilisant Markdown
|
403 |
+
content = f"{prompt}\n\n"
|
404 |
+
|
405 |
response = await client.chat.completions.create(
|
406 |
model="gpt-4o-mini",
|
407 |
messages=[
|
408 |
{
|
409 |
"role": "user",
|
410 |
+
"content": content,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
}
|
412 |
],
|
413 |
)
|
|
|
416 |
except Exception as e:
|
417 |
logging.error(f"Erreur lors de l'appel à l'API OpenAI : {str(e)}")
|
418 |
return "Description indisponible."
|
419 |
+
|
420 |
# MODIFICATIONS END
|
421 |
|
422 |
async def rewrite_html_accessible(html_content: str) -> str:
|