Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

community[minor]: Update model client to support vision model in Tong… #21474

Merged

Conversation

pcliupc
Copy link
Contributor

@pcliupc pcliupc commented May 9, 2024

  • 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 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

Copy link

vercel bot commented May 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 21, 2024 11:55am

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. 🤖:improvement Medium size change to existing code to handle new use-cases size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels May 9, 2024
@pcliupc pcliupc force-pushed the feat/support-tongyi-vision-model branch 3 times, most recently from a8dea08 to 3eb08dd Compare May 9, 2024 10:11
@pcliupc
Copy link
Contributor Author

pcliupc commented May 14, 2024

@baskaryan Would you like to take a look at this pr?

@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label May 21, 2024
@baskaryan baskaryan merged commit 4cf5239 into langchain-ai:master May 21, 2024
44 checks passed
JuHyung-Son pushed a commit to JuHyung-Son/langchain that referenced this pull request May 23, 2024
langchain-ai#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:improvement Medium size change to existing code to handle new use-cases lgtm PR looks good. Use to confirm that a PR is ready for merging. size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants