SparkLLM Chat
SparkLLM chat models API by iFlyTek. For more information, see iFlyTek Open Platform.
Basic useβ
"""For basic init and call"""
from langchain.chat_models import ChatSparkLLM
from langchain.schema 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])
- Get SparkLLMβs app_id, api_key and api_secret from iFlyTek SparkLLM
API Console (for more info,
see iFlyTek SparkLLM Intro ),
then set environment variables
IFLYTEK_SPARK_APP_ID
,IFLYTEK_SPARK_API_KEY
andIFLYTEK_SPARK_API_SECRET
or pass parameters when creatingChatSparkLLM
as the demo above.
For ChatSparkLLM with Streamingβ
chat = ChatSparkLLM(streaming=True)
for chunk in chat.stream("Hello!"):
print(chunk.content, end="")