Fix str passed to json
This commit is contained in:
@@ -33,7 +33,7 @@ def check_dish_safety(image_path: str) -> dict:
|
|||||||
response_raw = generate(
|
response_raw = generate(
|
||||||
prompt=prompt,
|
prompt=prompt,
|
||||||
images=[image_path],
|
images=[image_path],
|
||||||
output_format=DISH_SAFETY_SCHEMA # Passed as Ollama's `format` parameter
|
output_format=json.dumps(DISH_SAFETY_SCHEMA)
|
||||||
)
|
)
|
||||||
print(f"[Debug] Raw response from AI generator: {response_raw}")
|
print(f"[Debug] Raw response from AI generator: {response_raw}")
|
||||||
|
|
||||||
@@ -41,8 +41,4 @@ def check_dish_safety(image_path: str) -> dict:
|
|||||||
if isinstance(response_raw, dict):
|
if isinstance(response_raw, dict):
|
||||||
return response_raw
|
return response_raw
|
||||||
|
|
||||||
# 2. If it's a string or bytes, parse it
|
|
||||||
if isinstance(response_raw, (str, bytes, bytearray)):
|
|
||||||
return json.loads(response_raw)
|
|
||||||
|
|
||||||
raise ValueError(f"Unexpected response type from AI generator: {type(response_raw)}")
|
raise ValueError(f"Unexpected response type from AI generator: {type(response_raw)}")
|
||||||
Reference in New Issue
Block a user