Added ability to override request payload
| @@ -82,7 +82,6 @@ export class TextCompletionService { | |||
| 82 | */ | 82 | */ |
| 83 | static createRequestData({ stream = false, prompt, max_tokens, model, api_type, api_server, temperature, min_p, ...props }) { | 83 | static createRequestData({ stream = false, prompt, max_tokens, model, api_type, api_server, temperature, min_p, ...props }) { |
| 84 | const payload = { | 84 | const payload = { |
| 85 | ...props, | ||
| 86 | stream, | 85 | stream, |
| 87 | prompt, | 86 | prompt, |
| 88 | max_tokens, | 87 | max_tokens, |
| @@ -92,6 +91,7 @@ export class TextCompletionService { | |||
| 92 | api_server: api_server ?? getTextGenServer(api_type), | 91 | api_server: api_server ?? getTextGenServer(api_type), |
| 93 | temperature, | 92 | temperature, |
| 94 | min_p, | 93 | min_p, |
| 94 | ...props, | ||
| 95 | }; | 95 | }; |
| 96 | 96 | ||
| 97 | // Remove undefined values to avoid API errors | 97 | // Remove undefined values to avoid API errors |
| @@ -391,7 +391,6 @@ export class ChatCompletionService { | |||
| 391 | */ | 391 | */ |
| 392 | static createRequestData({ stream = false, messages, model, chat_completion_source, max_tokens, temperature, custom_url, reverse_proxy, proxy_password, ...props }) { | 392 | static createRequestData({ stream = false, messages, model, chat_completion_source, max_tokens, temperature, custom_url, reverse_proxy, proxy_password, ...props }) { |
| 393 | const payload = { | 393 | const payload = { |
| 394 | ...props, | ||
| 395 | stream, | 394 | stream, |
| 396 | messages, | 395 | messages, |
| 397 | model, | 396 | model, |
| @@ -401,6 +400,9 @@ export class ChatCompletionService { | |||
| 401 | custom_url, | 400 | custom_url, |
| 402 | reverse_proxy, | 401 | reverse_proxy, |
| 403 | proxy_password, | 402 | proxy_password, |
| 403 | use_makersuite_sysprompt: true, | ||
| 404 | claude_use_sysprompt: true, | ||
| 405 | ...props, | ||
| 404 | }; | 406 | }; |
| 405 | 407 | ||
| 406 | // Remove undefined values to avoid API errors | 408 | // Remove undefined values to avoid API errors |
| @@ -306,9 +306,10 @@ export class ConnectionManagerRequestService { | |||
| 306 | * @param {boolean?} [custom.includePreset=true] | 306 | * @param {boolean?} [custom.includePreset=true] |
| 307 | * @param {boolean?} [custom.includeInstruct=true] | 307 | * @param {boolean?} [custom.includeInstruct=true] |
| 308 | * @param {Partial<InstructSettings>?} [custom.instructSettings] Override instruct settings | 308 | * @param {Partial<InstructSettings>?} [custom.instructSettings] Override instruct settings |
| 309 | * @param {Record<string, any>} [overridePayload] - Override payload for the request | ||
| 309 | * @returns {Promise<import('../custom-request.js').ExtractedData | (() => AsyncGenerator<import('../custom-request.js').StreamResponse>)>} If not streaming, returns extracted data; if streaming, returns a function that creates an AsyncGenerator | 310 | * @returns {Promise<import('../custom-request.js').ExtractedData | (() => AsyncGenerator<import('../custom-request.js').StreamResponse>)>} If not streaming, returns extracted data; if streaming, returns a function that creates an AsyncGenerator |
| 310 | */ | 311 | */ |
| 311 | static async sendRequest(profileId, prompt, maxTokens, custom = this.defaultSendRequestParams) { | 312 | static async sendRequest(profileId, prompt, maxTokens, custom = this.defaultSendRequestParams, overridePayload = {}) { |
| 312 | const { stream, signal, extractData, includePreset, includeInstruct, instructSettings } = { ...this.defaultSendRequestParams, ...custom }; | 313 | const { stream, signal, extractData, includePreset, includeInstruct, instructSettings } = { ...this.defaultSendRequestParams, ...custom }; |
| 313 | 314 | ||
| 314 | const context = SillyTavern.getContext(); | 315 | const context = SillyTavern.getContext(); |
| @@ -338,6 +339,7 @@ export class ConnectionManagerRequestService { | |||
| 338 | custom_url: profile['api-url'], | 339 | custom_url: profile['api-url'], |
| 339 | reverse_proxy: proxyPreset?.url, | 340 | reverse_proxy: proxyPreset?.url, |
| 340 | proxy_password: proxyPreset?.password, | 341 | proxy_password: proxyPreset?.password, |
| 342 | ...overridePayload, | ||
| 341 | }, { | 343 | }, { |
| 342 | presetName: includePreset ? profile.preset : undefined, | 344 | presetName: includePreset ? profile.preset : undefined, |
| 343 | }, extractData, signal); | 345 | }, extractData, signal); |
| @@ -354,6 +356,7 @@ export class ConnectionManagerRequestService { | |||
| 354 | model: profile.model, | 356 | model: profile.model, |
| 355 | api_type: selectedApiMap.type, | 357 | api_type: selectedApiMap.type, |
| 356 | api_server: profile['api-url'], | 358 | api_server: profile['api-url'], |
| 359 | ...overridePayload, | ||
| 357 | }, { | 360 | }, { |
| 358 | instructName: includeInstruct ? profile.instruct : undefined, | 361 | instructName: includeInstruct ? profile.instruct : undefined, |
| 359 | presetName: includePreset ? profile.preset : undefined, | 362 | presetName: includePreset ? profile.preset : undefined, |