diff --git a/js/testapps/dev-ui-gallery/package.json b/js/testapps/dev-ui-gallery/package.json index 140915cb8b..447399e3c2 100644 --- a/js/testapps/dev-ui-gallery/package.json +++ b/js/testapps/dev-ui-gallery/package.json @@ -20,16 +20,16 @@ "dependencies": { "@genkit-ai/ai": "workspace:*", "@genkit-ai/core": "workspace:*", - "@genkit-ai/dotprompt": "workspace:*", - "@genkit-ai/flow": "workspace:*", - "genkitx-chromadb": "workspace:*", "@genkit-ai/dev-local-vectorstore": "workspace:*", + "@genkit-ai/dotprompt": "workspace:*", + "@genkit-ai/evaluator": "workspace:*", "@genkit-ai/firebase": "workspace:*", + "@genkit-ai/flow": "workspace:*", "@genkit-ai/googleai": "workspace:*", + "@genkit-ai/vertexai": "workspace:*", + "genkitx-chromadb": "workspace:*", "genkitx-ollama": "workspace:*", "genkitx-pinecone": "workspace:*", - "@genkit-ai/evaluator": "workspace:*", - "@genkit-ai/vertexai": "workspace:*", "zod": "^3.22.4" } } diff --git a/js/testapps/dev-ui-gallery/prompts/dotprompt-hello.first-last-name.prompt b/js/testapps/dev-ui-gallery/prompts/hello.first-last-name.prompt similarity index 79% rename from js/testapps/dev-ui-gallery/prompts/dotprompt-hello.first-last-name.prompt rename to js/testapps/dev-ui-gallery/prompts/hello.first-last-name.prompt index 5e1a8ed410..c374518534 100644 --- a/js/testapps/dev-ui-gallery/prompts/dotprompt-hello.first-last-name.prompt +++ b/js/testapps/dev-ui-gallery/prompts/hello.first-last-name.prompt @@ -1,5 +1,5 @@ --- -model: googleai/gemini-pro +model: googleai/gemini-1.5-flash-latest input: schema: firstName: string diff --git a/js/testapps/dev-ui-gallery/prompts/dotprompt-hello.history.prompt b/js/testapps/dev-ui-gallery/prompts/hello.history.prompt similarity index 95% rename from js/testapps/dev-ui-gallery/prompts/dotprompt-hello.history.prompt rename to js/testapps/dev-ui-gallery/prompts/hello.history.prompt index 23050fae2f..bde3010498 100644 --- a/js/testapps/dev-ui-gallery/prompts/dotprompt-hello.history.prompt +++ b/js/testapps/dev-ui-gallery/prompts/hello.history.prompt @@ -1,5 +1,5 @@ --- -model: googleai/gemini-1.5-pro-latest +model: googleai/gemini-1.5-flash-latest config: maxOutputTokens: 2048 temperature: 0.6 diff --git a/js/testapps/dev-ui-gallery/prompts/dotprompt-hello.json-output.prompt b/js/testapps/dev-ui-gallery/prompts/hello.json-output.prompt similarity index 80% rename from js/testapps/dev-ui-gallery/prompts/dotprompt-hello.json-output.prompt rename to js/testapps/dev-ui-gallery/prompts/hello.json-output.prompt index 539963a92b..05010f9469 100644 --- a/js/testapps/dev-ui-gallery/prompts/dotprompt-hello.json-output.prompt +++ b/js/testapps/dev-ui-gallery/prompts/hello.json-output.prompt @@ -1,5 +1,5 @@ --- -model: googleai/gemini-pro +model: googleai/gemini-1.5-flash-latest input: schema: name: string diff --git a/js/testapps/dev-ui-gallery/prompts/dotprompt-hello.prompt b/js/testapps/dev-ui-gallery/prompts/hello.prompt similarity index 93% rename from js/testapps/dev-ui-gallery/prompts/dotprompt-hello.prompt rename to js/testapps/dev-ui-gallery/prompts/hello.prompt index 4f8921a638..afc6519318 100644 --- a/js/testapps/dev-ui-gallery/prompts/dotprompt-hello.prompt +++ b/js/testapps/dev-ui-gallery/prompts/hello.prompt @@ -1,5 +1,5 @@ --- -model: googleai/gemini-pro +model: googleai/gemini-1.5-flash-latest config: maxOutputTokens: 2048 temperature: 0.6 diff --git a/js/testapps/dev-ui-gallery/prompts/dotprompt-hello.system.prompt b/js/testapps/dev-ui-gallery/prompts/hello.system.prompt similarity index 89% rename from js/testapps/dev-ui-gallery/prompts/dotprompt-hello.system.prompt rename to js/testapps/dev-ui-gallery/prompts/hello.system.prompt index d923b9402f..074dfed2bd 100644 --- a/js/testapps/dev-ui-gallery/prompts/dotprompt-hello.system.prompt +++ b/js/testapps/dev-ui-gallery/prompts/hello.system.prompt @@ -1,5 +1,5 @@ --- -model: googleai/gemini-1.5-pro-latest +model: googleai/gemini-1.5-flash-latest config: maxOutputTokens: 2048 temperature: 0.6 diff --git a/js/testapps/dev-ui-gallery/prompts/tools.prompt b/js/testapps/dev-ui-gallery/prompts/tools.prompt new file mode 100644 index 0000000000..cf4c22c85d --- /dev/null +++ b/js/testapps/dev-ui-gallery/prompts/tools.prompt @@ -0,0 +1,28 @@ +--- +model: googleai/gemini-1.5-flash-latest +config: + maxOutputTokens: 2048 + temperature: 0.6 + topK: 16 + topP: 0.95 + stopSequences: + - STAWP! + safetySettings: + - category: HARM_CATEGORY_HATE_SPEECH + threshold: BLOCK_ONLY_HIGH + - category: HARM_CATEGORY_DANGEROUS_CONTENT + threshold: BLOCK_ONLY_HIGH + - category: HARM_CATEGORY_HARASSMENT + threshold: BLOCK_ONLY_HIGH + - category: HARM_CATEGORY_SEXUALLY_EXPLICIT + threshold: BLOCK_ONLY_HIGH +input: + schema: + city: string + default: + city: Cambridge, MA +tools: + - getWeather +--- + +Is it raining in {{city}}? diff --git a/js/testapps/dev-ui-gallery/src/index.ts b/js/testapps/dev-ui-gallery/src/index.ts index 86aea503ee..21857ebd5e 100644 --- a/js/testapps/dev-ui-gallery/src/index.ts +++ b/js/testapps/dev-ui-gallery/src/index.ts @@ -68,7 +68,9 @@ export default configureGenkit({ firebase(), // model providers - googleAI({ apiVersion: ['v1', 'v1beta'] }), + googleAI({ + apiVersion: ['v1', 'v1beta'], + }), ollama({ models: [ { name: 'llama2' }, diff --git a/js/testapps/dev-ui-gallery/src/main/prompts.ts b/js/testapps/dev-ui-gallery/src/main/prompts.ts index 38b7432f3b..7904c03780 100644 --- a/js/testapps/dev-ui-gallery/src/main/prompts.ts +++ b/js/testapps/dev-ui-gallery/src/main/prompts.ts @@ -99,7 +99,7 @@ defineFlow( outputSchema: z.string(), streamSchema: z.string(), }, - async (input, streamingCallback) => { + async (input) => { const codeDefinedPrompt = await prompt('codeDefinedPrompt'); const response = await codeDefinedPrompt.generate({ input, @@ -113,7 +113,7 @@ defineFlow( // Dotprompt file - text output // -prompt('dotprompt-hello').then((prompt) => { +prompt('hello').then((prompt) => { defineFlow( { name: 'flowDotPrompt', @@ -128,7 +128,7 @@ prompt('dotprompt-hello').then((prompt) => { // Dotprompt file - variant, text output // -prompt('dotprompt-hello', { variant: 'first-last-name' }).then((prompt) => { +prompt('hello', { variant: 'first-last-name' }).then((prompt) => { defineFlow( { name: 'flowDotPromptVariant', @@ -143,7 +143,7 @@ prompt('dotprompt-hello', { variant: 'first-last-name' }).then((prompt) => { // Dotprompt file - json output // -prompt('dotprompt-hello', { variant: 'json-output' }).then((prompt) => { +prompt('hello', { variant: 'json-output' }).then((prompt) => { defineFlow( { name: 'flowDotPromptJsonOutput', @@ -154,7 +154,7 @@ prompt('dotprompt-hello', { variant: 'json-output' }).then((prompt) => { ); }); -prompt('dotprompt-hello', { variant: 'system' }).then((prompt) => { +prompt('hello', { variant: 'system' }).then((prompt) => { defineFlow( { name: 'flowDotPromptSystemMessage', @@ -165,7 +165,7 @@ prompt('dotprompt-hello', { variant: 'system' }).then((prompt) => { ); }); -prompt('dotprompt-hello', { variant: 'history' }).then((prompt) => { +prompt('hello', { variant: 'history' }).then((prompt) => { defineFlow( { name: 'flowDotPromptHistory', diff --git a/js/testapps/dev-ui-gallery/src/main/tools.ts b/js/testapps/dev-ui-gallery/src/main/tools.ts index 4a8730ef9b..1e897e51d1 100644 --- a/js/testapps/dev-ui-gallery/src/main/tools.ts +++ b/js/testapps/dev-ui-gallery/src/main/tools.ts @@ -34,3 +34,15 @@ defineTool( }; } ); + +defineTool( + { + name: 'getTime', + description: 'Get the current time', + inputSchema: z.object({ timezone: z.string().optional() }), + outputSchema: z.object({ time: z.number() }), + }, + async (input) => { + return { time: Date.now() }; + } +);