mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Added ability to override request payload
This commit is contained in:
@ -82,7 +82,6 @@ export class TextCompletionService {
|
||||
*/
|
||||
static createRequestData({ stream = false, prompt, max_tokens, model, api_type, api_server, temperature, min_p, ...props }) {
|
||||
const payload = {
|
||||
...props,
|
||||
stream,
|
||||
prompt,
|
||||
max_tokens,
|
||||
@ -92,6 +91,7 @@ export class TextCompletionService {
|
||||
api_server: api_server ?? getTextGenServer(api_type),
|
||||
temperature,
|
||||
min_p,
|
||||
...props,
|
||||
};
|
||||
|
||||
// Remove undefined values to avoid API errors
|
||||
@ -391,7 +391,6 @@ export class ChatCompletionService {
|
||||
*/
|
||||
static createRequestData({ stream = false, messages, model, chat_completion_source, max_tokens, temperature, custom_url, reverse_proxy, proxy_password, ...props }) {
|
||||
const payload = {
|
||||
...props,
|
||||
stream,
|
||||
messages,
|
||||
model,
|
||||
@ -401,6 +400,9 @@ export class ChatCompletionService {
|
||||
custom_url,
|
||||
reverse_proxy,
|
||||
proxy_password,
|
||||
use_makersuite_sysprompt: true,
|
||||
claude_use_sysprompt: true,
|
||||
...props,
|
||||
};
|
||||
|
||||
// Remove undefined values to avoid API errors
|
||||
|
@ -306,9 +306,10 @@ export class ConnectionManagerRequestService {
|
||||
* @param {boolean?} [custom.includePreset=true]
|
||||
* @param {boolean?} [custom.includeInstruct=true]
|
||||
* @param {Partial<InstructSettings>?} [custom.instructSettings] Override instruct settings
|
||||
* @param {Record<string, any>} [overridePayload] - Override payload for the request
|
||||
* @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
|
||||
*/
|
||||
static async sendRequest(profileId, prompt, maxTokens, custom = this.defaultSendRequestParams) {
|
||||
static async sendRequest(profileId, prompt, maxTokens, custom = this.defaultSendRequestParams, overridePayload = {}) {
|
||||
const { stream, signal, extractData, includePreset, includeInstruct, instructSettings } = { ...this.defaultSendRequestParams, ...custom };
|
||||
|
||||
const context = SillyTavern.getContext();
|
||||
@ -338,6 +339,7 @@ export class ConnectionManagerRequestService {
|
||||
custom_url: profile['api-url'],
|
||||
reverse_proxy: proxyPreset?.url,
|
||||
proxy_password: proxyPreset?.password,
|
||||
...overridePayload,
|
||||
}, {
|
||||
presetName: includePreset ? profile.preset : undefined,
|
||||
}, extractData, signal);
|
||||
@ -354,6 +356,7 @@ export class ConnectionManagerRequestService {
|
||||
model: profile.model,
|
||||
api_type: selectedApiMap.type,
|
||||
api_server: profile['api-url'],
|
||||
...overridePayload,
|
||||
}, {
|
||||
instructName: includeInstruct ? profile.instruct : undefined,
|
||||
presetName: includePreset ? profile.preset : undefined,
|
||||
|
Reference in New Issue
Block a user