Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用openAI的接口去调用one-api调用不同,返回远程主机强迫关闭了一个现有的连接,但是通过postman可以调用通,对接的是ollama #1980

Open
5 tasks
litaolaile opened this issue Dec 13, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@litaolaile
Copy link

例行检查

  • 我已确认目前没有类似 issue
  • 我已确认我已升级到最新版本
  • 我已完整查看过项目 README,尤其是常见问题部分
  • 我理解并愿意跟进此 issue,协助测试和提供反馈
  • 我理解并认可上述内容,并理解项目维护者精力有限,不遵循规则的 issue 可能会被无视或直接关闭

问题描述
源代码【from openai import OpenAI

client = OpenAI(
api_key="sk-JatkiMxJEBFDnQAC46662c598cA049F7803a45Cc677062C5",
base_url="http://10.57.167.86:3000/v1"
)

chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "今天天气如何",
}
],
model="qwen2-7b-instruct:latest",
stream=False
)

执行结果:
【D:\Users\10294692\software\python\python3.exe D:/Users/10294692/code/AI-knowledge-code/AI-knowledge-code/one-api/test.py
Traceback (most recent call last):
File "D:\Users\10294692\software\python\lib\site-packages\httpx_transports\default.py", line 69, in map_httpcore_exceptions
yield
File "D:\Users\10294692\software\python\lib\site-packages\httpx_transports\default.py", line 233, in handle_request
resp = self._pool.handle_request(req)
File "D:\Users\10294692\software\python\lib\site-packages\httpcore_sync\connection_pool.py", line 216, in handle_request
raise exc from None
File "D:\Users\10294692\software\python\lib\site-packages\httpcore_sync\connection_pool.py", line 196, in handle_request
response = connection.handle_request(
File "D:\Users\10294692\software\python\lib\site-packages\httpcore_sync\http_proxy.py", line 207, in handle_request
return self._connection.handle_request(proxy_request)
File "D:\Users\10294692\software\python\lib\site-packages\httpcore_sync\connection.py", line 101, in handle_request
return self._connection.handle_request(request)
File "D:\Users\10294692\software\python\lib\site-packages\httpcore_sync\http11.py", line 143, in handle_request
raise exc
File "D:\Users\10294692\software\python\lib\site-packages\httpcore_sync\http11.py", line 113, in handle_request
) = self._receive_response_headers(**kwargs)
File "D:\Users\10294692\software\python\lib\site-packages\httpcore_sync\http11.py", line 186, in _receive_response_headers
event = self._receive_event(timeout=timeout)
File "D:\Users\10294692\software\python\lib\site-packages\httpcore_sync\http11.py", line 224, in _receive_event
data = self._network_stream.read(
File "D:\Users\10294692\software\python\lib\site-packages\httpcore_backends\sync.py", line 124, in read
with map_exceptions(exc_map):
File "D:\Users\10294692\software\python\lib\contextlib.py", line 153, in exit
self.gen.throw(typ, value, traceback)
File "D:\Users\10294692\software\python\lib\site-packages\httpcore_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ReadError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "D:\Users\10294692\software\python\lib\site-packages\openai_base_client.py", line 991, in _request
response = self._client.send(
File "D:\Users\10294692\software\python\lib\site-packages\httpx_client.py", line 914, in send
response = self._send_handling_auth(
File "D:\Users\10294692\software\python\lib\site-packages\httpx_client.py", line 942, in _send_handling_auth
response = self._send_handling_redirects(
File "D:\Users\10294692\software\python\lib\site-packages\httpx_client.py", line 979, in _send_handling_redirects
response = self._send_single_request(request)
File "D:\Users\10294692\software\python\lib\site-packages\httpx_client.py", line 1015, in _send_single_request
response = transport.handle_request(request)
File "D:\Users\10294692\software\python\lib\site-packages\httpx_transports\default.py", line 232, in handle_request
with map_httpcore_exceptions():
File "D:\Users\10294692\software\python\lib\contextlib.py", line 153, in exit
self.gen.throw(typ, value, traceback)
File "D:\Users\10294692\software\python\lib\site-packages\httpx_transports\default.py", line 86, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ReadError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "D:\Users\10294692\code\AI-knowledge-code\AI-knowledge-code\one-api\test.py", line 9, in
chat_completion = client.chat.completions.create(
File "D:\Users\10294692\software\python\lib\site-packages\openai_utils_utils.py", line 275, in wrapper
return func(*args, **kwargs)
File "D:\Users\10294692\software\python\lib\site-packages\openai\resources\chat\completions.py", line 829, in create
return self._post(
File "D:\Users\10294692\software\python\lib\site-packages\openai_base_client.py", line 1278, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
File "D:\Users\10294692\software\python\lib\site-packages\openai_base_client.py", line 955, in request
return self._request(
File "D:\Users\10294692\software\python\lib\site-packages\openai_base_client.py", line 1015, in _request
return self._retry_request(
File "D:\Users\10294692\software\python\lib\site-packages\openai_base_client.py", line 1093, in _retry_request
return self._request(
File "D:\Users\10294692\software\python\lib\site-packages\openai_base_client.py", line 1015, in _request
return self._retry_request(
File "D:\Users\10294692\software\python\lib\site-packages\openai_base_client.py", line 1093, in _retry_request
return self._request(
File "D:\Users\10294692\software\python\lib\site-packages\openai_base_client.py", line 1025, in _request
raise APIConnectionError(request=request) from err
openai.APIConnectionError: Connection error.

Process finished with exit code 1

postman可以调用通
image

复现步骤

预期结果

相关截图
如果没有的话,请删除此节。

@litaolaile litaolaile added the bug Something isn't working label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant