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

receiving this error when uploading an image in local mode #426

Open
cspark0610 opened this issue Nov 8, 2024 · 3 comments
Open

receiving this error when uploading an image in local mode #426

cspark0610 opened this issue Nov 8, 2024 · 3 comments

Comments

@cspark0610
Copy link

Describe the bug
receiveing this error when uploading an image in local mode

poetry run uvicorn main:app --reload --port 7001
INFO: Will watch for changes in these directories: [/Documents/personal_projects/screenshot-to-code/backend']
INFO: Uvicorn running on http://127.0.0.1:7001 (Press CTRL+C to quit)
INFO: Started reloader process [40040] using StatReload
INFO: Started server process [40044]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: ('127.0.0.1', 57565) - "WebSocket /generate-code" [accepted]
Incoming websocket connection...
INFO: connection open
Received params
Using anthropicApiKey from environment variable
Using official OpenAI URL
Generating html_css code in image mode
Status (variant 0): Generating code...
Status (variant 1): Generating code...
[CLAUDE IMAGE PROCESSING] no processing needed
[CLAUDE IMAGE PROCESSING] no processing needed
Error generating code. Please contact support.
Traceback (most recent call last):
File "/Documents/personal_projects/screenshot-to-code/backend/llm.py", line 128, in stream_claude_response
async with client.messages.stream(
~~~~~~~~~~~~~~~~~~~~~~^
model=model.value,
^^^^^^^^^^^^^^^^^^
...<4 lines>...
extra_headers={"anthropic-beta": "max-tokens-3-5-sonnet-2024-07-15"},
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
) as stream:
^
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/anthropic/lib/streaming/_messages.py", line 305, in aenter
raw_stream = await self.__api_request
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/anthropic/_base_client.py", line 1838, in post
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/anthropic/_base_client.py", line 1532, in request
return await self._request(
^^^^^^^^^^^^^^^^^^^^
...<5 lines>...
)
^
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/anthropic/_base_client.py", line 1633, in _request
raise self._make_status_error_from_response(err.response) from None
anthropic.AuthenticationError: Error code: 401 - {'type': 'error', 'error': {'type': 'authentication_error', 'message': 'invalid x-api-key'}}
Traceback (most recent call last):
File "/Documents/personal_projects/screenshot-to-code/backend/llm.py", line 128, in stream_claude_response
async with client.messages.stream(
~~~~~~~~~~~~~~~~~~~~~~^
model=model.value,
^^^^^^^^^^^^^^^^^^
...<4 lines>...
extra_headers={"anthropic-beta": "max-tokens-3-5-sonnet-2024-07-15"},
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
) as stream:
^
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/anthropic/lib/streaming/_messages.py", line 305, in aenter
raw_stream = await self.__api_request
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/anthropic/_base_client.py", line 1838, in post
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/anthropic/_base_client.py", line 1532, in request
return await self._request(
^^^^^^^^^^^^^^^^^^^^
...<5 lines>...
)
^
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/anthropic/_base_client.py", line 1633, in _request
raise self._make_status_error_from_response(err.response) from None
anthropic.AuthenticationError: Error code: 401 - {'type': 'error', 'error': {'type': 'authentication_error', 'message': 'invalid x-api-key'}}
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 250, in run_asgi
result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/fastapi/applications.py", line 276, in call
await super().call(scope, receive, send)
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/starlette/applications.py", line 122, in call
await self.middleware_stack(scope, receive, send)
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/starlette/middleware/errors.py", line 149, in call
await self.app(scope, receive, send)
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/starlette/middleware/cors.py", line 75, in call
await self.app(scope, receive, send)
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/starlette/middleware/exceptions.py", line 79, in call
raise exc
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/starlette/middleware/exceptions.py", line 68, in call
await self.app(scope, receive, sender)
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in call
raise e
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call
await self.app(scope, receive, send)
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/starlette/routing.py", line 718, in call
await route.handle(scope, receive, send)
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/starlette/routing.py", line 341, in handle
await self.app(scope, receive, send)
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/starlette/routing.py", line 82, in app
await func(session)
File "/Library/Caches/pypoetry/virtualenvs/backend-0eH0r054-py3.13/lib/python3.13/site-packages/fastapi/routing.py", line 289, in app
await dependant.call(**values)
File "/Documents/personal_projects/screenshot-to-code/backend/routes/generate_code.py", line 329, in stream_code
raise Exception("All generations failed")
Exception: All generations failed
INFO: connection closed

Screenshots of backend AND frontend terminal logs
If applicable, add screenshots to help explain your problem.

@abi
Copy link
Owner

abi commented Nov 8, 2024

See: invalid x-api-key

@cspark0610
Copy link
Author

anthropic api key is setted as env var in backend, it has to be setted also where ??

@abi
Copy link
Owner

abi commented Nov 8, 2024

Your key is probably just not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants