KenyonY / openai-forward

🚀 大语言模型高效转发服务 · An efficient forwarding service designed for LLMs. · OpenAI API Reverse Proxy
https://api.openai-forward.com
MIT License
839 stars 288 forks source link

经常模型奇妙的崩溃 #135

Closed fuckqqcom closed 4 months ago

fuckqqcom commented 5 months ago

初始检查

问题描述

docker部署的,经常看日志会崩溃 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, │ │ └ {'name': 'main', 'doc': None, 'package': 'openai_forward', 'loader': <_frozen_importlib_external.SourceFi... │ └ <code object at 0x7fec8e505840, file "/home/openai-forward/openai_forward/main.py", line 1> └ <function _run_code at 0x7fec8e8eeef0> File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) │ └ {'name': 'main', 'doc': None, 'package': 'openai_forward', 'loader': <_frozen_importlib_external.SourceFi... └ <code object at 0x7fec8e505840, file "/home/openai-forward/openai_forward/main.py", line 1>

File "/home/openai-forward/openai_forward/main.py", line 255, in main() └ <function main at 0x7fec8e502b00>

File "/home/openai-forward/openai_forward/main.py", line 251, in main fire.Fire(Cli) │ │ └ <class 'main.Cli'> │ └ <function Fire at 0x7fec8e5725f0> └ <module 'fire' from '/usr/local/lib/python3.10/site-packages/fire/init.py'>

File "/usr/local/lib/python3.10/site-packages/fire/core.py", line 143, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) │ │ │ │ │ └ 'main.py' │ │ │ │ └ {} │ │ │ └ Namespace(verbose=False, interactive=False, separator='-', completion=None, help=False, trace=False) │ │ └ ['run'] │ └ <class 'main.Cli'> └ <function _Fire at 0x7fec8db1f490> File "/usr/local/lib/python3.10/site-packages/fire/core.py", line 477, in _Fire component, remaining_args = _CallAndUpdateTrace( │ └ <function _CallAndUpdateTrace at 0x7fec8db1f5b0> └ <bound method Cli.run of <main.Cli object at 0x7fec8d73fb50>> File "/usr/local/lib/python3.10/site-packages/fire/core.py", line 693, in _CallAndUpdateTrace component = fn(*varargs, **kwargs) │ │ └ {} │ └ [8000, 1, False, True, 8001] └ <bound method Cli.run of <main.Cli object at 0x7fec8d73fb50>>

File "/home/openai-forward/openai_forward/main.py", line 55, in run uvicorn.run( │ └ <function run at 0x7fec8d7c2200> └ <module 'uvicorn' from '/usr/local/lib/python3.10/site-packages/uvicorn/init.py'>

File "/usr/local/lib/python3.10/site-packages/uvicorn/main.py", line 575, in run server.run() │ └ <function Server.run at 0x7fec8d7c1b40> └ <uvicorn.server.Server object at 0x7fec8d73c910> File "/usr/local/lib/python3.10/site-packages/uvicorn/server.py", line 65, in run return asyncio.run(self.serve(sockets=sockets)) │ │ │ │ └ None │ │ │ └ <function Server.serve at 0x7fec8d7c1bd0> │ │ └ <uvicorn.server.Server object at 0x7fec8d73c910> │ └ <function run at 0x7fec8e356830> └ <module 'asyncio' from '/usr/local/lib/python3.10/asyncio/init.py'> File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) │ │ └ <coroutine object Server.serve at 0x7fec8d48c190> │ └ <method 'run_until_complete' of 'uvloop.loop.Loop' objects> └

File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 411, in run_asgi result = await app( # type: ignore[func-returns-value] └ <uvicorn.middleware.proxy_headers.ProxyHeadersMiddleware object at 0x7fec8d747490> File "/usr/local/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in call return await self.app(scope, receive, send) │ │ │ │ └ <bound method RequestResponseCycle.send of <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fec6df538... │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fec6df... │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('172.17.0.2', 8000), 'c... │ └ <fastapi.applications.FastAPI object at 0x7fec78c30520> └ <uvicorn.middleware.proxy_headers.ProxyHeadersMiddleware object at 0x7fec8d747490> File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in call await super().call(scope, receive, send)

配置/代码示例和输出

No response

我的见解

看代码是不是 这块路由放的很开,建议是卡死,因为部署一个线上服务,肯定会被扫码到各种奇奇怪怪的请求,建议参数不对或者请求方式不对直接拒绝。 <function request_response..app at 0x7fec6df00310> | └ Route(path='/{api_path:path}', name='reverse_proxy', methods=['DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'TR... | File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 77, in app

环境

python3.10

最后一步

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 4 months ago

This issue was closed because it has been inactive for 7 days since being marked as stale.