How to tackle this? Everything works for the first few minutes, then it it become unstable:
gemini_webapi.exceptions.APIError: Failed to generate contents (stream). Unknown API error code: 1097. This might be a temporary Google service issue.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/run.py", line 39, in <module>
uvicorn.run(
│ └ <function run at 0xe19effab3740>
└ <module 'uvicorn' from '/app/.venv/lib/python3.13/site-packages/uvicorn/__init__.py'>
File "/app/.venv/lib/python3.13/site-packages/uvicorn/main.py", line 606, in run
server.run()
│ └ <function Server.run at 0xe19effa4c7c0>
└ <uvicorn.server.Server object at 0xe19efd9d9160>
File "/app/.venv/lib/python3.13/site-packages/uvicorn/server.py", line 75, in run
return asyncio_run(self.serve(sockets=sockets), loop_factory=self.config.get_loop_factory())
│ │ │ │ │ │ └ <function Config.get_loop_factory at 0xe19effab7f60>
│ │ │ │ │ └ <uvicorn.config.Config object at 0xe19efd9d9010>
│ │ │ │ └ <uvicorn.server.Server object at 0xe19efd9d9160>
│ │ │ │ └ <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0xe19efd8079c0>
│ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0xe19efda...
│ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('192.168.100.6', 8000),...
│ └ <function request_response.<locals>.app at 0xe19efd9ec040>
└ APIRoute(path='/v1/chat/completions', name='create_chat_completion', methods=['POST'])
File "/app/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 134, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
How to tackle this? Everything works for the first few minutes, then it it become unstable: