Skip to content

Commit b470901

Browse files
committed
Mypy fixes
1 parent e0a8843 commit b470901

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

app/backend/prepdocslib/embeddings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ async def create_embedding(self, image_bytes: bytes) -> list[float]:
252252
async with session.post(url=endpoint, params=params, data=image_bytes) as resp:
253253
resp_json = await resp.json()
254254
return resp_json["vector"]
255+
raise ValueError("Failed to get image embedding after multiple retries.")
255256

256257
def before_retry_sleep(self, retry_state):
257258
logger.info("Rate limited on the Vision embeddings API, sleeping before retrying...")

app/backend/prepdocslib/mediadescriber.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,12 @@ async def describe_image(self, image_bytes: bytes) -> str:
134134
"text": "Describe image with no more than 5 sentences. Do not speculate about anything you don't know.",
135135
"type": "text",
136136
},
137-
{"image_url": {"url": image_datauri}, "type": "image_url", "detail": "auto"},
137+
{"image_url": {"url": image_datauri, "detail": "auto"}, "type": "image_url"},
138138
],
139139
},
140140
],
141141
)
142-
description = response.choices[0].message.content.strip() if response.choices else ""
142+
description = ""
143+
if response.choices and response.choices[0].message.content:
144+
description = response.choices[0].message.content.strip()
143145
return description

0 commit comments

Comments
 (0)