timoklimmer / powerproxy-aoai

Monitors and processes traffic to and from Azure OpenAI endpoints.
MIT License
83 stars 23 forks source link

Error running locally #70

Closed sterankin closed 2 months ago

sterankin commented 2 months ago

Attempting to run locally, hitting the following error:

AttributeError: 'int' object has no attribute 'startswith'

which is on line 90 in the dicts.py:

if path.startswith("/"):

From debugging, the path variable is evaluated as a 1 (int).

I'm not sure where this path value is coming from and why its bringing in an int.

Trace:

cd /Users/n02/src/powerproxy-aoai/app ; /usr/bin/env /usr/local/bin/python3.11 /Users/n02/.vscode/extensions/ms-python.python-2024.4.1/python_files/lib/python/debugpy/adapter/../../debugpy/launcher 56169 -- powerproxy.py --config-file ../config/config
.local.yaml 
------------------------------------
PowerProxy for Azure OpenAI - v0.0.0
------------------------------------
Proxy runs at port              : 80
Clients identified by API Key   : Team1, Team2
ERROR:    Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 732, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "powerproxy.py", line 65, in lifespan
    config.print()
  File "/Users/n02/src/powerproxy-aoai/app/helpers/config.py", line 49, in print
    f"{self['fixed_client'] if 'fixed_client' in self and self['fixed_client'] else '(not set)'}",
                               ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/n02/src/powerproxy-aoai/app/helpers/config.py", line 32, in __getitem__
    return self.values_dict[key]
           ~~~~~~~~~~~~~~~~^^^^^
  File "/Users/n02/src/powerproxy-aoai/app/helpers/dicts.py", line 11, in __getitem__
    return self.get(key)
           ^^^^^^^^^^^^^
  File "/Users/n02/src/powerproxy-aoai/app/helpers/dicts.py", line 33, in get
    keys_from_path = QueryDict._get_keys_from_path(path, separator, escape_sequence)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/n02/src/powerproxy-aoai/app/helpers/dicts.py", line 90, in _get_keys_from_path
    if path.startswith("/"):
       ^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'startswith'

ERROR:    Application startup failed. Exiting.

Is this an issue with the config yaml and if so do you have an example for running locally?

Thanks

timoklimmer commented 2 months ago

Hi @sterankin, thanks for reaching out. Looks like there was a bug. I have fixed it, and it should be working now.