Chainlit / cookbook

Chainlit's cookbook repo
https://github.com/Chainlit/chainlit
661 stars 245 forks source link

Custom react frontend with chainlit now working #90

Closed Kota-11711406 closed 4 months ago

Kota-11711406 commented 4 months ago

I was able to use chainlit as chatbot, but when I'm trying to integrate react with it, the react frontend is not able to fetch the message of chainlit backend, while I'm trying to run custom frontend example repo by chainlit.

Link to repo : https://github.com/Chainlit/cookbook/tree/main/custom-frontend

Exception in ASGI application Traceback (most recent call last): File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call await super().call(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/applications.py", line 116, in call await self.middleware_stack(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in call raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in call await self.app(scope, receive, _send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/cors.py", line 91, in call await self.simple_response(scope, receive, send, request_headers=headers) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/cors.py", line 146, in simple_response await self.app(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app await app(scope, receive, sender) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 746, in call await route.handle(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle await self.app(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 75, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app await app(scope, receive, sender) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 70, in app response = await func(request) ^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 299, in app raise e File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 294, in app raw_response = await run_endpoint_function( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function return await dependant.call(values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/Desktop/cookbook-main/custom-frontend/chainlit-backend/app.py", line 25, in custom_auth token = create_jwt(cl.User(identifier="Test User")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/chainlit/auth.py", line 58, in create_jwt encoded_jwt = jwt.encode(to_encode, get_jwt_secret(), algorithm="HS256") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/api_jwt.py", line 73, in encode return api_jws.encode( ^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/api_jws.py", line 160, in encode key = alg_obj.prepare_key(key) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/algorithms.py", line 265, in prepare_key key_bytes = force_bytes(key) ^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/utils.py", line 22, in force_bytes raise TypeError("Expected a string value") TypeError: Expected a string value ERROR: Exception in ASGI application Traceback (most recent call last): File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call await super().call(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/applications.py", line 116, in call await self.middleware_stack(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in call raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in call await self.app(scope, receive, _send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/cors.py", line 91, in call await self.simple_response(scope, receive, send, request_headers=headers) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/cors.py", line 146, in simple_response await self.app(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app await app(scope, receive, sender) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 746, in call await route.handle(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle await self.app(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 75, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app await app(scope, receive, sender) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 70, in app response = await func(request) ^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 299, in app raise e File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 294, in app raw_response = await run_endpoint_function( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function return await dependant.call(values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/Desktop/cookbook-main/custom-frontend/chainlit-backend/app.py", line 25, in custom_auth token = create_jwt(cl.User(identifier="Test User")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/chainlit/auth.py", line 58, in create_jwt encoded_jwt = jwt.encode(to_encode, get_jwt_secret(), algorithm="HS256") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/api_jwt.py", line 73, in encode return api_jws.encode( ^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/api_jws.py", line 160, in encode key = alg_obj.prepare_key(key) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/algorithms.py", line 265, in prepare_key key_bytes = force_bytes(key) ^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/utils.py", line 22, in force_bytes raise TypeError("Expected a string value") TypeError: Expected a string value ERROR: Exception in ASGI application Traceback (most recent call last): File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call await super().call(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/applications.py", line 116, in call await self.middleware_stack(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in call raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in call await self.app(scope, receive, _send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/cors.py", line 91, in call await self.simple_response(scope, receive, send, request_headers=headers) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/cors.py", line 146, in simple_response await self.app(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app await app(scope, receive, sender) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 746, in call await route.handle(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle await self.app(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 75, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app await app(scope, receive, sender) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 70, in app response = await func(request) ^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 299, in app raise e File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 294, in app raw_response = await run_endpoint_function( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function return await dependant.call(values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/Desktop/cookbook-main/custom-frontend/chainlit-backend/app.py", line 25, in custom_auth token = create_jwt(cl.User(identifier="Test User")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/chainlit/auth.py", line 58, in create_jwt encoded_jwt = jwt.encode(to_encode, get_jwt_secret(), algorithm="HS256") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/api_jwt.py", line 73, in encode return api_jws.encode( ^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/api_jws.py", line 160, in encode key = alg_obj.prepare_key(key) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/algorithms.py", line 265, in prepare_key key_bytes = force_bytes(key) ^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/utils.py", line 22, in force_bytes raise TypeError("Expected a string value") TypeError: Expected a string value ERROR: Exception in ASGI application Traceback (most recent call last): File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call await super().call(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/applications.py", line 116, in call await self.middleware_stack(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in call raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in call await self.app(scope, receive, _send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/cors.py", line 91, in call await self.simple_response(scope, receive, send, request_headers=headers) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/cors.py", line 146, in simple_response await self.app(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app await app(scope, receive, sender) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 746, in call await route.handle(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle await self.app(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 75, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app await app(scope, receive, sender) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 70, in app response = await func(request) ^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 299, in app raise e File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 294, in app raw_response = await run_endpoint_function( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function return await dependant.call(values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/Desktop/cookbook-main/custom-frontend/chainlit-backend/app.py", line 25, in custom_auth token = create_jwt(cl.User(identifier="Test User")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/chainlit/auth.py", line 58, in create_jwt encoded_jwt = jwt.encode(to_encode, get_jwt_secret(), algorithm="HS256") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/api_jwt.py", line 73, in encode return api_jws.encode( ^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/api_jws.py", line 160, in encode key = alg_obj.prepare_key(key) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/algorithms.py", line 265, in prepare_key key_bytes = force_bytes(key) ^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/utils.py", line 22, in force_bytes raise TypeError("Expected a string value") TypeError: Expected a string value ERROR: Exception in ASGI application Traceback (most recent call last): File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call await super().call(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/applications.py", line 116, in call await self.middleware_stack(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in call raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in call await self.app(scope, receive, _send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/cors.py", line 91, in call await self.simple_response(scope, receive, send, request_headers=headers) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/cors.py", line 146, in simple_response await self.app(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app await app(scope, receive, sender) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 746, in call await route.handle(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle await self.app(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 75, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app await app(scope, receive, sender) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 70, in app response = await func(request) ^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 299, in app raise e File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 294, in app raw_response = await run_endpoint_function( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function return await dependant.call(values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/Desktop/cookbook-main/custom-frontend/chainlit-backend/app.py", line 25, in custom_auth token = create_jwt(cl.User(identifier="Test User")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/chainlit/auth.py", line 58, in create_jwt encoded_jwt = jwt.encode(to_encode, get_jwt_secret(), algorithm="HS256") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/api_jwt.py", line 73, in encode return api_jws.encode( ^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/api_jws.py", line 160, in encode key = alg_obj.prepare_key(key) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/algorithms.py", line 265, in prepare_key key_bytes = force_bytes(key) ^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/utils.py", line 22, in force_bytes raise TypeError("Expected a string value") TypeError: Expected a string value ERROR: Exception in ASGI application Traceback (most recent call last): File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call await super().call(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/applications.py", line 116, in call await self.middleware_stack(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in call raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in call await self.app(scope, receive, _send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/cors.py", line 91, in call await self.simple_response(scope, receive, send, request_headers=headers) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/cors.py", line 146, in simple_response await self.app(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app await app(scope, receive, sender) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 746, in call await route.handle(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle await self.app(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 75, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app raise exc File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app await app(scope, receive, sender) File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/starlette/routing.py", line 70, in app response = await func(request) ^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 299, in app raise e File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 294, in app raw_response = await run_endpoint_function( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function return await dependant.call(values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/Desktop/cookbook-main/custom-frontend/chainlit-backend/app.py", line 25, in custom_auth token = create_jwt(cl.User(identifier="Test User")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/chainlit/auth.py", line 58, in create_jwt encoded_jwt = jwt.encode(to_encode, get_jwt_secret(), algorithm="HS256") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/api_jwt.py", line 73, in encode return api_jws.encode( ^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/api_jws.py", line 160, in encode key = alg_obj.prepare_key(key) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/algorithms.py", line 265, in prepare_key key_bytes = force_bytes(key) ^^^^^^^^^^^^^^^^ File "/Users/srichandankota/anaconda3/lib/python3.11/site-packages/jwt/utils.py", line 22, in force_bytes raise TypeError("Expected a string value") TypeError: Expected a string value

benaichouchemgit commented 4 months ago

make sure you run chainlit generate-secret and put it in the ENV file