diff --git a/log10/load.py b/log10/load.py index 3d3e93b1..95f401b5 100644 --- a/log10/load.py +++ b/log10/load.py @@ -705,7 +705,11 @@ def wrapper(*args, **kwargs): while result_queue.empty(): pass result = result_queue.get() - completionID = result["completionID"] + + if result is None: + return output + + completionID = result.get("completionID") last_completion_response_var.set(result) with timed_block("result call duration (sync)"): diff --git a/tests/large_image.png b/tests/large_image.png new file mode 100644 index 00000000..9fc22bbb Binary files /dev/null and b/tests/large_image.png differ diff --git a/tests/test_magentic.py b/tests/test_magentic.py index 4c8ed701..ab77d61e 100644 --- a/tests/test_magentic.py +++ b/tests/test_magentic.py @@ -2,7 +2,17 @@ import openai import pytest -from magentic import AsyncParallelFunctionCall, AsyncStreamedStr, FunctionCall, OpenaiChatModel, StreamedStr, prompt +from magentic import ( + AsyncParallelFunctionCall, + AsyncStreamedStr, + FunctionCall, + OpenaiChatModel, + StreamedStr, + SystemMessage, + chatprompt, + prompt, +) +from magentic.vision import UserImageMessage from pydantic import BaseModel from log10._httpx_utils import finalize @@ -176,3 +186,16 @@ async def _generate_title_and_description(query: str, widget_data: str) -> Widge _LogAssertion( completion_id=session.last_completion_id(), function_args=function_args ).assert_function_call_response() + + +@pytest.mark.async_client +@pytest.mark.widget +@pytest.mark.asyncio(scope="module") +async def test_large_image_upload(session, magentic_model): + with open("./tests/large_image.png", "rb") as f: + image_bytes = f.read() + + @chatprompt(SystemMessage("What's in the following screenshot?"), UserImageMessage(image_bytes)) + def _llm() -> str: ... + + _llm()