@memberjunction/ai-gemini
Advanced tools
Comparing version 0.9.18 to 0.9.19
@@ -6,3 +6,3 @@ import { InputContent } from "@google/generative-ai"; | ||
constructor(apiKey: string); | ||
protected geminiMessageSpacing(messages: ChatMessage[]): ChatMessage[]; | ||
protected geminiMessageSpacing(messages: InputContent[]): InputContent[]; | ||
ChatCompletion(params: ChatParams): Promise<ChatResult>; | ||
@@ -9,0 +9,0 @@ SummarizeText(params: SummarizeParams): Promise<SummarizeResult>; |
@@ -27,9 +27,9 @@ "use strict"; | ||
const result = []; | ||
let lastRole = "assistant"; | ||
let lastRole = "model"; | ||
for (let i = 0; i < messages.length; i++) { | ||
if (messages[i].role === lastRole) { | ||
result.push({ | ||
role: "assistant", // we are using the ChatMessage type from the MJ package, so we need to use the role "assistant" instead of "model" | ||
role: "model", // we are using the ChatMessage type from the MJ package, so we need to use the role "assistant" instead of "model" | ||
// later on the role will be converted to "model" in the MapMJMessageToGeminiHistoryEntry method | ||
content: "OK" | ||
parts: "OK" | ||
}); | ||
@@ -50,6 +50,6 @@ } | ||
const model = GeminiLLM_1._gemini.getGenerativeModel({ model: params.model || "gemini-pro", generationConfig: config }); | ||
const allMessagesButLast = params.messages; //.slice(0, -1); | ||
const tempMessages = this.geminiMessageSpacing(allMessagesButLast); | ||
const convertedMessages = params.messages.map(m => GeminiLLM_1.MapMJMessageToGeminiHistoryEntry(m)); | ||
const tempMessages = this.geminiMessageSpacing(convertedMessages); | ||
const chat = model.startChat({ | ||
history: tempMessages.map(m => GeminiLLM_1.MapMJMessageToGeminiHistoryEntry(m)) | ||
history: tempMessages | ||
}); | ||
@@ -56,0 +56,0 @@ const latestMessage = params.messages[params.messages.length - 1].content; |
{ | ||
"name": "@memberjunction/ai-gemini", | ||
"version": "0.9.18", | ||
"version": "0.9.19", | ||
"description": "MemberJunction Wrapper for Google Gemini AI Models", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10494