Open purpleofdial opened 2 weeks ago
Hey @purpleofdial! I'm here to help you with any bugs, questions, or contributions you have while waiting for a human maintainer. Let's figure this out together!
The error you're encountering suggests that there are issues with network connectivity and unclosed client sessions when using the QianfanChatEndpoint
class. Here are a few steps to address these issues:
Network Connectivity:
aip.baidubce.com
.Handling Unclosed Client Sessions:
aiohttp.client.ClientSession
objects to avoid resource leaks. Ensure that sessions are closed after use, especially in asynchronous contexts.Here's an example of how you might manage the client session properly:
import asyncio
from langchain_community.chat_models import QianfanChatEndpoint
from langchain_core.language_models.chat_models import HumanMessage
async def main():
async with QianfanChatEndpoint(
streaming=False,
model="ERNIE-Speed-8K",
) as chatBot:
score = await evaluate(dataset, metrics=[faithfulness, answer_correctness], llm=chatBot, embeddings=embeddings)
print(score)
asyncio.run(main())
This ensures that the QianfanChatEndpoint
is properly closed after use.
Unfortunately, specific details about the retry policies, backoff strategies, and session management for the QianfanChatEndpoint
class are not available in the provided information. You may need to refer to the class documentation or source code for more detailed configurations.
By addressing these points, you should be able to mitigate the network and session management issues you're facing.
To continue talking to Dosu, mention @dosu.
Question Has anyone ever used Baidu Qianfan's model? I have encountered problems when using langchain call, I hope someone can help me.
Code Examples from langchain_community.chat_models import QianfanChatEndpoint from langchain_core.language_models.chat_models import HumanMessage
chatBot = QianfanChatEndpoint( streaming=False, model="ERNIE-Speed-8K", ) score = evaluate(dataset,metrics=[faithfulness,answer_correctness],llm=chatBot,embeddings=embeddings)
Error [ERROR][2024-06-19 08:00:12.491] base.py:444 [t:140121514964544]: request exception: Cannot connect to host aip.baidubce.com:443 ssl:default [Network is unreachable], retrying... Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x7f71bebe56a0> Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x7f71be96d760> Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x7f71bebe5610> [ERROR][2024-06-19 08:00:12.576] base.py:444 [t:140121514964544]: request exception: Cannot connect to host aip.baidubce.com:443 ssl:default [Network is unreachable], retrying... [ERROR][2024-06-19 08:00:12.734] base.py:444 [t:140121514964544]: request exception: Cannot connect to host aip.baidubce.com:443 ssl:default [Network is unreachable], retrying...