update model options settings
This commit is contained in:
parent
f83e5b5a66
commit
49d52a5ffa
@ -290,9 +290,13 @@ const Chat = forwardRef<ChatRef, ChatProps>((props, ref) => {
|
||||
const stream = await streamResponse(
|
||||
chatModel,
|
||||
{
|
||||
model: chatModel.modelId,
|
||||
temperature: 0,
|
||||
messages: requestMessages,
|
||||
model: chatModel.modelId,
|
||||
max_tokens: settings.modelOptions.max_tokens,
|
||||
temperature: settings.modelOptions.temperature,
|
||||
// top_p: settings.modelOptions.top_p,
|
||||
// frequency_penalty: settings.modelOptions.frequency_penalty,
|
||||
// presence_penalty: settings.modelOptions.presence_penalty,
|
||||
stream: true,
|
||||
},
|
||||
{
|
||||
|
||||
@ -37,6 +37,7 @@ export class InfioSettingTab extends PluginSettingTab {
|
||||
const { containerEl } = this
|
||||
containerEl.empty()
|
||||
this.renderModelsSection(containerEl)
|
||||
this.renderModelParametersSection(containerEl)
|
||||
this.renderFilesSearchSection(containerEl)
|
||||
this.renderChatBehaviorSection(containerEl)
|
||||
this.renderDeepResearchSection(containerEl)
|
||||
@ -60,6 +61,90 @@ export class InfioSettingTab extends PluginSettingTab {
|
||||
);
|
||||
}
|
||||
|
||||
private renderModelParametersSection(containerEl: HTMLElement): void {
|
||||
new Setting(containerEl).setHeading().setName('Model parameters');
|
||||
new Setting(containerEl)
|
||||
.setName('Temperature')
|
||||
.setDesc('This parameter affects randomness in the sampling. Lower values result in more repetitive and deterministic responses. Higher temperatures will result in more unexpected or creative responses. Default: 0.0, please don\'t change this if you don\'t know what you are doing.')
|
||||
.addText((text) => {
|
||||
text
|
||||
.setValue(String(this.plugin.settings.modelOptions.temperature))
|
||||
.onChange(async (value) => {
|
||||
await this.plugin.setSettings({
|
||||
...this.plugin.settings,
|
||||
modelOptions: {
|
||||
...this.plugin.settings.modelOptions,
|
||||
temperature: parseFloat(value),
|
||||
},
|
||||
});
|
||||
})
|
||||
});
|
||||
new Setting(containerEl)
|
||||
.setName('TopP')
|
||||
.setDesc("Like the temperature parameter, the Top P parameter affects the randomness in sampling. Lowering the value will limit the model's token selection to likelier tokens while increasing the value expands the model's token selection with lower likelihood tokens. Default: 1, please don't change this if you don't know what you are doing.")
|
||||
.addText((text) => {
|
||||
text
|
||||
.setValue(String(this.plugin.settings.modelOptions.top_p))
|
||||
.onChange(async (value) => {
|
||||
await this.plugin.setSettings({
|
||||
...this.plugin.settings,
|
||||
modelOptions: {
|
||||
...this.plugin.settings.modelOptions,
|
||||
top_p: parseFloat(value),
|
||||
},
|
||||
});
|
||||
})
|
||||
});
|
||||
new Setting(containerEl)
|
||||
.setName('Frequency penalty')
|
||||
.setDesc('This parameter reduces the chance of repeating a token proportionally based on how often it has appeared in the text so far. This decreases the likelihood of repeating the exact same text in a response. Default: 0.25')
|
||||
.addText((text) => {
|
||||
text
|
||||
.setValue(String(this.plugin.settings.modelOptions.frequency_penalty))
|
||||
.onChange(async (value) => {
|
||||
await this.plugin.setSettings({
|
||||
...this.plugin.settings,
|
||||
modelOptions: {
|
||||
...this.plugin.settings.modelOptions,
|
||||
frequency_penalty: parseFloat(value),
|
||||
},
|
||||
});
|
||||
})
|
||||
});
|
||||
new Setting(containerEl)
|
||||
.setName('Presence penalty')
|
||||
.setDesc("This parameter reduces the chance of repeating any token that has appeared in the text so far. This increases the likelihood of introducing new topics in a response. Default: 2")
|
||||
.addText((text) => {
|
||||
text
|
||||
.setValue(String(this.plugin.settings.modelOptions.presence_penalty))
|
||||
.onChange(async (value) => {
|
||||
await this.plugin.setSettings({
|
||||
...this.plugin.settings,
|
||||
modelOptions: {
|
||||
...this.plugin.settings.modelOptions,
|
||||
presence_penalty: parseFloat(value),
|
||||
},
|
||||
});
|
||||
})
|
||||
});
|
||||
new Setting(containerEl)
|
||||
.setName('Max tokens')
|
||||
.setDesc("This parameter changes the maximum number of tokens the model is allowed to generate. Default: 4096")
|
||||
.addText((text) => {
|
||||
text
|
||||
.setValue(String(this.plugin.settings.modelOptions.max_tokens))
|
||||
.onChange(async (value) => {
|
||||
await this.plugin.setSettings({
|
||||
...this.plugin.settings,
|
||||
modelOptions: {
|
||||
...this.plugin.settings.modelOptions,
|
||||
max_tokens: parseInt(value),
|
||||
},
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
private renderFilesSearchSection(containerEl: HTMLElement): void {
|
||||
new Setting(containerEl).setHeading().setName('File search')
|
||||
new Setting(containerEl)
|
||||
@ -95,7 +180,7 @@ export class InfioSettingTab extends PluginSettingTab {
|
||||
}
|
||||
|
||||
private renderChatBehaviorSection(containerEl: HTMLElement): void {
|
||||
new Setting(containerEl).setHeading().setName('Chat Behavior');
|
||||
new Setting(containerEl).setHeading().setName('Chat behavior');
|
||||
new Setting(containerEl)
|
||||
.setName('Default mention for new chat')
|
||||
.setDesc('Choose the default file mention behavior when starting a new chat.')
|
||||
@ -111,7 +196,7 @@ export class InfioSettingTab extends PluginSettingTab {
|
||||
defaultMention: value as 'none' | 'current-file' | 'vault',
|
||||
});
|
||||
}),
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
renderModelsSection(containerEl: HTMLElement): void {
|
||||
@ -151,7 +236,7 @@ export class InfioSettingTab extends PluginSettingTab {
|
||||
}
|
||||
return t;
|
||||
})
|
||||
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Serper search engine')
|
||||
.setDesc('Choose the search engine to use for web search.')
|
||||
@ -395,16 +480,6 @@ export class InfioSettingTab extends PluginSettingTab {
|
||||
/>
|
||||
);
|
||||
|
||||
// Model parameters
|
||||
new Setting(containerEl).setName('Model parameters').setHeading();
|
||||
this.renderComponent(containerEl,
|
||||
<ModelParametersSettings
|
||||
settings={this.plugin.settings}
|
||||
updateSettings={updateSettings}
|
||||
errors={errors}
|
||||
/>
|
||||
);
|
||||
|
||||
// Preprocessing
|
||||
new Setting(containerEl).setName('Preprocessing').setHeading();
|
||||
this.renderComponent(containerEl,
|
||||
|
||||
@ -6,10 +6,10 @@ export const MIN_MAX_CHAR_LIMIT = 100;
|
||||
export const MAX_MAX_CHAR_LIMIT = 10000;
|
||||
export const MIN_MAX_TOKENS = 128;
|
||||
export const MAX_MAX_TOKENS = 8192;
|
||||
export const MIN_TEMPERATURE = 0;
|
||||
export const MAX_TEMPERATURE = 1;
|
||||
export const MIN_TOP_P = 0;
|
||||
export const MAX_TOP_P = 1;
|
||||
export const MIN_TEMPERATURE = 0.0;
|
||||
export const MAX_TEMPERATURE = 1.0;
|
||||
export const MIN_TOP_P = 0.0;
|
||||
export const MAX_TOP_P = 1.0;
|
||||
export const MIN_FREQUENCY_PENALTY = 0;
|
||||
export const MAX_FREQUENCY_PENALTY = 2;
|
||||
export const MIN_PRESENCE_PENALTY = 0;
|
||||
@ -34,17 +34,18 @@ export const ollamaApiSettingsSchema = z.object({
|
||||
|
||||
export const modelOptionsSchema = z.object({
|
||||
temperature: z.number()
|
||||
.min(0, { message: `Temperature must be at least ${MIN_TEMPERATURE}` })
|
||||
.max(1, { message: `Temperature must be at most ${MAX_TEMPERATURE}` }),
|
||||
.min(MIN_TEMPERATURE, { message: `Temperature must be at least ${MIN_TEMPERATURE}` }),
|
||||
top_p: z.number()
|
||||
.min(0, { message: `top_p must be greater than ${MIN_TOP_P}` })
|
||||
.max(1, { message: `top_p must be at most ${MAX_TOP_P}` }),
|
||||
.min(MIN_TOP_P, { message: `top_p must be greater than ${MIN_TOP_P}` })
|
||||
.max(MAX_TOP_P, { message: `top_p must be at most ${MAX_TOP_P}` }),
|
||||
frequency_penalty: z.number()
|
||||
.min(0, { message: `Frequency penalty must be at least ${MIN_FREQUENCY_PENALTY}` })
|
||||
.max(2, { message: `Frequency penalty must be at most ${MAX_FREQUENCY_PENALTY}` }),
|
||||
presence_penalty: z.number().min(MIN_PRESENCE_PENALTY, { message: `Presence penalty must be at least ${MIN_PRESENCE_PENALTY}` }).max(MAX_PRESENCE_PENALTY, { message: `Presence penalty must be at most ${MAX_PRESENCE_PENALTY}` }),
|
||||
.min(MIN_FREQUENCY_PENALTY, { message: `Frequency penalty must be at least ${MIN_FREQUENCY_PENALTY}` })
|
||||
.max(MAX_FREQUENCY_PENALTY, { message: `Frequency penalty must be at most ${MAX_FREQUENCY_PENALTY}` }),
|
||||
presence_penalty: z.number()
|
||||
.min(MIN_PRESENCE_PENALTY, { message: `Presence penalty must be at least ${MIN_PRESENCE_PENALTY}` })
|
||||
.max(MAX_PRESENCE_PENALTY, { message: `Presence penalty must be at most ${MAX_PRESENCE_PENALTY}` }),
|
||||
max_tokens: z.number().int()
|
||||
.min(MIN_MAX_TOKENS, { message: `max_tokens must be at least than ${MIN_MAX_TOKENS}` }).max(MAX_MAX_TOKENS, { message: `max_tokens must be at most ${MAX_MAX_TOKENS}` }),
|
||||
.min(MIN_MAX_TOKENS, { message: `max_tokens must be at least than ${MIN_MAX_TOKENS}` }),
|
||||
}).strict();
|
||||
|
||||
export const fewShotExampleSchema = z.object({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user