Skip to content

Commit

Permalink
Merge pull request #184 from log10-io/nqn/large-files
Browse files Browse the repository at this point in the history
[ENG-850] Large files break logger
  • Loading branch information
nqn committed Jun 11, 2024
2 parents 7b56d11 + 5e30aea commit 2912d54
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
6 changes: 5 additions & 1 deletion log10/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"):
Expand Down
Binary file added tests/large_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 24 additions & 1 deletion tests/test_magentic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

0 comments on commit 2912d54

Please sign in to comment.