langchain/libs/community/tests/unit_tests/chat_models/test_edenai.py
Harrison Chase 4eda647fdd
infra: add -p to mkdir in lint steps (#17013)
Previously, if this did not find a mypy cache then it wouldnt run

this makes it always run

adding mypy ignore comments with existing uncaught issues to unblock other prs

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>
2024-02-05 11:22:06 -08:00

41 lines
1.2 KiB
Python

"""Test EdenAI Chat API wrapper."""
from typing import List
import pytest
from langchain_core.messages import BaseMessage, HumanMessage, SystemMessage
from langchain_community.chat_models.edenai import (
_format_edenai_messages,
_message_role,
)
@pytest.mark.parametrize(
("messages", "expected"),
[
(
[
SystemMessage(content="Translate the text from English to French"),
HumanMessage(content="Hello how are you today?"),
],
{
"text": "Hello how are you today?",
"previous_history": [],
"chatbot_global_action": "Translate the text from English to French",
},
)
],
)
def test_edenai_messages_formatting(messages: List[BaseMessage], expected: str) -> None:
result = _format_edenai_messages(messages)
assert result == expected
@pytest.mark.parametrize(
("role", "role_response"),
[("ai", "assistant"), ("human", "user"), ("chat", "user")],
)
def test_edenai_message_role(role: str, role_response) -> None: # type: ignore[no-untyped-def]
role = _message_role(role)
assert role == role_response