Skip to main content
Open In ColabOpen on GitHub

腾讯混元

腾讯的混合模型API (Hunyuan API) 实现了对话交流、内容生成、 分析和理解,并可以广泛应用于各种场景,如智能 客服、智能营销、角色扮演、广告文案、产品描述、 剧本创作、简历生成、文章写作、代码生成、数据分析和内容 分析。

查看更多信息

from langchain_community.chat_models import ChatHunyuan
from langchain_core.messages import HumanMessage
API Reference:ChatHunyuan | HumanMessage
chat = ChatHunyuan(
hunyuan_app_id=111111111,
hunyuan_secret_id="YOUR_SECRET_ID",
hunyuan_secret_key="YOUR_SECRET_KEY",
)
chat(
[
HumanMessage(
content="You are a helpful assistant that translates English to French.Translate this sentence from English to French. I love programming."
)
]
)
AIMessage(content="J'aime programmer.")

用于流式传输的ChatHunyuan

chat = ChatHunyuan(
hunyuan_app_id="YOUR_APP_ID",
hunyuan_secret_id="YOUR_SECRET_ID",
hunyuan_secret_key="YOUR_SECRET_KEY",
streaming=True,
)
chat(
[
HumanMessage(
content="You are a helpful assistant that translates English to French.Translate this sentence from English to French. I love programming."
)
]
)
AIMessageChunk(content="J'aime programmer.")

这个页面有帮助吗?