Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-850] Large files break logger #184

Merged
merged 5 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading