softwaremill / sttp-openai

Apache License 2.0
41 stars 9 forks source link

JSON schema support #216

Closed mrdziuban closed 2 days ago

mrdziuban commented 1 week ago

Would you consider adding support for the json_schema response format? If so, I would be happy to take a stab at a pull request to add it. I would model it similarly to this: https://github.com/cequence-io/openai-scala-client/blob/master/openai-core/src/main/scala/io/cequence/openaiscala/domain/JsonSchema.scala

adamw commented 1 week ago

Sounds great!

As I understand, as a user I would be able to provide the JSON Schema, to which the response should adhere? An extension to this idea would be to derive a Tapir schema from a case class, and then serialize it as JSON Schema.

And a second extension to that would be to use e.g. jsoniter to deserialize the response to the desired object