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

openai.AuthenticationError: Unauthorized #89

Open
watertianyi opened this issue Jul 2, 2024 · 2 comments
Open

openai.AuthenticationError: Unauthorized #89

watertianyi opened this issue Jul 2, 2024 · 2 comments

Comments

@watertianyi
Copy link

2024-07-02 11:13:58.658 | INFO | main:init:426 - Creating KV. May take a while for the first time.
2024-07-02 11:13:58.662 | INFO | leptonai.photon.photon:_uvicorn_run:837 - Setting up signal handlers for graceful incoming traffic shutdown after 5 seconds.
2024-07-02 11:13:58,662 - INFO:
If you are using standard photon, a few urls that may be helpful:
- http://0.0.0.0:8080/docs OpenAPI documentation
- http://0.0.0.0:8080/redoc Redoc documentation
- http://0.0.0.0:8080/openapi.json Raw OpenAPI schema
- http://0.0.0.0:8080/metrics Prometheus metrics

If you are using python clients, here is an example code snippet:
from leptonai.client import Client, local
client = Client(local(port=8080))
client.healthz() # checks the health of the photon
client.paths() # lists all the paths of the photon
client.method_name? # If client has a method_name method, get the docstring
client.method_name(...) # calls the method_name method
If you are using ipython, you can use tab completion by typing client. and then press tab.

2024-07-02 11:13:58,672 - INFO: Started server process [778289]
2024-07-02 11:13:58,672 - INFO: Waiting for application startup.
2024-07-02 11:13:58.673 | INFO | leptonai.photon.photon:uvicorn_startup:776 - Starting photon app - running startup prep code.
2024-07-02 11:13:58,673 - INFO: Application startup complete.
2024-07-02 11:13:58,673 - INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
2024-07-02 11:14:03,179 - INFO: 127.0.0.1:50610 - "GET / HTTP/1.1" 307 Temporary Redirect
2024-07-02 11:14:03,198 - INFO: 127.0.0.1:50610 - "GET /ui/index.html HTTP/1.1" 304 Not Modified
2024-07-02 11:14:03,220 - INFO: 127.0.0.1:50610 - "GET /ui/_next/static/media/c9a5bc6a7c948fb0-s.p.woff2 HTTP/1.1" 304 Not Modified
2024-07-02 11:14:03,221 - INFO: 127.0.0.1:50614 - "GET /ui/_next/static/css/c45868dfc0d7a6fe.css HTTP/1.1" 304 Not Modified
2024-07-02 11:14:03,231 - INFO: 127.0.0.1:50614 - "GET /ui/_next/static/chunks/webpack-fc4785faa12a4784.js HTTP/1.1" 304 Not Modified
2024-07-02 11:14:03,232 - INFO: 127.0.0.1:50610 - "GET /ui/_next/static/chunks/fd9d1056-7fda3e9b28bca7f7.js HTTP/1.1" 304 Not Modified
2024-07-02 11:14:03,232 - INFO: 127.0.0.1:50622 - "GET /ui/_next/static/chunks/938-fe6b19e2b7ce9569.js HTTP/1.1" 304 Not Modified
2024-07-02 11:14:03,233 - INFO: 127.0.0.1:50644 - "GET /ui/_next/static/chunks/445-0d7890e16447ec0a.js HTTP/1.1" 304 Not Modified
2024-07-02 11:14:03,233 - INFO: 127.0.0.1:50632 - "GET /ui/_next/static/chunks/main-app-e7ab2f567f2172b4.js HTTP/1.1" 304 Not Modified
2024-07-02 11:14:03,234 - INFO: 127.0.0.1:50658 - "GET /ui/_next/static/chunks/app/page-aa89276e7ee62c06.js HTTP/1.1" 304 Not Modified
2024-07-02 11:14:09,343 - INFO: 127.0.0.1:50658 - "GET /ui/search.html.txt?q=%25E8%25A2%2581%25E6%25B3%2589%25E6%25BC%2594%25E4%25BA%2586%25E4%25B8%2580%25E4%25B8%25AA%25E4%25B9%2598%25E5%258A%25A1%25E5%2591%2598%25E6%2595%2591%25E4%25BA%2586%25E4%25B8%2580%25E9%25A3%259E%25E6%259C%25BA%25E7%259A%2584%25E4%25BA%25BA&rid=OJQXtgkJpBYDuAHvJsKxA&_rsc=9ehs5 HTTP/1.1" 404 Not Found
2024-07-02 11:14:09,359 - INFO: 127.0.0.1:50658 - "GET /ui/search.html?q=%25E8%25A2%2581%25E6%25B3%2589%25E6%25BC%2594%25E4%25BA%2586%25E4%25B8%2580%25E4%25B8%25AA%25E4%25B9%2598%25E5%258A%25A1%25E5%2591%2598%25E6%2595%2591%25E4%25BA%2586%25E4%25B8%2580%25E9%25A3%259E%25E6%259C%25BA%25E7%259A%2584%25E4%25BA%25BA&rid=OJQXtgkJpBYDuAHvJsKxA HTTP/1.1" 200 OK
2024-07-02 11:14:09,507 - INFO: 127.0.0.1:50658 - "GET /ui/_next/static/chunks/925-a4abdbbc3a2e2d8f.js HTTP/1.1" 304 Not Modified
2024-07-02 11:14:09,507 - INFO: 127.0.0.1:50632 - "GET /ui/_next/static/chunks/app/search/page-576f37977d880d6d.js HTTP/1.1" 304 Not Modified
2024-07-02 11:14:09,591 - INFO: 127.0.0.1:50632 - "GET /ui/bg.svg HTTP/1.1" 304 Not Modified
2024-07-02 11:14:09.612 | ERROR | main:query_function:572 - KV error: 'RAG' object has no attribute 'kv'
Traceback (most recent call last):
File "/media/soul/EC3C5BDA3C5B9E80/win10/soul_code/gpt/search_with_lepton/search_with_lepton.py", line 563, in query_function
result = self.kv.get(search_uuid)
AttributeError: 'RAG' object has no attribute 'kv'
, will generate again.
2024-07-02 11:14:09.612 | INFO | main:search_with_searchapi:215 - {'q': '袁泉演了一个乘务员救了一飞机的人', 'engine': 'google', 'num': 10} {'Authorization': 'Bearer s6Zqers1erJh3KMFBybFtCv6', 'Content-Type': 'application/json'} s6Zqers1erJh3KMFBybFtCv6 袁泉演了一个乘务员救了一飞机的人 https://www.searchapi.io/api/v1/search
2024-07-02 11:14:13.058 | ERROR | main:query_function:620 - encountered error: Unauthorized
Traceback (most recent call last):
File "/media/soul/EC3C5BDA3C5B9E80/win10/soul_code/gpt/search_with_lepton/search_with_lepton.py", line 600, in query_function
llm_response = client.chat.completions.create(
File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/openai/_utils/_utils.py", line 277, in wrapper
return func(*args, **kwargs)
File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/openai/resources/chat/completions.py", line 643, in create
return self._post(
File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/openai/_base_client.py", line 1250, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/openai/_base_client.py", line 931, in request
return self._request(
File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/openai/_base_client.py", line 1030, in _request
raise self._make_status_error_from_response(err.response) from None
openai.AuthenticationError: Unauthorized

2024-07-02 11:14:13,060 - INFO: 127.0.0.1:50632 - "POST /query HTTP/1.1" 200 OK
2024-07-02 11:14:13,062 - ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/responses.py", line 265, in call
await wrap(partial(self.listen_for_disconnect, receive))
File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/responses.py", line 261, in wrap
await func()
File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/responses.py", line 238, in listen_for_disconnect
message = await receive()
File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 553, in receive
await self.message_event.wait()
File "/home/soul/anaconda3/envs/search/lib/python3.9/asyncio/locks.py", line 226, in wait
await fut
asyncio.exceptions.CancelledError: Cancelled by cancel scope 7f11dea3c610

During handling of the above exception, another exception occurred:

  • Exception Group Traceback (most recent call last):
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 399, in run_asgi
    | result = await app( # type: ignore[func-returns-value]
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 70, in call
    | return await self.app(scope, receive, send)
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/fastapi/applications.py", line 1054, in call
    | await super().call(scope, receive, send)
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/applications.py", line 123, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/middleware/errors.py", line 186, in call
    | raise exc
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/middleware/errors.py", line 164, in call
    | await self.app(scope, receive, _send)
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/prometheus_fastapi_instrumentator/middleware.py", line 174, in call
    | raise exc
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/prometheus_fastapi_instrumentator/middleware.py", line 172, in call
    | await self.app(scope, receive, send_wrapper)
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/middleware/cors.py", line 93, in call
    | await self.simple_response(scope, receive, send, request_headers=headers)
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/middleware/cors.py", line 148, in simple_response
    | await self.app(scope, receive, send)
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 65, in call
    | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    | raise exc
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    | await app(scope, receive, sender)
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/routing.py", line 756, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/routing.py", line 776, in app
    | await route.handle(scope, receive, send)
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/routing.py", line 297, in handle
    | await self.app(scope, receive, send)
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/routing.py", line 77, in app
    | await wrap_app_handling_exceptions(app, request)(scope, receive, send)
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    | raise exc
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    | await app(scope, receive, sender)
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/routing.py", line 75, in app
    | await response(scope, receive, send)
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/responses.py", line 265, in call
    | await wrap(partial(self.listen_for_disconnect, receive))
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 680, in aexit
    | raise BaseExceptionGroup(
    | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/responses.py", line 261, in wrap
    | await func()
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/responses.py", line 250, in stream_response
    | async for chunk in self.body_iterator:
    | File "/home/soul/anaconda3/envs/search/lib/python3.9/site-packages/starlette/concurrency.py", line 62, in iterate_in_threadpool
    | as_iterator = iter(iterator)
    | TypeError: 'HTMLResponse' object is not iterable
    +------------------------------------
    2024-07-02 11:37:04,499 - INFO: 127.0.0.1:59392 - "GET /docs HTTP/1.1" 200 OK
    2024-07-02 11:37:06,607 - INFO: 127.0.0.1:59392 - "GET /openapi.json HTTP/1.1" 200 OK
@watertianyi
Copy link
Author

It is correct to replace LEPTON_WORKSPACE_TOKEN with LEPTON_API_TOKEN. Why is this?

@NickN0309
Copy link
Contributor

Thank you for bringing up this issue. We have updated our documentation to include setting up your LEPTON_WORKSPACE_TOKEN before running the server.

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