QuivrHQ / quivr

Your GenAI Second Brain 🧠 A personal 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 ! Local & Private alternative to OpenAI GPTs & ChatGPT powered by retrieval-augmented generation.

Home Page:https://quivr.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: [ERROR] models.databases.supabase.user_usage

weatherman6996 opened this issue · comments

What happened?

A bug happened!

BUG

What's this?

Relevant log output

backend-core  | [ERROR] models.databases.supabase.user_usage [user_usage.py:162]: {'code': 'XX000', 'details': None, 'hint': None, 'message': 'called `Result::unwrap()` on an `Err` value: InvalidPosition'}
backend-core  | [ERROR] models.databases.supabase.user_usage [user_usage.py:163]: Error while checking if user is a premium user. Stripe needs to be configured.
backend-core  | [ERROR] models.databases.supabase.user_usage [user_usage.py:166]: {'code': 'XX000', 'details': None, 'hint': None, 'message': 'called `Result::unwrap()` on an `Err` value: InvalidPosition'}

Twitter / LinkedIn details

No response

The errors you're encountering, specifically the 'InvalidPosition' error and the Stripe configuration error, point towards two distinct areas of concern in your code.

Starting with the 'InvalidPosition' error, this typically arises from a mismatch in data types or incorrect database function usage. It's crucial to ensure that the data types and values in your queries align with your Supabase database schema's expectations. Review the lines mentioned (162, 163, and 166) in your user_usage.py file for potential data mismatches or incorrect assumptions. The Supabase documentation can provide further guidance on structuring your queries and data types correctly.

Regarding the Stripe configuration error, it appears your user_usage.py file's check_if_is_premium_user method attempts to determine a user's premium status based on their Stripe subscription. However, the integration with Stripe to fetch subscription details isn't shown in the provided code. You'd typically use Stripe's Python SDK for this purpose. Ensure your Stripe API keys are correctly configured and that you're using the Stripe Python SDK to make API calls for fetching subscription status.

Here's a basic example of how you might use Stripe's Python SDK to check a user's subscription status:

import stripe

stripe.api_key = "your_stripe_api_key"

def check_stripe_subscription(customer_id):
    subscriptions = stripe.Subscription.list(customer=customer_id, status='active')
    for subscription in subscriptions.auto_paging_iter():
        if subscription.status == "active":
            return True
    return False

This function should be integrated into your check_subscription_validity method or another suitable place in your user_usage.py file, replacing placeholder logic with actual Stripe API calls. This requires having the Stripe Python SDK installed and configured with your Stripe API keys. For more details on using the SDK, refer to the Stripe Python SDK documentation.

Regarding the similar issue you found, it seems the error related to Stripe not being implemented can be safely ignored as it doesn't affect anything, according to the response in the issue.

If you need further clarification or have more questions, feel free to ask.

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.

This is normal because you don't have the stripe implement. It doesn't affect your usage :)