-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Format Parsers #708
Comments
galihlprakoso
added a commit
to galihlprakoso/genkit
that referenced
this issue
Oct 23, 2024
3 tasks
mbleigh
added a commit
that referenced
this issue
Oct 28, 2024
Adds a new "Formatter" interface and re-implements existing JSON and text formatting with the new interface in addition to adding new "array" and "jsonl" format types.
mbleigh
added a commit
that referenced
this issue
Oct 30, 2024
mbleigh
added a commit
that referenced
this issue
Oct 30, 2024
mbleigh
added a commit
that referenced
this issue
Nov 6, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently the
output()
method on Genkit results attempts to leniently parse JSON based on whetherformat
is supplied or an output schema is present. There are a variety of reasons, however, that someone might want to have greater control over output parsing than this.Proposed is to extend the
format
option to instead be a registry of formatters with some defaults (text
andjson
at a minimum), provided. To define a custom format parser, developers would specify it something like so:The parser definition semantics should be flexible enough to handle many different scenarios, including:
parseChunk
must have the ability to returnnull
and not emit a chunk to the end user)To use a custom format is simple: just use the
format
option already in output.Work Plan
text
,json
,array
,jsonl
,enum
.generate
andgenerateStream
to play nicely with new streaming semantics.instructions?: boolean | string | (req: GenerateRequest) => string
for custom instructions control.constrained?: boolean
option to output for schema-constrained generation, and implement it for Gemini models.ai.defineFormat
to define custom formats.The text was updated successfully, but these errors were encountered: