mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
743f888580
**Description:** This PR adds [Dappier](https://dappier.com/) for the chat model. It supports generate, async generate, and batch functionalities. We added unit and integration tests as well as a notebook with more details about our chat model. **Dependencies:** No extra dependencies are needed.
35 lines
981 B
Python
35 lines
981 B
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.dappier import _format_dappier_messages
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("messages", "expected"),
|
|
[
|
|
(
|
|
[
|
|
SystemMessage(
|
|
content="You are a chat model with real time search tools"
|
|
),
|
|
HumanMessage(content="Hello how are you today?"),
|
|
],
|
|
[
|
|
{
|
|
"role": "system",
|
|
"content": "You are a chat model with real time search tools",
|
|
},
|
|
{"role": "user", "content": "Hello how are you today?"},
|
|
],
|
|
)
|
|
],
|
|
)
|
|
def test_dappier_messages_formatting(
|
|
messages: List[BaseMessage], expected: str
|
|
) -> None:
|
|
result = _format_dappier_messages(messages)
|
|
assert result == expected
|