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 CHANGED
@@ -185,11 +185,16 @@ function extractSystemMessages(messages) {
185
185
  );
186
186
  return [
187
187
  {
188
- role: "user",
189
- parts: systemMessages.reduce((acc, cur) => {
190
- acc.push(...cur.parts);
191
- return acc;
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
- role: "user",
172
- parts: systemMessages.reduce((acc, cur) => {
173
- acc.push(...cur.parts);
174
- return acc;
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[]): [ChatCompletionResponseMessage, 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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-chatluna-google-gemini-adapter",
3
3
  "description": "google-gemini adapter for chatluna",
4
- "version": "1.2.8",
4
+ "version": "1.2.10",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.mjs",
7
7
  "typings": "lib/index.d.ts",