handles sillytavern using both camel and snake-cased parameters for gemini api

This commit is contained in:
nai-degen 2024-10-06 11:03:48 -05:00
parent 514d1b7e31
commit 161f5aba3e
3 changed files with 38 additions and 0 deletions

33
package-lock.json generated
View File

@ -49,6 +49,7 @@
"source-map-support": "^0.5.21", "source-map-support": "^0.5.21",
"stream-json": "^1.8.0", "stream-json": "^1.8.0",
"tiktoken": "^1.0.10", "tiktoken": "^1.0.10",
"tinyws": "^0.1.0",
"uuid": "^9.0.0", "uuid": "^9.0.0",
"zlib": "^1.0.5", "zlib": "^1.0.5",
"zod": "^3.22.3", "zod": "^3.22.3",
@ -6611,6 +6612,17 @@
"resolved": "https://registry.npmjs.org/tiktoken/-/tiktoken-1.0.14.tgz", "resolved": "https://registry.npmjs.org/tiktoken/-/tiktoken-1.0.14.tgz",
"integrity": "sha512-g5zd5r/DoH8Kw0fiYbYpVhb6WO8BHO1unXqmBBWKwoT17HwSounnDtMDFUKm2Pko8U47sjQarOe+9aUrnqmmTg==" "integrity": "sha512-g5zd5r/DoH8Kw0fiYbYpVhb6WO8BHO1unXqmBBWKwoT17HwSounnDtMDFUKm2Pko8U47sjQarOe+9aUrnqmmTg=="
}, },
"node_modules/tinyws": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/tinyws/-/tinyws-0.1.0.tgz",
"integrity": "sha512-6WQ2FlFM7qm6lAXxeKnzsAEfmnBHz5W5EwonNs52V0++YfK1IoCCAWM429afcChFE9BFrDgOFnq7ligaWMsa/A==",
"engines": {
"node": ">=12.4"
},
"peerDependencies": {
"ws": ">=8"
}
},
"node_modules/tmp": { "node_modules/tmp": {
"version": "0.0.33", "version": "0.0.33",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
@ -6945,6 +6957,27 @@
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="
}, },
"node_modules/ws": {
"version": "8.18.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz",
"integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==",
"peer": true,
"engines": {
"node": ">=10.0.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": ">=5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
},
"node_modules/xtend": { "node_modules/xtend": {
"version": "4.0.2", "version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",

View File

@ -59,6 +59,7 @@
"source-map-support": "^0.5.21", "source-map-support": "^0.5.21",
"stream-json": "^1.8.0", "stream-json": "^1.8.0",
"tiktoken": "^1.0.10", "tiktoken": "^1.0.10",
"tinyws": "^0.1.0",
"uuid": "^9.0.0", "uuid": "^9.0.0",
"zlib": "^1.0.5", "zlib": "^1.0.5",
"zod": "^3.22.3", "zod": "^3.22.3",

View File

@ -37,6 +37,10 @@ export const GoogleAIV1GenerateContentSchema = z
tools: z.array(z.object({})).max(0).optional(), tools: z.array(z.object({})).max(0).optional(),
safetySettings: SafetySettingsSchema, safetySettings: SafetySettingsSchema,
systemInstruction: GoogleAIV1ContentSchema.optional(), systemInstruction: GoogleAIV1ContentSchema.optional(),
// quick fix for SillyTavern, which uses camel case field names for everything
// except for system_instruction where it randomly uses snake case.
// google api evidently accepts either case.
"system_instruction": GoogleAIV1ContentSchema.optional(),
generationConfig: z generationConfig: z
.object({ .object({
temperature: z.number().min(0).max(2).optional(), temperature: z.number().min(0).max(2).optional(),