Skip to content

Conversation

@pavelgj
Copy link
Collaborator

@pavelgj pavelgj commented Jun 4, 2025

import { dynamicTool } from 'genkit';

const dynamicGablorkenTool = dynamicTool(
  {
    name: 'dynamicGablorkenTool',
    inputSchema: z.object({
      value: z.number(),
    }),
    description: 'can be used to calculate gablorken value',
  },
  async (input) => {
    return input.value * 3 - 4;
  }
);

const { text } = ai.generateStream({
  model: googleAI.model('gemini-2.0-flash'),
  tools: [dynamicGablorkenTool],
  prompt: `what is a gablorken of ${input}`,
});

also added global (Genkit instance level) context:

const ai = genkit({
  context: { something: 'extra' }
});

Checklist (if applicable):

@pavelgj pavelgj requested a review from mbleigh June 4, 2025 02:05
@pavelgj pavelgj marked this pull request as ready for review June 4, 2025 20:33
Modify the generate test to include a non-serializable object in the context. This ensures that the serialization logic handles such cases correctly.
@pavelgj pavelgj requested a review from ifielker June 5, 2025 14:14
@pavelgj pavelgj enabled auto-merge (squash) June 10, 2025 15:43
@pavelgj pavelgj merged commit 8fe3719 into main Jun 10, 2025
5 checks passed
@pavelgj pavelgj deleted the pj/js-unregistered-tools branch June 10, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants