GooeyAI / gooey-server

The core orchestration logic behind Gooey.AI
https://gooey.ai
Other
9 stars 2 forks source link

OpenAPI revisions for compatibility with Fern SDK generator #422

Open nikochiko opened 2 months ago

nikochiko commented 2 months ago

Change Summary

Q/A checklist


Executed in 1.15 secs fish external usr time 2.22 secs 86.00 micros 2.22 secs sys time 0.72 secs 613.00 micros 0.72 secs

To reduce import times, import libraries that take a long time inside the functions that use them instead of at the top of the file:
```python
def my_function():
    import pandas as pd
    ...

Legal Boilerplate

Look, I get it. The entity doing business as “Gooey.AI” and/or “Dara.network” was incorporated in the State of Delaware in 2020 as Dara Network Inc. and is gonna need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Dara Network Inc can use, modify, copy, and redistribute my contributions, under its choice of terms.


devxpy commented 1 month ago

do we really need this huge refactor of all enums?

devxpy commented 1 month ago

in any case if this can be broken up between the auth header and the enum that would be greatly appreciated

nikochiko commented 1 month ago

do we really need this huge refactor of all enums?

I used GooeyEnum where we were already using Enums or TextChoices per https://github.com/GooeyAI/gooey-server/discussions/393. That was an easier change and consistent with this discussion.

Where it was something else, I have used x-fern-type-name to not make new Enums.

devxpy commented 1 month ago

do we really need this huge refactor of all enums?

I used GooeyEnum where we were already using Enums or TextChoices per https://github.com/GooeyAI/gooey-server/discussions/393. That was an easier change and consistent with this discussion.

Where it was something else, I have used x-fern-type-name to not make new Enums.

Do we need the enum for fern to generate the literal | str type annotation? The enum refactor is nice but i think it would need a lot of testing to pass the review

nikochiko commented 1 month ago

By default, Fern will generate types like

CompareLLMSelectedModelsItem = typing.Union[typing.Literal[...], typing.Any]

Giving an Enum type lets us customize this name because fastapi will generate an OpenAPI component with the name inferred from the Enum's name.

By default, Literals will create a new OpenAPI Enum type for each input, and each will have its own different name.

nikochiko commented 1 month ago

Separated into this and https://github.com/GooeyAI/gooey-server/pull/465

nikochiko commented 1 month ago

The enum refactor is nice but i think it would need a lot of testing to pass the review

I have tested all the affected recipes in this PR - the UX names, API names, and their use in run & run_v2 - with different models and settings.

The nice thing with the refactor is that it doesn't affect how the value is stored in state, or passed down to the run method of each recipe. So that logic doesn't need any changes (I have still tested, and fixed where this wasn't the case). The automated tests already guarantee that all pages load with 200, sane_defaults work as before. We can continue testing like before manually after deployment, and also revert easily in case anything is breaking (because no migrations).