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

Idea for custom built in types #7029

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

Conversation

jmaslek
Copy link
Contributor

@jmaslek jmaslek commented Feb 12, 2025

Idea that we can have some custom types for our ColDefs or whatever.

This one is meant to mimic the options endpoint one.

Example here:

from fastapi import FastAPI
from openbb_platform_api import OptionsEndpoint

app = FastAPI()


def get_names() -> list[str]:
    return ["John", "Jane", "Jim", "Jill"]


@app.get("/hello")
def hello(name: OptionsEndpoint(get_names)) -> str:
    return f"Hello, {name}!"

And it has the desired dropdown.

But we could essentiually create types for everything we tell folks to do.

Screenshot 2025-02-12 at 2 21 41 PM

@github-actions github-actions bot added enhancement Enhancement platform OpenBB Platform v4 PRs for v4 labels Feb 12, 2025
@deeleeramone
Copy link
Contributor

So when Workspace calls the function, what happens?

The parameter that is being defined in the API needs to correspond with what happens inside the function. For Workspace "optionsEndpoint", you need a defined route in the API for it to call and retrieve the list of [{"label": "some choice", "value": "actual_value"}].

Defining choices in this way does not make them dynamic, because, openapi.json is only read once. This is an equivalent to generating an enum of choices.

Dynamic choices are made by Workspace calling a defined API route with the rigid structure it expects, the widget parameter, itself, still needs to be of a primitive type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement platform OpenBB Platform v4 PRs for v4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants