mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-16 23:13:31 +00:00
community[patch]: Update model client to support vision model in Tong… (#21474)
- **Description:** Tongyi uses different client for chat model and vision model. This PR chooses proper client based on model name to support both chat model and vision model. Reference [tongyi document](https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-qianwen-vl-plus-api?spm=a2c4g.11186623.0.0.27404c9a7upm11) for details. ``` from langchain_core.messages import HumanMessage from langchain_community.chat_models import ChatTongyi llm = ChatTongyi(model_name='qwen-vl-max') image_message = { "image": "https://lilianweng.github.io/posts/2023-06-23-agent/agent-overview.png" } text_message = { "text": "summarize this picture", } message = HumanMessage(content=[text_message, image_message]) llm.invoke([message]) ``` - **Issue:** None - **Dependencies:** None - **Twitter handle:** None
This commit is contained in:
@@ -77,6 +77,25 @@ def test_model() -> None:
|
||||
assert isinstance(response.content, str)
|
||||
|
||||
|
||||
def test_vision_model() -> None:
|
||||
"""Test model kwarg works."""
|
||||
chat = ChatTongyi(model="qwen-vl-max") # type: ignore[call-arg]
|
||||
response = chat.invoke(
|
||||
[
|
||||
HumanMessage(
|
||||
content=[
|
||||
{
|
||||
"image": "https://python.langchain.com/v0.1/assets/images/run_details-806f6581cd382d4887a5bc3e8ac62569.png"
|
||||
},
|
||||
{"text": "Summarize the image"},
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
assert isinstance(response, BaseMessage)
|
||||
assert isinstance(response.content, list)
|
||||
|
||||
|
||||
def test_functions_call_thoughts() -> None:
|
||||
chat = ChatTongyi(model="qwen-plus") # type: ignore[call-arg]
|
||||
|
||||
|
Reference in New Issue
Block a user