A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://python.langchain.com/docs/integrations/chat/sparkllm/ below:

SparkLLM Chat | 🦜️🔗 LangChain

SparkLLM Chat

SparkLLM chat models API by iFlyTek. For more information, see iFlyTek Open Platform.

Basic use
"""For basic init and call"""
from langchain_community.chat_models import ChatSparkLLM
from langchain_core.messages import HumanMessage

chat = ChatSparkLLM(
spark_app_id="<app_id>", spark_api_key="<api_key>", spark_api_secret="<api_secret>"
)
message = HumanMessage(content="Hello")
chat([message])
AIMessage(content='Hello! How can I help you today?')
For ChatSparkLLM with Streaming
chat = ChatSparkLLM(
spark_app_id="<app_id>",
spark_api_key="<api_key>",
spark_api_secret="<api_secret>",
streaming=True,
)
for chunk in chat.stream("Hello!"):
print(chunk.content, end="")
Hello! How can I help you today?
For v2
"""For basic init and call"""
from langchain_community.chat_models import ChatSparkLLM
from langchain_core.messages import HumanMessage

chat = ChatSparkLLM(
spark_app_id="<app_id>",
spark_api_key="<api_key>",
spark_api_secret="<api_secret>",
spark_api_url="wss://spark-api.xf-yun.com/v2.1/chat",
spark_llm_domain="generalv2",
)
message = HumanMessage(content="Hello")
chat([message])

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4