dottxt-ai / outlines

Structured Text Generation
https://dottxt-ai.github.io/outlines/
Apache License 2.0
9.57k stars 490 forks source link

Add Gemini integration #1243

Open rlouf opened 2 weeks ago

rlouf commented 2 weeks ago

This PR provides a thin wrapper around the Gemini client. Gemini provides structured generation by accepting the following to define output types:

This integration is already fairly complex:

  1. We need to define a new Choice output type to handle the Enum output type;
  2. The Gemini SDK does not accept JSON Schema string. Json thus needs to keep track of the original definition object. We should thus add a method to translate the definition object to JSON Schema instead of translating during initialization.
  3. The Gemini SDK also accepts TypedDicts
  4. The Gemini SDK accepts List type with arguments.

TODO

Builds on #1240.