Skip to content

Commit

Permalink
🖼️ Add image analysis test
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Jan 22, 2024
1 parent 03bce74 commit c257232
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions tests/ollama_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
from funcchain import chain, settings
from pydantic import BaseModel
from PIL import Image
from pydantic import BaseModel, Field


class Task(BaseModel):
Expand Down Expand Up @@ -39,26 +40,28 @@ def test_neural_chat() -> None:
)


# def test_vision() -> None:
# from PIL import Image
class Analysis(BaseModel):
description: str = Field(description="A description of the image")
objects: list[str] = Field(description="A list of objects found in the image")

# settings.llm = "mys/ggml_llava-v1.5-13b"

# class Analysis(BaseModel):
# description: str = Field(description="A description of the image")
# objects: list[str] = Field(description="A list of objects found in the image")
def analyse(image: Image.Image) -> Analysis:
"""
Analyse the image and extract its
theme, description and objects.
"""
return chain()


# def analyse(image: Image.Image) -> Analysis:
# """
# Analyse the image and extract its
# theme, description and objects.
# """
# return chain()
@pytest.mark.skip_on_actions
def test_vision() -> None:
settings.llm = "ollama/bakllava"

assert isinstance(
analyse(Image.open("examples/assets/old_chinese_temple.jpg")),
Analysis,
) # todo check actual output

# assert isinstance(
# analyse(Image.open("examples/assets/old_chinese_temple.jpg")),
# Analysis,
# )

# TODO: Test union types
# def test_union_types() -> None:
Expand Down

0 comments on commit c257232

Please sign in to comment.