koishi-plugin-chatluna-google-gemini-adapter 1.2.8 → 1.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +10 -5
- package/lib/index.mjs +10 -5
- package/lib/utils.d.ts +4 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -185,11 +185,16 @@ function extractSystemMessages(messages) {
|
|
|
185
185
|
);
|
|
186
186
|
return [
|
|
187
187
|
{
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
parts: [
|
|
189
|
+
{
|
|
190
|
+
text: systemMessages.reduce((acc, cur) => {
|
|
191
|
+
acc.push(...cur.parts);
|
|
192
|
+
return acc;
|
|
193
|
+
}, []).map((part) => {
|
|
194
|
+
return partAsType(part).text;
|
|
195
|
+
}).join("\n\n\n")
|
|
196
|
+
}
|
|
197
|
+
]
|
|
193
198
|
},
|
|
194
199
|
messages.slice(messages.indexOf(lastSystemMessage))
|
|
195
200
|
];
|
package/lib/index.mjs
CHANGED
|
@@ -168,11 +168,16 @@ function extractSystemMessages(messages) {
|
|
|
168
168
|
);
|
|
169
169
|
return [
|
|
170
170
|
{
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
171
|
+
parts: [
|
|
172
|
+
{
|
|
173
|
+
text: systemMessages.reduce((acc, cur) => {
|
|
174
|
+
acc.push(...cur.parts);
|
|
175
|
+
return acc;
|
|
176
|
+
}, []).map((part) => {
|
|
177
|
+
return partAsType(part).text;
|
|
178
|
+
}).join("\n\n\n")
|
|
179
|
+
}
|
|
180
|
+
]
|
|
176
181
|
},
|
|
177
182
|
messages.slice(messages.indexOf(lastSystemMessage))
|
|
178
183
|
];
|
package/lib/utils.d.ts
CHANGED
|
@@ -3,7 +3,10 @@ import { StructuredTool } from '@langchain/core/tools';
|
|
|
3
3
|
import { ChatCompletionFunction, ChatCompletionResponseMessage, ChatCompletionResponseMessageRoleEnum, ChatPart } from './types';
|
|
4
4
|
import { Config } from '.';
|
|
5
5
|
export declare function langchainMessageToGeminiMessage(messages: BaseMessage[], model?: string): Promise<ChatCompletionResponseMessage[]>;
|
|
6
|
-
export declare function extractSystemMessages(messages: ChatCompletionResponseMessage[]): [
|
|
6
|
+
export declare function extractSystemMessages(messages: ChatCompletionResponseMessage[]): [
|
|
7
|
+
Omit<ChatCompletionResponseMessage, 'role'>,
|
|
8
|
+
ChatCompletionResponseMessage[]
|
|
9
|
+
];
|
|
7
10
|
export declare function partAsType<T extends ChatPart>(part: ChatPart): T;
|
|
8
11
|
export declare function partAsTypeCheck<T extends ChatPart>(part: ChatPart, check: (part: ChatPart & unknown) => boolean): T | undefined;
|
|
9
12
|
export declare function formatToolsToGeminiAITools(tools: StructuredTool[], config: Config, model: string): Record<string, any>;
|
package/package.json
CHANGED