检查其他资源
- 我为这个问题添加了一个非常描述性的标题。
- 我使用集成搜索在LangChain文档中进行了搜索。
- 我使用GitHub搜索查找类似的问题,但没有找到。
- 我确信这是LangChain中的一个bug,而不是我的代码。
- 通过更新到LangChain的最新稳定版本(或特定集成包)无法解决此错误。
示例代码
from langchain_openai import AzureOpenAIEmbeddings
os.environ["AZURE_OPENAI_API_KEY"] = get_auth_token()
os.environ["OPENAI_API_KEY"] = get_auth_token()
os.environ["AZURE_OPENAI_ENDPOINT"] = 'https://workspace.openai.azure.com/'
os.environ["OPENAI_ENDPOINT"] = 'https://workspace.openai.azure.com/'
os.environ['OPENAI_API_TYPE'] = "azure"
os.environ['OPENAI_API_VERSION']='2023-07-01-preview'
embeddings = AzureOpenAIEmbeddings(
model='text-embedding-3-small',
chunk_size=1
)
embeddings.embed_documents(['text'])
错误信息和堆栈跟踪(如果适用)
---------------------------------------------------------------------------
SSLEOFError Traceback (most recent call last)
File /anaconda/envs/nlp_min/lib/python3.10/site-packages/urllib3/connectionpool.py:670, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
[669](https://vscode-remote+amlext-002b2f737562736372697074696f6e732f32316164386262372d633338382d343161352d613931612d6362336539323161356439612f7265736f7572636547726f7570732f676932756f6b79757439356e6c6c392d636f6d6d6f6e2f70726f7669646572732f4d6963726f736f66742e4d616368696e654c6561726e696e6753657276696365732f776f726b7370616365732f676932756f6b79757439356e6c6c392d616d6c2f636f6d70757465732f6465762d41313030.vscode-resource.vscode-cdn.net/anaconda/envs/nlp_min/lib/python3.10/site-packages/urllib3/connectionpool.py:669) # Make the request on the httplib connection object.
......
[706](https://vscode-remote+amlext-002b2f737562736372697074696f6e732f32316164386262372d633338382d343161352d613931612d6362336539323161356439612f7265736f7572636547726f7570732f676932756f6b79757439356e6c6c392d636f6d6d6f6e2f70726f7669646572732f4d6963726f736f66742e4d616368696e654c6561726e696e6753657276696365732f776f726b7370616365732f676932756f6b79757439356e6c6c392d616d6c2f636f6d70757465732f6465762d41313030.vscode-resource.vscode-cdn.net/anaconda/envs/nlp_min/lib/python3.10/site-packages/requests/sessions.py:706) elapsed = preferred_clock() - start
File /anaconda/envs/nlp_min/lib/python3.10/site-packages/requests/adapters.py:517, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
[513](https://vscode-remote+amlext-002b2f737562736372697074696f6e732f32316164386262372d633338382d343161352d613931612d6362336539323161356439612f7265736f7572636547726f7570732f676932756f6b79757439356e6c6c392d636f6d6d6f6e2f70726f7669646572732f4d6963726f736f66742e4d616368696e654c6561726e696e6753657276696365732f776f726b7370616365732f676932756f6b79757439356e6c6c392d616d6c2f636f6d70757465732f6465762d41313030.vscode-resource.vscode-cdn.net/anaconda/envs/nlp_min/lib/python3.10/site-packages/requests/adapters.py:513) raise ProxyError(e, request=request)
[515](https://vscode-remote+amlext-002b2f737562736372697074696f6e732f32316164386262372d633338382d343161352d613931612d6362336539323161356439612f7265736f7572636547726f7570732f676932756f6b79757439356e6c6c392d636f6d6d6f6e2f70726f7669646572732f4d6963726f736f66742e4d616368696e654c6561726e696e6753657276696365732f776f726b7370616365732f676932756f6b79757439356e6c6c392d616d6c2f636f6d70757465732f6465762d41313030.vscode-resource.vscode-cdn.net/anaconda/envs/nlp_min/lib/python3.10/site-packages/requests/adapters.py:515) if isinstance(e.reason, _SSLError):
[516](https://vscode-remote+amlext-002b2f737562736372697074696f6e732f32316164386262372d633338382d343161352d613931612d6362336539323161356439612f7265736f7572636547726f7570732f676932756f6b79757439356e6c6c392d636f6d6d6f6e2f70726f7669646572732f4d6963726f736f66742e4d616368696e654c6561726e696e6753657276696365732f776f726b7370616365732f676932756f6b79757439356e6c6c392d616d6c2f636f6d70757465732f6465762d41313030.vscode-resource.vscode-cdn.net/anaconda/envs/nlp_min/lib/python3.10/site-packages/requests/adapters.py:516) # This branch is for urllib3 v1.22 and later.
--> [517](https://vscode-remote+amlext-002b2f737562736372697074696f6e732f32316164386262372d633338382d343161352d613931612d6362336539323161356439612f7265736f7572636547726f7570732f676932756f6b79757439356e6c6c392d636f6d6d6f6e2f70726f7669646572732f4d6963726f736f66742e4d616368696e654c6561726e696e6753657276696365732f776f726b7370616365732f676932756f6b79757439356e6c6c392d616d6c2f636f6d70757465732f6465762d41313030.vscode-resource.vscode-cdn.net/anaconda/envs/nlp_min/lib/python3.10/site-packages/requests/adapters.py:517) raise SSLError(e, request=request)
[519](https://vscode-remote+amlext-002b2f737562736372697074696f6e732f32316164386262372d633338382d343161352d613931612d6362336539323161356439612f7265736f7572636547726f7570732f676932756f6b79757439356e6c6c392d636f6d6d6f6e2f70726f7669646572732f4d6963726f736f66742e4d616368696e654c6561726e696e6753657276696365732f776f726b7370616365732f676932756f6b79757439356e6c6c392d616d6c2f636f6d70757465732f6465762d41313030.vscode-resource.vscode-cdn.net/anaconda/envs/nlp_min/lib/python3.10/site-packages/requests/adapters.py:519) raise ConnectionError(e, request=request)
[521](https://vscode-remote+amlext-002b2f737562736372697074696f6e732f32316164386262372d633338382d343161352d613931612d6362336539323161356439612f7265736f7572636547726f7570732f676932756f6b79757439356e6c6c392d636f6d6d6f6e2f70726f7669646572732f4d6963726f736f66742e4d616368696e654c6561726e696e6753657276696365732f776f726b7370616365732f676932756f6b79757439356e6c6c392d616d6c2f636f6d70757465732f6465762d41313030.vscode-resource.vscode-cdn.net/anaconda/envs/nlp_min/lib/python3.10/site-packages/requests/adapters.py:521) except ClosedPoolError as e:
SSLError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by SSLError(SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1007)')))
描述
我尝试了这段代码片段以及许多变体,都没有成功,问题在于底层函数试图访问openaipublic.blob.core.windows.net,这是不允许的。为什么它要访问外部链接,而它只需要连接到我们的Azure OpenAI端点?
系统信息
langchain==0.2.7
langchain-chroma==0.1.2
langchain-community==0.0.8
langchain-core==0.2.18
langchain-openai==0.1.16
langchain-text-splitters==0.2.2
1条答案
按热度按时间2sbarzqh1#
你好 @hassanzadeh ,
你可以尝试将
azure_deployment
作为嵌入模型的名称传递,如下所示:参考文档:https://python.langchain.com/v0.2/docs/integrations/text_embedding/azureopenai/