feat: 添加系统提示词对模型的不同叫法

This commit is contained in:
A-Cepheus 2024-04-24 14:49:23 +08:00
parent d12cf44d06
commit 0d66756f61
No known key found for this signature in database
GPG Key ID: 02057AE4D52020B4
2 changed files with 12 additions and 1 deletions

View File

@ -112,7 +112,7 @@ export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lan
// Latex block: $$e=mc^2$$
// `;
export const DEFAULT_SYSTEM_TEMPLATE = `
You are {{model}}, a large language model trained by {{ServiceProvider}}.
You are {{modelname}}, a large language model trained by {{ServiceProvider}}.
Knowledge cutoff: {{cutoff}}
Current model: {{model}}
Current time: {{time}}
@ -138,6 +138,13 @@ export const KnowledgeCutOffDate: Record<string, string> = {
"Meta-Llama-3-8B-Instruct": "2023-12",
};
export const ModelNameToName: Record<string, string> = {
default: "ChatGPT",
"gemini-pro": "Gemini",
"gemini-pro-vision": "Gemini",
"Meta-Llama-3-8B-Instruct": "Llama",
};
const openaiModels = [
"gpt-3.5-turbo",
"gpt-3.5-turbo-0301",

View File

@ -13,6 +13,7 @@ import {
StoreKey,
SUMMARIZE_MODEL,
GEMINI_SUMMARIZE_MODEL,
ModelNameToName,
} from "../constant";
import { ClientApi, RequestMessage, MultimodalContent } from "../client/api";
import { ChatControllerPool } from "../client/controller";
@ -105,6 +106,8 @@ function countMessages(msgs: ChatMessage[]) {
function fillTemplateWith(input: string, modelConfig: ModelConfig) {
const cutoff =
KnowledgeCutOffDate[modelConfig.model] ?? KnowledgeCutOffDate.default;
const modelname =
ModelNameToName[modelConfig.model] ?? ModelNameToName.default;
// Find the model in the DEFAULT_MODELS array that matches the modelConfig.model
const modelInfo = DEFAULT_MODELS.find((m) => m.name === modelConfig.model);
@ -118,6 +121,7 @@ function fillTemplateWith(input: string, modelConfig: ModelConfig) {
const vars = {
ServiceProvider: serviceProvider,
modelname,
cutoff,
model: modelConfig.model,
time: new Date().toString(),