Chatbot with Context
The gemini model is a generous and valuable resource to use if it comes to creating a product with AI that has both vision and text generation and without spending a penny is what we want.
To start remember to install the gemini plugin and have your Google Api key
Install Gemini
We started the installation of a package that will help you to implement the Gemin power in builderbot.
pnpm install @builderbot-plugins/gemini-layer
Context Example
Sometimes we don't want to place so many keywords or answers in validations of our flows, we want some freedom when it comes to responding, that's why we have the gemini plugin to respond based on a context
the context indicates between key value, the different scenarios in which the user may be when interacting with the assistant
context: It is the object that will contain all the necessary properties you need.
import { geminiLayer } from "@builderbot-plugins/gemini-layer"
export default async (...bot: any) => await geminiLayer({
context: {
name: 'your name',
email: 'your email',
summary: 'your summary'
// and more properties
}
}, bot)
Vision Example
Field | Description |
---|---|
vision | true |
visionPrompt | What you want the model to see |
image_path | The route where the image will be downloaded to be analyzed later |
cb | A callback that receives the same interface as addAction and which returns an answer in the state |
import { geminiLayer } from "@builderbot-plugins/gemini-layer"
const visionPrompt = 'Give me a brief summary of what you see in the picture'
export default async (...bot: any) => await geminiLayer({
vision: true,
visionPrompt,
image_path: './',
cb: async (_, { state, gotoFlow }) => {
const { answer } = state.getMyState()
console.log('answer about image', answer)
if (answer === 'anything else you want to validate') {
return gotoFlow('any flow you want to go')
}
}
}, bot)