Skip to content

langchain test connection time out #1688

@hashiqi-233

Description

@hashiqi-233

当我按照langchain_integration.md配置好前三个服务,都是正常的。使用测试代码,报错,发生异常: ConnectionError
HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fb7ddcc22b0>: Failed to establish a new connection: [Errno 110] Connection timed out'))
TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fb7ddcc22b0>: Failed to establish a new connection: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fb7ddcc22b0>: Failed to establish a new connection: [Errno 110] Connection timed out'))

During handling of the above exception, another exception occurred:

File "/workspace/37656/FastChat-main/ceshi.py", line 9, in
index = VectorstoreIndexCreator(embedding=embedding).from_loaders([loader])
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fb7ddcc22b0>: Failed to establish a new connection: [Errno 110] Connection timed out'))

测试代码如下:

from langchain.document_loaders import TextLoader
from langchain.indexes import VectorstoreIndexCreator
from langchain.embeddings import OpenAIEmbeddings
from langchain.llms import OpenAI

embedding = OpenAIEmbeddings(model="text-embedding-ada-002",request_timeout=5000)

wget https://raw.githubusercontent.com/hwchase17/langchain/master/docs/modules/state_of_the_union.txt

loader = TextLoader('state_of_the_union.txt')
index = VectorstoreIndexCreator(embedding=embedding).from_loaders([loader])

llm = OpenAI(model="gpt-3.5-turbo")

questions = [
"who is the speaker",
"What did the president say about Ketanji Brown Jackson",
"What are the threats to America",
"Who are mentioned in the speech",
"Who is the vice president",
"How many projects were announced",
]

for query in questions:
print("Query: ", query)
print("Ans: ",index.query(query,llm=llm))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions