cohere模型报错403,是不是用国内网都无法连接上了?
代码如下:

env环境:

我发现weaciate其实连接成功了,但是运行到cohere就报错了:
D:\code\llmops\llmops-api\env\lib\site-packages\langchain_openai\embeddings\base.py:585: PydanticDeprecatedSince20: The `dict` method is deprecated; use `model_dump` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.12/migration/
response = response.dict()
Traceback (most recent call last):
File "D:\code\llmops\llmops-api\env\lib\site-packages\cohere\raw_base_client.py", line 1916, in rerank
object_=_response.json(),
File "D:\code\llmops\llmops-api\env\lib\site-packages\httpx\_models.py", line 832, in json
return jsonlib.loads(self.content, **kwargs)
File "D:\Env\python\python310\lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "D:\Env\python\python310\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "D:\Env\python\python310\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\code\llmops\llmops-api\study\52-ReRank重排序提升RAG系统效果\1.Cohere重排序示例.py", line 53, in <module>
search_docs = retriever.invoke("关于LLMOps应用配置的信息有哪些呢?")
File "D:\code\llmops\llmops-api\env\lib\site-packages\langchain_core\retrievers.py", line 252, in invoke
raise e
File "D:\code\llmops\llmops-api\env\lib\site-packages\langchain_core\retrievers.py", line 245, in invoke
result = self._get_relevant_documents(
File "D:\code\llmops\llmops-api\env\lib\site-packages\langchain\retrievers\contextual_compression.py", line 46, in _get_relevant_documents
compressed_docs = self.base_compressor.compress_documents(
File "D:\code\llmops\llmops-api\env\lib\site-packages\langchain_cohere\rerank.py", line 121, in compress_documents
for res in self.rerank(documents, query):
File "D:\code\llmops\llmops-api\env\lib\site-packages\langchain_cohere\rerank.py", line 88, in rerank
results = self.client.rerank(
File "D:\code\llmops\llmops-api\env\lib\site-packages\cohere\base_client.py", line 1214, in rerank
_response = self._raw_client.rerank(
File "D:\code\llmops\llmops-api\env\lib\site-packages\cohere\raw_base_client.py", line 2021, in rerank
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
cohere.core.api_error.ApiError: headers: {'content-length': '134', 'content-type': 'text/html; charset=UTF-8', 'date': 'Sat, 14 Feb 2026 02:43:26 GMT', 'alt-svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000'}, status_code: 403, body: <!doctype html><meta charset="utf-8"><meta name=viewport content="width=device-width, initial-scale=1"><title>403</title>403 Forbidden
D:\code\llmops\llmops-api\env\lib\site-packages\weaviate\warnings.py:302: ResourceWarning: Con004: The connection to Weaviate was not closed properly. This can lead to memory leaks.
Please make sure to close the connection using `client.close()`.
sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=3244, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('7.249.125.73', 34503), raddr=('34.160.174.119', 443)>
sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=1812, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('7.249.125.73', 57990), raddr=('34.96.76.122', 443)>
请老师帮忙分析下,谢谢。
正在回答 回答被采纳积分+1
- 参与学习 588 人
- 解答问题 440 个
全流程打造你自己的(Coze/Dify)低代码智能体开发平台;2025年入行正当时,企业急需,人才稀缺,竞争小;无论入行还是转行,首选口碑好课,门槛低、成长高
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星