mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
4eda647fdd
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>
41 lines
1.2 KiB
Python
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
|