Skip to content

Commit 2912d54

Browse files
authored
Merge pull request #184 from log10-io/nqn/large-files
[ENG-850] Large files break logger
2 parents 7b56d11 + 5e30aea commit 2912d54

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

log10/load.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,11 @@ def wrapper(*args, **kwargs):
705705
while result_queue.empty():
706706
pass
707707
result = result_queue.get()
708-
completionID = result["completionID"]
708+
709+
if result is None:
710+
return output
711+
712+
completionID = result.get("completionID")
709713
last_completion_response_var.set(result)
710714

711715
with timed_block("result call duration (sync)"):

tests/large_image.png

14.8 MB
Loading

tests/test_magentic.py

+24-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22

33
import openai
44
import pytest
5-
from magentic import AsyncParallelFunctionCall, AsyncStreamedStr, FunctionCall, OpenaiChatModel, StreamedStr, prompt
5+
from magentic import (
6+
AsyncParallelFunctionCall,
7+
AsyncStreamedStr,
8+
FunctionCall,
9+
OpenaiChatModel,
10+
StreamedStr,
11+
SystemMessage,
12+
chatprompt,
13+
prompt,
14+
)
15+
from magentic.vision import UserImageMessage
616
from pydantic import BaseModel
717

818
from log10._httpx_utils import finalize
@@ -176,3 +186,16 @@ async def _generate_title_and_description(query: str, widget_data: str) -> Widge
176186
_LogAssertion(
177187
completion_id=session.last_completion_id(), function_args=function_args
178188
).assert_function_call_response()
189+
190+
191+
@pytest.mark.async_client
192+
@pytest.mark.widget
193+
@pytest.mark.asyncio(scope="module")
194+
async def test_large_image_upload(session, magentic_model):
195+
with open("./tests/large_image.png", "rb") as f:
196+
image_bytes = f.read()
197+
198+
@chatprompt(SystemMessage("What's in the following screenshot?"), UserImageMessage(image_bytes))
199+
def _llm() -> str: ...
200+
201+
_llm()

0 commit comments

Comments
 (0)