openai-php / client

⚡️ OpenAI PHP is a supercharged community-maintained PHP API client that allows you to interact with OpenAI API.
MIT License
4.82k stars 499 forks source link

Object binding #277

Closed francisco-ltech closed 10 months ago

francisco-ltech commented 10 months ago

Description

Hi,

Is it possible to bind the response to a class?

E.g.: If I instruct a model to fetch specific information from a given content, e.g.; car name and car make. Is it possible to somehow do an automatic binding to a class containing those properties, e.g.: car_name and car_make? so that I don't have to fiddle with the extraction myself?

Steps To Reproduce

N/A

OpenAI PHP Client Version

N/A

PHP Version

N/A

Notes

No response

gehrisandro commented 10 months ago

No there is no direct way for this. You may can reach for function calling or json response types.

Closing this as it is not a bug and not directly related to this package.