QuivrHQ / quivr

Open-source RAG Framework for building GenAI Second Brains 🧠 Build productivity assistant (RAG) ⚡️🤖 Chat with your docs (PDF, CSV, ...) & apps using Langchain, GPT 3.5 / 4 turbo, Private, Anthropic, VertexAI, Ollama, LLMs, Groq that you can share with users ! Efficient retrieval augmented generation framework
https://quivr.com
Other
34.1k stars 3.34k forks source link

backend-core error in "http://localhost:5050/user/identity" [Bug]: #2454

Open Braga-source opened 2 months ago

Braga-source commented 2 months ago

What happened?

It was expected that the Quivr application would function correctly, but with the errors, it is not possible to create brains, for example.

Relevant log output

Installation: Ubuntu 22
The installation guide from the Quivr GitHub page was followed.

The installation proceeds smoothly without errors, and the installation of supabse also presents no issues.

The error is verified when attempting to create a brain, and inspecting the page in Google Chrome, it's possible to see that the error occurs at "http://localhost:5050/brains/" with the message "Not authenticated".

Twitter / LinkedIn details

No response

dosubot[bot] commented 2 months ago

It looks like the issue you're encountering with authentication when trying to create a brain in the Quivr application is likely due to one of several potential misconfigurations or mismatches in your setup. Here's what you should check and adjust to resolve the problem:

  1. Environment Variable Configuration: Ensure the NEXT_PUBLIC_AUTH_MODES is correctly set to include all intended authentication modes. This variable controls which authentication methods are available, such as password, magic link, and Google SSO.

  2. Authentication Mode Support: Verify that the authentication mode you're trying to use is enabled and supported. If you're using a mode that's not listed in NEXT_PUBLIC_AUTH_MODES, authentication will fail.

  3. Supabase Integration: Double-check your Supabase setup, including API keys and redirect URIs for SSO. Incorrect configuration here can prevent successful authentication.

  4. Frontend and Backend Consistency: Make sure that the authentication modes expected by the backend align with those enabled in the frontend. Any mismatch can lead to issues.

For more detailed troubleshooting, consider reviewing the code in backend/modules/brain/service/brain_authorization_service.py and frontend/lib/hooks/useAuthModes.ts.

If these steps don't resolve the issue, providing more specific error messages or logs could help pinpoint the exact problem.

Sources

#### About Dosu This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot.
Braga-source commented 2 months ago

@dosu-bot

"It was done the alterations that were suggested but the problem persists. Configuration of the .env file:"

QUIVR Configuration

This file is used to configure the Quivr stack. It is used by the docker-compose.yml file to configure the stack.

OPENAI. Update this to use your API key. To skip OpenAI integration use a fake key, for example: tk-aabbccddAABBCCDDEeFfGgHhIiJKLmnopjklMNOPqQqQqQqQ

OPENAI_API_KEY=sk-voCNLgel8xcjYElMaU1qT3

LOCAL

OLLAMA_API_BASE_URL=http://host.docker.internal:11434 # Uncomment to activate ollama. This is the local url for the ollama api

########

FRONTEND

########

NEXT_PUBLIC_ENV=local NEXT_PUBLIC_BACKEND_URL=http://localhost:5050 NEXT_PUBLIC_SUPABASE_URL=http://localhost:54321 NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0 NEXT_PUBLIC_CMS_URL=https://cms.quivr.app NEXT_PUBLIC_FRONTEND_URL=http://localhost:* NEXT_PUBLIC_AUTH_MODES=magic_link,google_sso,password

########

BACKEND

########

SUPABASE_URL=http://host.docker.internal:54321 SUPABASE_SERVICE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU PG_DATABASE_URL=notimplementedyet ANTHROPIC_API_KEY=null JWT_SECRET_KEY=super-secret-jwt-token-with-at-least-32-characters-long AUTHENTICATE=true TELEMETRY_ENABLED=true CELERY_BROKER_URL=redis://redis:6379/0 CELEBRY_BROKER_QUEUE_NAME=quivr-preview.fifo QUIVR_DOMAIN=http://localhost:3000/

dosubot[bot] commented 2 months ago

Given the detailed configuration you've shared and the persistent "Not authenticated" error, it seems the issue might still be related to the authentication process, despite the correct setup in your .env file. Here are some targeted steps to troubleshoot and potentially resolve the issue:

  1. Verify Supabase Service Key and URL: Double-check that the SUPABASE_SERVICE_KEY and SUPABASE_URL are correct and match the details in your Supabase project settings. These are crucial for backend communication with Supabase.

  2. Ensure Environment Variables Are Loaded: Confirm that your application is correctly loading the environment variables. Sometimes, issues in loading .env files can lead to authentication failures due to missing or incorrect configurations.

  3. Review Authentication Logic: Since the error occurs when attempting to create a brain, which requires authentication, closely examine the authentication logic in your application. This includes how tokens are handled, ensuring they're valid and not expired.

  4. Debugging and Error Logging: Enhance error handling and logging around the authentication process. This can provide clearer insights into what might be going wrong during the authentication phase.

  5. Check for Service Disruptions: Ensure there are no issues or outages with the authentication service you're using (e.g., Supabase) that might be affecting authentication operations.

If these steps do not resolve the issue, consider providing more specific error messages or logs from the authentication process. This additional information could be crucial in pinpointing the exact cause of the authentication failure.

#### Details **Sources** - [[Bug]: Error occurred while creating a brain](https://github.com/QuivrHQ/quivr/issues/1913) - [error message when asking question on localhost](https://github.com/QuivrHQ/quivr/issues/1766) - [[Bug]: Cant create brains locally](https://github.com/QuivrHQ/quivr/issues/1602) - [frontend/e2e/tests/createBrain.ts](https://github.com/QuivrHQ/quivr/blob/main/frontend/e2e/tests/createBrain.ts) - [frontend/lib/components/AddBrainModal/components/BrainTypeSelectionStep/BrainCatalogue/BrainCatalogue.tsx](https://github.com/QuivrHQ/quivr/blob/main/frontend/lib/components/AddBrainModal/components/BrainTypeSelectionStep/BrainCatalogue/BrainCatalogue.tsx) - [frontend/lib/components/AddBrainModal/components/CreateBrainStep/hooks/useBrainCreationApi.ts](https://github.com/QuivrHQ/quivr/blob/main/frontend/lib/components/AddBrainModal/components/CreateBrainStep/hooks/useBrainCreationApi.ts) - [frontend/lib/components/AddBrainModal/components/CreateBrainStep/CreateBrainStep.tsx](https://github.com/QuivrHQ/quivr/blob/main/frontend/lib/components/AddBrainModal/components/CreateBrainStep/CreateBrainStep.tsx) - [frontend/lib/api/brain/useBrainApi.ts](https://github.com/QuivrHQ/quivr/blob/main/frontend/lib/api/brain/useBrainApi.ts) - [backend/modules/brain/service/brain_authorization_service.py](https://github.com/QuivrHQ/quivr/blob/main/backend/modules/brain/service/brain_authorization_service.py)
**About Dosu** This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

StanGirard commented 2 months ago

Hey my friend, can you try to git pull and rerun the docker compose up ?

Or else, follow this procedure if on your own vps: https://docs.quivr.app/deployment/digital_ocean