Skip to content

Commit

Permalink
prepare tests for multimodality
Browse files Browse the repository at this point in the history
  • Loading branch information
pieroit committed Dec 20, 2024
1 parent 718f057 commit 4a5a657
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
17 changes: 16 additions & 1 deletion core/tests/looking_glass/test_stray_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_stray_nlp(stray):
assert isinstance(embedding[0][0], float)


def test_stray_call(stray):
def test_stray_call_with_text(stray):
msg = {"text": "Where do I go?", "user_id": "Alice"}

reply = stray.__call__(msg)
Expand All @@ -38,6 +38,21 @@ def test_stray_call(stray):
assert isinstance(reply.why, MessageWhy)


def test_stray_call_with_text_and_image(stray):
msg = {
"text": "Where do I go?",
"user_id": "Alice",
"image": "https://raw.githubusercontent.com/cheshire-cat-ai/core/refs/heads/main/readme/cheshire-cat.jpeg",
}

reply = stray.__call__(msg)

assert isinstance(reply, CatMessage)
assert "You did not configure" in reply.text
assert reply.user_id == "Alice"
assert reply.type == "chat"
assert isinstance(reply.why, MessageWhy)

# TODO: update these tests once we have a real LLM in tests
def test_stray_classify(stray):
label = stray.classify("I feel good", labels=["positive", "negative"])
Expand Down
5 changes: 3 additions & 2 deletions core/tests/mocks/mock_plugin/mock_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
from typing import List, Type
from pydantic import ConfigDict

from langchain_community.llms.fake import FakeListLLM
from langchain_community.chat_models.fake import FakeListChatModel

from cat.mad_hatter.decorators import hook
from cat.factory.llm import LLMSettings

class FakeLLMConfig(LLMSettings):
"""Fake LLM for testing purposes."""

_pyclass: Type = FakeListLLM
responses: List[str] = ["I'm a fake LLM!"]
_pyclass: Type = FakeListChatModel

model_config = ConfigDict(
json_schema_extra={
Expand Down

0 comments on commit 4a5a657

Please sign in to comment.