Amm1rr / WebAI-to-API

Claude, Gemini to API : ) (Don't need API KEY)
MIT License
194 stars 39 forks source link

claude: Internal Server Error #9

Closed johnd0e closed 10 months ago

johnd0e commented 10 months ago

When using http://127.0.0.1:8000/claude

Output in server console:

Traceback (most recent call last):
  File "D:\AI\WebAI-to-API\venv\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 408, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "D:\AI\WebAI-to-API\venv\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
  File "D:\AI\WebAI-to-API\venv\lib\site-packages\fastapi\applications.py", line 289, in __call__
    await super().__call__(scope, receive, send)
  File "D:\AI\WebAI-to-API\venv\lib\site-packages\starlette\applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "D:\AI\WebAI-to-API\venv\lib\site-packages\starlette\middleware\errors.py", line 184, in __call__
    raise exc
  File "D:\AI\WebAI-to-API\venv\lib\site-packages\starlette\middleware\errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "D:\AI\WebAI-to-API\venv\lib\site-packages\starlette\middleware\cors.py", line 83, in __call__
    await self.app(scope, receive, send)
  File "D:\AI\WebAI-to-API\venv\lib\site-packages\starlette\middleware\exceptions.py", line 79, in __call__
    raise exc
  File "D:\AI\WebAI-to-API\venv\lib\site-packages\starlette\middleware\exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "D:\AI\WebAI-to-API\venv\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 20, in __call__
    raise e
  File "D:\AI\WebAI-to-API\venv\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "D:\AI\WebAI-to-API\venv\lib\site-packages\starlette\routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "D:\AI\WebAI-to-API\venv\lib\site-packages\starlette\routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "D:\AI\WebAI-to-API\venv\lib\site-packages\starlette\routing.py", line 66, in app
    response = await func(request)
  File "D:\AI\WebAI-to-API\venv\lib\site-packages\fastapi\routing.py", line 273, in app
    raw_response = await run_endpoint_function(
  File "D:\AI\WebAI-to-API\venv\lib\site-packages\fastapi\routing.py", line 190, in run_endpoint_function
    return await dependant.call(**values)
  File "D:\AI\WebAI-to-API\src\main.py", line 546, in ask_claude
    claude = Client(cookie)
  File "D:\AI\WebAI-to-API\src\claude.py", line 14, in __init__
    self.organization_id = self.get_organization_id()
  File "D:\AI\WebAI-to-API\src\claude.py", line 34, in get_organization_id
    uuid = res[0]['uuid']
KeyError: 0

P.S. I was testing with curl. But example_claude.py is ok

johnd0e commented 10 months ago

Fixed by changing "session_id": "session-ID" to "session_id": "" But still, this exception is bug.

Amm1rr commented 10 months ago

Instructions and example codes are now clearly fixed and available right now.

johnd0e commented 10 months ago

Indeed, you fixed instructions. But not the code - in case of wrong (or outdated) token value we still get exception. It would be better to handle it, and return clear error message.

But again - it is not clear why we may need to specify the value already present in Config.conf?

It would be more useful to have ability to continue some previous conversation, specifying it's id.

zexry619 commented 10 months ago

image

I still don't understand how to get this session key.

The format is still not correct. When I copy all the values it appears like this:

   File "/usr/local/lib/python3.10/dist-packages/browser_cookie3/__init__.py", line 195, in __enter__
     self.__connection = open_dbus_connection()
   File "/usr/lib/python3/dist-packages/jeepney/io/blocking.py", line 332, in open_dbus_connection
     bus_addr = get_bus(bus)
   File "/usr/lib/python3/dist-packages/jeepney/bus.py", line 53, in get_bus
     return find_session_bus()
   File "/usr/lib/python3/dist-packages/jeepney/bus.py", line 42, in find_session_bus
     addr = os.environ['DBUS_SESSION_BUS_ADDRESS']
   File "/usr/lib/python3.10/os.py", line 680, in __getitem__
     raise KeyError(key) from None
KeyError: 'DBUS_SESSION_BUS_ADDRESS'
johnd0e commented 10 months ago

You only need sessionKey.