Optionaloptions: {Create a chat session with the provided options.
const session = ai.createSession({});
const chat = session.chat({
system: 'talk like a pirate',
})
let response = await chat.send('tell me a joke');
response = await chat.send('another one');
Create a chat session with the provided preamble.
const triageAgent = ai.definePrompt({
system: 'help the user triage a problem',
})
const session = ai.createSession({});
const chat = session.chat(triageAgent);
const { text } = await chat.send('my phone feels hot');
Optionaloptions: ChatOptions<I, S>Craete a separate chat conversation ("thread") within the given preamble.
const session = ai.createSession({});
const lawyerChat = session.chat('lawyerThread', {
system: 'talk like a lawyer',
});
const pirateChat = session.chat('pirateThread', {
system: 'talk like a pirate',
});
await lawyerChat.send('tell me a joke');
await pirateChat.send('tell me a joke');
Optionaloptions: ChatOptions<I, S>Craete a separate chat conversation ("thread").
const session = ai.createSession({});
const lawyerChat = session.chat('lawyerThread', {
system: 'talk like a lawyer',
});
const pirateChat = session.chat('pirateThread', {
system: 'talk like a pirate',
});
await lawyerChat.send('tell me a joke');
await pirateChat.send('tell me a joke');
Update messages for a given thread.
Update session state data by patching the existing state.
Partial state update that will be merged with existing state
Session encapsulates a statful execution environment for chat. Chat session executed within a session in this environment will have acesss to session session convesation history.