to the package langchain/chat_models in langchain:API Initializationâ€‹To use the LLM services based on Baidu Qianfan, you have to initialize these parameters:You could either choose to init the AK,SK in environment variables or init params:export QIANFAN_AK=XXXexport QIANFAN_SK=XXXCurrent supported models:â€‹ERNIE-Bot-turbo (default models)ERNIE-BotBLOOMZ-7BLlama-2-7b-chatLlama-2-13b-chatLlama-2-70b-chatQianfan-BLOOMZ-7B-compressedQianfan-Chinese-Llama-2-7BChatGLM2-6B-32KAquilaChat-7B"""For basic init and call"""from langchain.chat_models import QianfanChatEndpoint from langchain.chat_models.base import HumanMessageimport osos.environ["QIANFAN_AK"] = "your_ak"os.environ["QIANFAN_SK"] = "your_sk"chat = QianfanChatEndpoint(                            streaming=True,                             )res = chat([HumanMessage(content="write a funny joke")])    [INFO] [09-15 20:00:29] logging.py:55 [t:139698882193216]: requesting llm api endpoint: /chat/eb-instantfrom langchain.chat_models import QianfanChatEndpointfrom langchain.schema import HumanMessagechatLLM = QianfanChatEndpoint(    streaming=True,)res = chatLLM.stream([HumanMessage(content="hi")], streaming=True)for r in res:    print("chat resp:", r)async def run_aio_generate():    resp = await chatLLM.agenerate(messages=[[HumanMessage(content="write a 20 words sentence about sea.")]])    print(resp)        await run_aio_generate()async def run_aio_stream():    async for res in chatLLM.astream([HumanMessage(content="write a 20 words sentence about sea.")]):        print("astream", res)        await run_aio_stream()    [INFO] [09-15 20:00:36] logging.py:55 [t:139698882193216]: requesting llm api endpoint: /chat/eb-instant    [INFO] [09-15 20:00:37] logging.py:55 [t:139698882193216]: async requesting llm api endpoint: /chat/eb-instant    chat resp: content='æ‚¨å¥½ï¼Œæ‚¨ä¼¼ä¹�è¾“å…¥' additional_kwargs={} example=False    chat resp:
Baidu AI Cloud Qianfan Platform is a one-stop large model development and service operation platform for enterprise developers. Qianfan not only provides including the model of Wenxin Yiyan (ERNIE-Bot) and the third-party open-source models, but also provides various AI development tools and the whole set of development environment, which facilitates customers to use and develop large model applications easily.
Baidu AI Cloud Qianfan Platform is a one-stop large model development and service operation platform for enterprise developers. Qianfan not only provides including the model of Wenxin Yiyan (ERNIE-Bot) and the third-party open-source models, but also provides various AI development tools and the whole set of development environment, which facilitates customers to use and develop large model applications easily. ->: to the package langchain/chat_models in langchain:API Initializationâ€‹To use the LLM services based on Baidu Qianfan, you have to initialize these parameters:You could either choose to init the AK,SK in environment variables or init params:export QIANFAN_AK=XXXexport QIANFAN_SK=XXXCurrent supported models:â€‹ERNIE-Bot-turbo (default models)ERNIE-BotBLOOMZ-7BLlama-2-7b-chatLlama-2-13b-chatLlama-2-70b-chatQianfan-BLOOMZ-7B-compressedQianfan-Chinese-Llama-2-7BChatGLM2-6B-32KAquilaChat-7B"""For basic init and call"""from langchain.chat_models import QianfanChatEndpoint from langchain.chat_models.base import HumanMessageimport osos.environ["QIANFAN_AK"] = "your_ak"os.environ["QIANFAN_SK"] = "your_sk"chat = QianfanChatEndpoint(                            streaming=True,                             )res = chat([HumanMessage(content="write a funny joke")])    [INFO] [09-15 20:00:29] logging.py:55 [t:139698882193216]: requesting llm api endpoint: /chat/eb-instantfrom langchain.chat_models import QianfanChatEndpointfrom langchain.schema import HumanMessagechatLLM = QianfanChatEndpoint(    streaming=True,)res = chatLLM.stream([HumanMessage(content="hi")], streaming=True)for r in res:    print("chat resp:", r)async def run_aio_generate():    resp = await chatLLM.agenerate(messages=[[HumanMessage(content="write a 20 words sentence about sea.")]])    print(resp)        await run_aio_generate()async def run_aio_stream():    async for res in chatLLM.astream([HumanMessage(content="write a 20 words sentence about sea.")]):        print("astream", res)        await run_aio_stream()    [INFO] [09-15 20:00:36] logging.py:55 [t:139698882193216]: requesting llm api endpoint: /chat/eb-instant    [INFO] [09-15 20:00:37] logging.py:55 [t:139698882193216]: async requesting llm api endpoint: /chat/eb-instant    chat resp: content='æ‚¨å¥½ï¼Œæ‚¨ä¼¼ä¹�è¾“å…¥' additional_kwargs={} example=False    chat resp: