Skip to content

Commit

Permalink
✨ Add llamacpp tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Dec 12, 2023
1 parent 15bfd53 commit f33813f
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions tests/llamacpp_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import pytest
from funcchain import chain, settings
from pydantic import BaseModel


class Task(BaseModel):
description: str
difficulty: int


class TodoList(BaseModel):
tasks: list[Task]


def todo_list(job_title: str) -> TodoList:
"""
Create a todo list for a perfect day for the given job.
"""
return chain()


@pytest.mark.skip_on_actions
def test_openhermes() -> None:
settings.MODEL_NAME = "gguf/openhermes-2.5-mistral-7b"

assert isinstance(
todo_list("software engineer"),
TodoList,
)


@pytest.mark.skip_on_actions
def test_neural_chat() -> None:
settings.MODEL_NAME = "gguf/neural-chat-7b-v3-1"

assert isinstance(
todo_list("ai engineer"),
TodoList,
)


# def test_vision() -> None:
# from PIL import Image

# settings.MODEL_NAME = "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()

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

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


def test_model_search_failure() -> None:
settings.MODEL_NAME = "gguf/neural-chat-ultra-mega"

try:
todo_list("software engineer")
except Exception:
assert True
else:
assert False, "Model should not be found"


if __name__ == "__main__":
test_openhermes()
test_neural_chat()
# test_vision()
test_model_search_failure()

0 comments on commit f33813f

Please sign in to comment.