feat: Migrate OpenAI implementation to use structured outputs (#6964)

This commit is contained in:
Michael Genson
2026-01-31 11:57:05 -06:00
committed by GitHub
parent dcf410739e
commit 570d6f1433
14 changed files with 124 additions and 273 deletions

View File

@@ -21,7 +21,7 @@ def test_openai_create_recipe_from_image(
unique_user: TestUser,
test_image_jpg: str,
):
async def mock_get_response(self, prompt: str, message: str, *args, **kwargs) -> str | None:
async def mock_get_response(self, prompt: str, message: str, *args, **kwargs) -> OpenAIRecipe | None:
data = OpenAIRecipe(
name=random_string(),
description=random_string(),
@@ -33,7 +33,7 @@ def test_openai_create_recipe_from_image(
instructions=[OpenAIRecipeInstruction(text=random_string()) for _ in range(1, random_int(5, 10))],
notes=[OpenAIRecipeNotes(text=random_string()) for _ in range(random_int(2, 5))],
)
return data.model_dump_json()
return data
monkeypatch.setattr(OpenAIService, "get_response", mock_get_response)
with open(test_image_jpg, "rb") as f: