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

[Feature] Set provider fallback based on credentials #6446

Merged
merged 31 commits into from
May 29, 2024

Conversation

montezdesousa
Copy link
Contributor

@montezdesousa montezdesousa commented May 21, 2024

  1. Why?

    • First time users are immediately blocked if they don't setup credentials before using openbb
    • v3 used to have a sources priority configuration
  2. What?

Create a provider fallback mechanism that checks if required credentials are set before using a given provider.

The priority is the following:

I. Provider specified in the command (if you have no credentials it will display the same message as before)

obb.equity.price.quote("AAPL", provider="fmp") -> "fmp"

II. Configured priority list (or just 1 provider as before)

{
    "credentials": {},
    "preferences": {},
    "defaults": {
        "commands": {
            # 1 provider
            "equity.price.historical": { "provider": "fmp" },
            # priority list
            "equity.price.quote": { "provider": ["foo", "bar", "fmp"] }
        }
    }
}
obb.equity.price.historical("AAPL") -> "fmp"
obb.equity.price.quote("AAPL") -> "fmp" (tries "foo" and "bar" first)

III. Default priority is the list of providers for the command, sorted alphabetically

obb.equity.price.quote("AAPL") -> "yfinance" (tries "fmp" and "intrinio" first or other providers if they are installed)

IV. Raises exception

{
    "credentials": {},
    "preferences": {},
    "defaults": {
        "commands": {
            "equity.price.quote": { "provider": ["foo", "bar", "baz"] }
        }
    }
}
obb.equity.price.quote("AAPL")

OpenBBError: 
[Error] -> Provider fallback failed, please specify the provider or update credentials.
[Providers]
  * 'foo' -> not found
  * 'bar' -> not found
  * 'baz' -> not found
  • Replaced routes by commands in the Defaults configuration class, since this feature is relevant to Python users only. Routes is an API concept. Will keep it as alias, accept slash split commands and set deprecation warning.
  1. Impact:

    • Reduces friction for first time users. If the command supports a provider without credential it will be used, no setup needed.
    • LLMs can rely on configuration or just fallback to whatever provider works.
  2. Testing Done:

    • Examples above and some combinations

@github-actions github-actions bot added enhancement Enhancement platform OpenBB Platform v4 PRs for v4 labels May 21, 2024
@montezdesousa montezdesousa marked this pull request as ready for review May 22, 2024 12:08
@montezdesousa montezdesousa added the feat M Medium T-Shirt size feature label May 22, 2024
Copy link
Contributor

@IgorWounds IgorWounds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could wait for the docs to be merged here so we write about it.

@montezdesousa montezdesousa added this pull request to the merge queue May 29, 2024
Merged via the queue into develop with commit 01a71a8 May 29, 2024
9 checks passed
@IgorWounds IgorWounds deleted the feature/provider-fallbacks branch May 30, 2024 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement feat M Medium T-Shirt size feature platform OpenBB Platform v4 PRs for v4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants