Merge branch 'ChatGPTNextWeb:main' into main
This commit is contained in:
commit
c45cab1e98
|
@ -99,7 +99,7 @@ export const Google = {
|
|||
|
||||
export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lang
|
||||
export const DEFAULT_SYSTEM_TEMPLATE = `
|
||||
You are ChatGPT, a large language model trained by OpenAI.
|
||||
You are ChatGPT, a large language model trained by {{ServiceProvider}}.
|
||||
Knowledge cutoff: {{cutoff}}
|
||||
Current model: {{model}}
|
||||
Current time: {{time}}
|
||||
|
@ -115,6 +115,9 @@ export const KnowledgeCutOffDate: Record<string, string> = {
|
|||
"gpt-4-1106-preview": "2023-04",
|
||||
"gpt-4-0125-preview": "2023-04",
|
||||
"gpt-4-vision-preview": "2023-04",
|
||||
// After improvements,
|
||||
// it's now easier to add "KnowledgeCutOffDate" instead of stupid hardcoding it, as was done previously.
|
||||
"gemini-pro": "2023-12",
|
||||
};
|
||||
|
||||
export const DEFAULT_MODELS = [
|
||||
|
|
|
@ -6,6 +6,7 @@ import { ModelConfig, ModelType, useAppConfig } from "./config";
|
|||
import { createEmptyMask, Mask } from "./mask";
|
||||
import {
|
||||
DEFAULT_INPUT_TEMPLATE,
|
||||
DEFAULT_MODELS,
|
||||
DEFAULT_SYSTEM_TEMPLATE,
|
||||
KnowledgeCutOffDate,
|
||||
ModelProvider,
|
||||
|
@ -99,10 +100,17 @@ function countMessages(msgs: ChatMessage[]) {
|
|||
}
|
||||
|
||||
function fillTemplateWith(input: string, modelConfig: ModelConfig) {
|
||||
let cutoff =
|
||||
KnowledgeCutOffDate[modelConfig.model] ?? KnowledgeCutOffDate.default;
|
||||
const cutoff = KnowledgeCutOffDate[modelConfig.model] ?? KnowledgeCutOffDate.default;
|
||||
// Find the model in the DEFAULT_MODELS array that matches the modelConfig.model
|
||||
const modelInfo = DEFAULT_MODELS.find(m => m.name === modelConfig.model);
|
||||
if (!modelInfo) {
|
||||
throw new Error(`Model ${modelConfig.model} not found in DEFAULT_MODELS array.`);
|
||||
}
|
||||
// Directly use the providerName from the modelInfo
|
||||
const serviceProvider = modelInfo.provider.providerName;
|
||||
|
||||
const vars = {
|
||||
ServiceProvider: serviceProvider,
|
||||
cutoff,
|
||||
model: modelConfig.model,
|
||||
time: new Date().toLocaleString(),
|
||||
|
@ -119,7 +127,8 @@ function fillTemplateWith(input: string, modelConfig: ModelConfig) {
|
|||
}
|
||||
|
||||
Object.entries(vars).forEach(([name, value]) => {
|
||||
output = output.replaceAll(`{{${name}}}`, value);
|
||||
const regex = new RegExp(`{{${name}}}`, 'g');
|
||||
output = output.replace(regex, value.toString()); // Ensure value is a string
|
||||
});
|
||||
|
||||
return output;
|
||||
|
|
Loading…
Reference in New Issue