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.
constai = genkit({...}); constchat = ai.chat(); // create a Session letresponse = awaitchat.send('hi'); // session/history aware conversation response = awaitchat.send('tell me a story');
Craete a separate chat conversation ("thread") within the given preamble.
constsession = ai.createSession({}); constlawyerChat = session.chat('lawyerThread', { system:'talk like a lawyer', }); constpirateChat = session.chat('pirateThread', { system:'talk like a pirate', }); awaitlawyerChat.send('tell me a joke'); awaitpirateChat.send('tell me a joke');
constsession = ai.createSession({}); constlawyerChat = session.chat('lawyerThread', { system:'talk like a lawyer', }); constpirateChat = session.chat('pirateThread', { system:'talk like a pirate', }); awaitlawyerChat.send('tell me a joke'); awaitpirateChat.send('tell me a joke');
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.