firebase / genkit

An open source framework for building AI-powered apps with familiar code-centric patterns. Genkit makes it easy to develop, integrate, and test AI features with observability and evaluations. Genkit works with various models and platforms.
Apache License 2.0
729 stars 107 forks source link

[JS] fix genkitx-* plugins for `next` (0.9) release #1088

Open pavelgj opened 2 weeks ago

pavelgj commented 2 weeks ago

Plugin migration guide:

Update deps:

Before:

  "dependencies": {
   ...
    "zod": "^3.23.8"
  },
  "peerDependencies": {
    "@genkit-ai/ai": "^0.5.0",
    "@genkit-ai/core": "^0.5.0"
  },

After:

  "dependencies": {
    ...
  },
  "peerDependencies": {
    "genkit": "^0.9 | ^1.0",
  },

Note that dependency on zod is gone. Zod is now reexported via genkit package. Import it from there. See below.

until 0.9 is published may need:

  "dependencies": {
    ...
  },
  "peerDependencies": {
    "genkit": ">0.9.0-dev.0 | ^0.9 | ^1.0",
  },

Before:

import { genkitPlugin, type Plugin } from '@genkit-ai/core';
import { defineModel } from '@genkit-ai/ai/model';
import { defineEmbedder } from '@genkit-ai/ai/embedder';
import { z } from 'zod';

export const myPlugin: Plugin<[MyPluginOptions] | []> = genkitPlugin(
  'myPlugin',
  async (options?: MyPluginOptions) => {
    return {
      models:[defineModel(...), defineModel(...) ],
      embedders: [ defineEmbedder(...), defineEmbedder(...) ],
    };
  }
);

After:

import { Genkit, z } from 'genkit';
import { GenkitPlugin, genkitPlugin } from 'genkit/plugin';

export function myPlugin(options?: MyPluginOptions) {
  return genkitPlugin('myPlugin', async (ai: Genkit) => {
    ai.defineModel(...);
    ai.defineEmbedder(...)
    // ....
  });
}
pavelgj commented 1 week ago

@cabljac genkit@0.9.0-dev.1 is published to npm, that should unblock plugin conversion work.

https://www.npmjs.com/package/genkit/v/0.9.0-dev.1

pavelgj commented 1 week ago

I also added migration instructions to the description.

cabljac commented 1 week ago

and the main ones are OpenAI, Anthropic, Cohere?