michaelmagan / hydraai

a dev tool for generative UI that adapts to user context in real-time
https://usehydra.ai
MIT License
114 stars 8 forks source link

WIP: Add JSON schemas for all OpenAI requests #30

Open Antel0pe opened 3 weeks ago

Antel0pe commented 3 weeks ago

Added JSON Schemas for

Modified API call to require these schemas be included

Antel0pe commented 3 weeks ago

Running into bit of an error here and I believe it is because of this option: https://github.com/Antel0pe/hydraai/blob/e5ffbef100f2de372c56132c91f90427a36b4ddc/package/src/hydra-ai/ai-service.ts#L31

When it's not included, no error. When it IS included I get the following error: "open ai Internal error: Error: 400 Invalid schema for response_format 'generateSpecifiedComponentSchema': In context=('properties', 'props'), 'additionalProperties' is required to be supplied and to be false."

The .passthrough option says that you can include any additional properties you need with this schema and that is being used by chatgpt to supply the component props values.

Since before my commits, this schema+option was given in a string along with the request, it didn't cause a problem. Now that I'm using Structured Output and demanding the output be given with this schema option, it's giving an error that I can't ask it to specify additional properties in the response.

The problem I'm currently in is dynamically defining the zod schema according to the component prop definitions so that we don't need the passthrough option and can avoid the error... which looks pretty close to this: https://github.com/Antel0pe/hydraai/blob/e5ffbef100f2de372c56132c91f90427a36b4ddc/package/src/hydra-ai/ai-service.ts#L319

michaelmagan commented 2 days ago

hi antelope can you help me understand what this is for? also mind rebasing with latest commits?