Skip to content

Commit

Permalink
Merge branch 'main' into kt/update-anthropic-funcion-calls
Browse files Browse the repository at this point in the history
  • Loading branch information
kxtran committed Jun 11, 2024
2 parents 4d9ebc0 + 2912d54 commit 32b2f4b
Show file tree
Hide file tree
Showing 5 changed files with 39 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 @@ -591,7 +591,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
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def pytest_addoption(parser):

parser.addoption("--magentic_model", action="store", help="Model name for Magentic tests")

parser.addoption("--magentic_vision_model", action="store", help="Model name for Magentic vision tests")


@pytest.fixture
def openai_model(request):
Expand Down Expand Up @@ -63,6 +65,11 @@ def magentic_model(request):
return request.config.getoption("--magentic_model")


@pytest.fixture
def magentic_vision_model(request):
return request.config.getoption("--magentic_vision_model")


@pytest.fixture
def session():
with log10_session() as session:
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.
1 change: 1 addition & 0 deletions tests/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ addopts =
--mistralai_model=mistral-tiny
--lamini_model=meta-llama/Llama-2-7b-chat-hf
--magentic_model=gpt-3.5-turbo
--magentic_vision_model=gpt-4o

markers =
completion: mark a test as a completion test
Expand Down
27 changes: 26 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 @@ -171,3 +181,18 @@ async def _generate_title_and_description(query: str, widget_data: str) -> Widge

await finalize()
_LogAssertion(completion_id=session.last_completion_id(), function_args=function_args).assert_tool_calls_response()


@pytest.mark.vision
def test_large_image_upload(magentic_vision_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),
model=OpenaiChatModel(model=magentic_vision_model),
)
def _llm() -> str: ...

_llm()

0 comments on commit 32b2f4b

Please sign in to comment.