Skip to content
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

feat: expose defineFormat on Genkit instance, allowing to define custom formats #1365

Merged
merged 3 commits into from
Nov 22, 2024

Conversation

pavelgj
Copy link
Collaborator

@pavelgj pavelgj commented Nov 21, 2024

    ai.defineFormat(
      {
        name: 'banana',
        format: 'banana',
      },
      (schema) => {
        let instructions: string | undefined;

        if (schema) {
          instructions = `Output should be in banana format`;
        }

        return {
          parseChunk: (chunk) => {
            return `banana: ${chunk.content[0].text}`;
          },

          parseMessage: (message) => {
            return `banana: ${message.content[0].text}`;
          },

          instructions,
        };
      }
    );

@pavelgj pavelgj changed the title feat: expose defineFormat on Genkit instance, allowing to define custom format feat: expose defineFormat on Genkit instance, allowing to define custom formats Nov 21, 2024
@pavelgj pavelgj requested review from apascal07 and mbleigh and removed request for apascal07 November 21, 2024 15:31
@pavelgj pavelgj merged commit 0da9501 into main Nov 22, 2024
4 checks passed
@pavelgj pavelgj deleted the pj/exposeDefineFormat branch November 22, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants