const textModel = 'gemini-1.5-pro-preview-0409';
function initVertex() {
const vertex_ai = new VertexAI({ project: project, location: location });
return vertex_ai.preview.getGenerativeModel({
model: textModel,
safetySettings: [
{ category: HarmCategory.HARM_CATEGORY_HATE_SPEECH, threshold: HarmBlockThreshold.BLOCK_NONE },
{ category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT, threshold: HarmBlockThreshold.BLOCK_NONE },
{ category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT, threshold: HarmBlockThreshold.BLOCK_NONE },
{ category: HarmCategory.HARM_CATEGORY_HARASSMENT, threshold: HarmBlockThreshold.BLOCK_NONE }
],
});
}
export async function startChat(question: string) {
const model = initVertex();
const chat = model.startChat();
const result = await chat.sendMessage(question);
return result.response.candidates?.at(0)?.content.parts.at(0)?.text;
}
Hi,
I'm using Vertex AI for a project of mine. Basically, I have a Google Cloud Function to get the generated text from the model. The problem is each time the function is called a new chat starts and the history of the previous chat is gone. Is there a way for me to use chat history as context or any other way for me use the chat history. I do save the chat history in document currently.
Thank you