Skip to content

Commit 7051a59

Browse files
EPMattcabljacGustolandiacoderabbitai[bot]pavelgj
authored
deps!: migrate plugins to genkit 0.9.0 (#157)
* chore(deps)!: run npm audit fix, upgrade openai plugin to genkit 0.9 RC * chore(deps)!: upgrade anthropic plugin to genkit RC * chore(deps)!: upgrade cohere plugin to genkit 0.9.0-dev.1 * chore(mistral)!: bump genkit to RC version * test(*): add first run at example apps for plugins * chore(examples): add gitignore to each example * docs(anthropic): add jsDoc comments back in * chore(*): organize imports * fix(*): update build script * Groq updated for 0.9 * @invertase/augment examples (#4) * feat: add embedding to cohere example * fix: make mistral embeddingTypes optional * feat: add embedding to openai example * chore: fix RC bump deps (#5) * chore(*): keep RC dependency compatible with stable release * fix(cohere): remove direct import of zod * @invertase/fix groq (#6) * chore: fix RC bump deps (#5) * chore(*): keep RC dependency compatible with stable release * fix(cohere): remove direct import of zod * fix(groq): amend model ref names * Update examples/anthropic/src/index.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix(cohere): amend type error in toCohereTool (#7) * docs(*): update plugin READMEs (#8) * Update examples/anthropic/package.json Co-authored-by: Pavel Jbanov <[email protected]> * fix(*): fix genkit dependencies * chore(*): reinstate and update dotprompt example * chore(*): update test CI * chore(*): add nx as dev dependency * bump genkit versions to 0.9.0, remove examples lockfiles * fix genkit plugin build * fix tests * remove empty npm test scripts --------- Co-authored-by: Jacob Cable <[email protected]> Co-authored-by: Gustavo Pedro Ricou <[email protected]> Co-authored-by: Jacob Cable <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Pavel Jbanov <[email protected]>
1 parent 25df5a1 commit 7051a59

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+12203
-8954
lines changed

.github/workflows/main.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Build & Test
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88

99
jobs:
1010
build-and-test:
@@ -15,17 +15,17 @@ jobs:
1515
node-version: [20.x]
1616

1717
steps:
18-
- uses: actions/checkout@v4
19-
- name: Use Node.js ${{ matrix.node-version }}
20-
uses: actions/setup-node@v4
21-
with:
22-
node-version: ${{ matrix.node-version }}
23-
cache: 'npm'
24-
- run: npm ci
25-
- run: npm run build
26-
- run: npm run test
27-
- name: SonarCloud Scan
28-
if: env.SONAR_TOKEN != null
29-
uses: SonarSource/sonarcloud-github-action@v2
30-
env:
31-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
18+
- uses: actions/checkout@v4
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
cache: 'npm'
24+
- run: npm ci --include=optional
25+
- run: npm run build
26+
- run: npm run test
27+
- name: SonarCloud Scan
28+
if: env.SONAR_TOKEN != null
29+
uses: SonarSource/sonarcloud-github-action@v2
30+
env:
31+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ lib/
66
plugins/.DS_Store
77
lerna-debug.log
88
.DS_Store
9+
.genkit

examples/.env.local renamed to examples/all-plugins/.env.example

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ COHERE_API_KEY=your-cohere-api-key
55
MISTRAL_API_KEY=your-mistral-api-key
66
AZURE_OPENAI_API_ENDPOINT=your-azure-openai-api-endpoint
77
AZURE_OPENAI_API_KEY=your-azure-openai-api-key
8-
AZURE_OPENAI_API_EMBEDDING_DEPLOYMENT_NAME=your-azure-openai-api-embedding-deployment-name
9-
8+
AZURE_OPENAI_API_EMBEDDING_DEPLOYMENT_NAME=your-azure-openai-api-embedding-deployment-name
File renamed without changes.

examples/all-plugins/package.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "genkit-plugins-examples",
3+
"version": "0.10.1",
4+
"description": "",
5+
"main": "lib/index.js",
6+
"private": true,
7+
"type": "commonjs",
8+
"scripts": {
9+
"init": "npm --prefix ../ install && npm --prefix ../ run build",
10+
"start": "node lib/index.js",
11+
"start:browser": "npx genkit start -o",
12+
"start:dev": "npm --prefix ../ run build && node lib/index.js",
13+
"compile": "npx tsc",
14+
"build": "npm run build:clean && npm run compile",
15+
"build:clean": "rm -rf ./lib",
16+
"build:watch": "npx tsc --watch",
17+
"genkit:dev": "cross-env GENKIT_ENV=dev npm run dev",
18+
"dev": "export GENKIT_RUNTIME_ID=$(openssl rand -hex 8) && node lib/index.js 2>&1"
19+
},
20+
"keywords": [],
21+
"author": "",
22+
"license": "ISC",
23+
"dependencies": {
24+
"genkit": "^0.9.0",
25+
"dotenv": "^16.4.5",
26+
"express": "^4.19.2",
27+
"genkitx-anthropic": "file:../../plugins/anthropic",
28+
"genkitx-azure-openai": "file:../../plugins/azure-openai",
29+
"genkitx-cohere": "file:../../plugins/cohere",
30+
"genkitx-groq": "file:../../plugins/groq",
31+
"genkitx-mistral": "file:../../plugins/mistral",
32+
"genkitx-openai": "file:../../plugins/openai"
33+
},
34+
"devDependencies": {
35+
"cross-env": "^7.0.3",
36+
"ts-node": "^10.9.2",
37+
"typescript": "^5.4.5"
38+
}
39+
}

examples/prompts/structuredInputOutput.prompt renamed to examples/all-plugins/prompts/structuredInputOutput.prompt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ output:
1414
occupation: string,
1515
fun_fact: string
1616
---
17-
Come up with a funny personal info for a {{animal}}, as if it was a person. Specify, name, surname, age, occupation, and a fun fact.
17+
Come up with a funny personal info for a {{animal}}, as if it was a person. Specify, name, surname, age, occupation, and a fun fact.

examples/src/index.ts renamed to examples/all-plugins/src/index.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
import 'dotenv/config';
22

3-
import { defineDotprompt, prompt } from '@genkit-ai/dotprompt';
4-
import { generate, definePrompt, defineTool } from '@genkit-ai/ai';
3+
import { Genkit } from 'genkit';
4+
// import { generate, definePrompt, defineTool } from '@genkit-ai/ai';
55

66
import { defineFlow, startFlowsServer } from '@genkit-ai/flow';
7-
import * as z from 'zod';
8-
9-
import { gpt4o } from 'genkitx-openai';
10-
import { initializeGenkit } from '@genkit-ai/core';
11-
import config from './genkit.config';
12-
import { llama3x70b } from 'genkitx-groq';
13-
14-
initializeGenkit(config);
157

8+
import { gpt4o, openAI } from 'genkitx-openai';
9+
import { genkit, z } from 'genkit';
10+
import groq, { llama3x70b } from 'genkitx-groq';
11+
import mistral from 'genkitx-mistral';
12+
import anthropic from 'genkitx-anthropic';
13+
import { cohere } from 'genkitx-cohere';
14+
const ai = genkit({
15+
plugins: [openAI(), groq(), cohere(), anthropic(), mistral()],
16+
promptDir: '../prompts',
17+
});
1618
// Define standard prompts
17-
const helloPrompt = definePrompt(
19+
const helloPrompt = ai.definePrompt(
1820
{
1921
name: 'helloPrompt',
20-
inputSchema: z.object({ name: z.string() }),
22+
input: {
23+
schema: z.object({ name: z.string() }),
24+
},
2125
},
2226
async (input) => {
2327
const promptText = `You are a helpful AI assistant named Walt.
@@ -31,7 +35,7 @@ const helloPrompt = definePrompt(
3135
);
3236

3337
// Tool definition
34-
const tool = defineTool(
38+
const tool = ai.defineTool(
3539
{
3640
name: 'myJoke',
3741
description: 'useful when you need a joke to tell.',
@@ -48,7 +52,7 @@ const tool = defineTool(
4852
// const customConfigPrompt = prompt('customConfig');
4953

5054
// Define a Dotprompt in code
51-
const codeDotPrompt = defineDotprompt(
55+
const codeDotPrompt = ai.definePrompt(
5256
{
5357
name: 'exampleDotPrompt',
5458
model: gpt4o,
@@ -85,12 +89,12 @@ export const myFlow = defineFlow(
8589
outputSchema: z.string(),
8690
},
8791
async (subject) => {
88-
const llmResponse = await generate({
92+
const llmResponse = await ai.generate({
8993
prompt: `Suggest an item for the menu of a ${subject} themed restaurant`,
9094
model: gpt4o,
9195
});
9296

93-
return llmResponse.text();
97+
return llmResponse.text;
9498
}
9599
);
96100
startFlowsServer();

0 commit comments

Comments
 (0)