feat: add prompt variable "username" (#7174)

This commit is contained in:
Wang Jiyuan 2025-06-14 13:08:32 +08:00 committed by GitHub
parent 27354d82e2
commit c9f12c2e49
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 19 additions and 9 deletions

View File

@ -10,7 +10,7 @@
"add.prompt.placeholder": "Enter prompt", "add.prompt.placeholder": "Enter prompt",
"add.prompt.variables.tip": { "add.prompt.variables.tip": {
"title": "Available variables", "title": "Available variables",
"content": "{{date}}:\tDate\n{{time}}:\tTime\n{{datetime}}:\tDate and time\n{{system}}:\tOperating system\n{{arch}}:\tCPU architecture\n{{language}}:\tLanguage\n{{model_name}}:\tModel name" "content": "{{date}}:\tDate\n{{time}}:\tTime\n{{datetime}}:\tDate and time\n{{system}}:\tOperating system\n{{arch}}:\tCPU architecture\n{{language}}:\tLanguage\n{{model_name}}:\tModel name\n{{username}}:\tUsername"
}, },
"add.title": "Create Agent", "add.title": "Create Agent",
"import": { "import": {

View File

@ -10,7 +10,7 @@
"add.prompt.placeholder": "プロンプトを入力", "add.prompt.placeholder": "プロンプトを入力",
"add.prompt.variables.tip": { "add.prompt.variables.tip": {
"title": "利用可能な変数", "title": "利用可能な変数",
"content": "{{date}}:\t日付\n{{time}}:\t時間\n{{datetime}}:\t日付と時間\n{{system}}:\tオペレーティングシステム\n{{arch}}:\tCPUアーキテクチャ\n{{language}}:\t言語\n{{model_name}}:\tモデル名" "content": "{{date}}:\t日付\n{{time}}:\t時間\n{{datetime}}:\t日付と時間\n{{system}}:\tオペレーティングシステム\n{{arch}}:\tCPUアーキテクチャ\n{{language}}:\t言語\n{{model_name}}:\tモデル名\n{{username}}:\tユーザー名"
}, },
"add.title": "エージェントを作成", "add.title": "エージェントを作成",
"import": { "import": {

View File

@ -10,7 +10,7 @@
"add.prompt.placeholder": "Введите промпт", "add.prompt.placeholder": "Введите промпт",
"add.prompt.variables.tip": { "add.prompt.variables.tip": {
"title": "Доступные переменные", "title": "Доступные переменные",
"content": "{{date}}:\tДата\n{{time}}:\tВремя\n{{datetime}}:\tДата и время\n{{system}}:\tОперационная система\n{{arch}}:\tАрхитектура процессора\n{{language}}:\tЯзык\n{{model_name}}:\tНазвание модели" "content": "{{date}}:\tДата\n{{time}}:\tВремя\n{{datetime}}:\tДата и время\n{{system}}:\tОперационная система\n{{arch}}:\tАрхитектура процессора\n{{language}}:\tЯзык\n{{model_name}}:\tНазвание модели\n{{username}}:\tИмя пользователя"
}, },
"add.title": "Создать агента", "add.title": "Создать агента",
"delete.popup.content": "Вы уверены, что хотите удалить этого агента?", "delete.popup.content": "Вы уверены, что хотите удалить этого агента?",

View File

@ -10,7 +10,7 @@
"add.prompt.placeholder": "输入提示词", "add.prompt.placeholder": "输入提示词",
"add.prompt.variables.tip": { "add.prompt.variables.tip": {
"title": "可用的变量", "title": "可用的变量",
"content": "{{date}}:\t日期\n{{time}}:\t时间\n{{datetime}}:\t日期和时间\n{{system}}:\t操作系统\n{{arch}}:\tCPU架构\n{{language}}:\t语言\n{{model_name}}:\t模型名称" "content": "{{date}}:\t日期\n{{time}}:\t时间\n{{datetime}}:\t日期和时间\n{{system}}:\t操作系统\n{{arch}}:\tCPU架构\n{{language}}:\t语言\n{{model_name}}:\t模型名称\n{{username}}:\t用户名"
}, },
"add.title": "创建智能体", "add.title": "创建智能体",
"import": { "import": {

View File

@ -10,7 +10,7 @@
"add.prompt.placeholder": "輸入提示詞", "add.prompt.placeholder": "輸入提示詞",
"add.prompt.variables.tip": { "add.prompt.variables.tip": {
"title": "可用的變數", "title": "可用的變數",
"content": "{{date}}:\t日期\n{{time}}:\t時間\n{{datetime}}:\t日期和時間\n{{system}}:\t作業系統\n{{arch}}:\tCPU架構\n{{language}}:\t語言\n{{model_name}}:\t模型名稱" "content": "{{date}}:\t日期\n{{time}}:\t時間\n{{datetime}}:\t日期和時間\n{{system}}:\t作業系統\n{{arch}}:\tCPU架構\n{{language}}:\t語言\n{{model_name}}:\t模型名稱\n{{username}}:\t使用者名稱"
}, },
"add.title": "建立智慧代理人", "add.title": "建立智慧代理人",
"import": { "import": {

View File

@ -10,7 +10,7 @@
"add.prompt.placeholder": "Εισαγάγετε φράση προκαλέσεως", "add.prompt.placeholder": "Εισαγάγετε φράση προκαλέσεως",
"add.prompt.variables.tip": { "add.prompt.variables.tip": {
"title": "Διαθέσιμες μεταβλητές", "title": "Διαθέσιμες μεταβλητές",
"content": "{{date}}:\tΗμερομηνία\n{{time}}:\tΏρα\n{{datetime}}:\tΗμερομηνία και ώρα\n{{system}}:\tΛειτουργικό σύστημα\n{{arch}}:\tΑρχιτεκτονική CPU\n{{language}}:\tΓλώσσα\n{{model_name}}:\tΌνομα μοντέλου" "content": "{{date}}:\tΗμερομηνία\n{{time}}:\tΏρα\n{{datetime}}:\tΗμερομηνία και ώρα\n{{system}}:\tΛειτουργικό σύστημα\n{{arch}}:\tΑρχιτεκτονική CPU\n{{language}}:\tΓλώσσα\n{{model_name}}:\tΌνομα μοντέλου\n{{username}}:\tΌνομα χρήστη"
}, },
"add.title": "Δημιουργία νέου ειδικού", "add.title": "Δημιουργία νέου ειδικού",
"delete.popup.content": "Είστε σίγουροι ότι θέλετε να διαγράψετε αυτόν τον ειδικό;", "delete.popup.content": "Είστε σίγουροι ότι θέλετε να διαγράψετε αυτόν τον ειδικό;",

View File

@ -10,7 +10,7 @@
"add.prompt.placeholder": "Ingrese la palabra clave", "add.prompt.placeholder": "Ingrese la palabra clave",
"add.prompt.variables.tip": { "add.prompt.variables.tip": {
"title": "Variables disponibles", "title": "Variables disponibles",
"content": "{{date}}:\tFecha\n{{time}}:\tHora\n{{datetime}}:\tFecha y hora\n{{system}}:\tSistema operativo\n{{arch}}:\tArquitectura de CPU\n{{language}}:\tIdioma\n{{model_name}}:\tNombre del modelo" "content": "{{date}}:\tFecha\n{{time}}:\tHora\n{{datetime}}:\tFecha y hora\n{{system}}:\tSistema operativo\n{{arch}}:\tArquitectura de CPU\n{{language}}:\tIdioma\n{{model_name}}:\tNombre del modelo\n{{username}}:\tNombre de usuario"
}, },
"add.title": "Crear agente inteligente", "add.title": "Crear agente inteligente",
"delete.popup.content": "¿Está seguro de que desea eliminar este agente inteligente?", "delete.popup.content": "¿Está seguro de que desea eliminar este agente inteligente?",

View File

@ -10,7 +10,7 @@
"add.prompt.placeholder": "Entrer le mot-clé", "add.prompt.placeholder": "Entrer le mot-clé",
"add.prompt.variables.tip": { "add.prompt.variables.tip": {
"title": "Variables disponibles", "title": "Variables disponibles",
"content": "{{date}}:\tDate\n{{time}}:\tHeure\n{{datetime}}:\tDate et heure\n{{system}}:\tSystème d'exploitation\n{{arch}}:\tArchitecture du processeur\n{{language}}:\tLangue\n{{model_name}}:\tNom du modèle" "content": "{{date}}:\tDate\n{{time}}:\tHeure\n{{datetime}}:\tDate et heure\n{{system}}:\tSystème d'exploitation\n{{arch}}:\tArchitecture du processeur\n{{language}}:\tLangue\n{{model_name}}:\tNom du modèle\n{{username}}:\tNom d'utilisateur"
}, },
"add.title": "Créer un agent intelligent", "add.title": "Créer un agent intelligent",
"delete.popup.content": "Êtes-vous sûr de vouloir supprimer cet agent intelligent ?", "delete.popup.content": "Êtes-vous sûr de vouloir supprimer cet agent intelligent ?",

View File

@ -10,7 +10,7 @@
"add.prompt.placeholder": "Digite o Prompt", "add.prompt.placeholder": "Digite o Prompt",
"add.prompt.variables.tip": { "add.prompt.variables.tip": {
"title": "Variáveis disponíveis", "title": "Variáveis disponíveis",
"content": "{{date}}:\tData\n{{time}}:\tHora\n{{datetime}}:\tData e hora\n{{system}}:\tSistema operativo\n{{arch}}:\tArquitetura da CPU\n{{language}}:\tIdioma\n{{model_name}}:\tNome do modelo" "content": "{{date}}:\tData\n{{time}}:\tHora\n{{datetime}}:\tData e hora\n{{system}}:\tSistema operativo\n{{arch}}:\tArquitetura da CPU\n{{language}}:\tIdioma\n{{model_name}}:\tNome do modelo\n{{username}}:\tNome de utilizador"
}, },
"add.title": "Criar Agente Inteligente", "add.title": "Criar Agente Inteligente",
"delete.popup.content": "Tem certeza de que deseja excluir este agente inteligente?", "delete.popup.content": "Tem certeza de que deseja excluir este agente inteligente?",

View File

@ -204,6 +204,16 @@ export const buildSystemPrompt = async (userSystemPrompt: string, tools?: MCPToo
userSystemPrompt = userSystemPrompt.replace(/{{model_name}}/g, 'Unknown Model') userSystemPrompt = userSystemPrompt.replace(/{{model_name}}/g, 'Unknown Model')
} }
} }
if (userSystemPrompt.includes('{{username}}')) {
try {
const username = store.getState().settings.userName || 'Unknown Username'
userSystemPrompt = userSystemPrompt.replace(/{{username}}/g, username)
} catch (error) {
console.error('Failed to get username:', error)
userSystemPrompt = userSystemPrompt.replace(/{{username}}/g, 'Unknown Username')
}
}
} }
if (tools && tools.length > 0) { if (tools && tools.length > 0) {