diff --git a/locales/bg-BG/chat.json b/locales/bg-BG/chat.json index a0ebf2df..b579dbc4 100644 --- a/locales/bg-BG/chat.json +++ b/locales/bg-BG/chat.json @@ -45,6 +45,11 @@ "camera": "Видеочат", "chat": "Чат", "chatList": "Списък с чатове", + "clear": { + "action": "Изчисти контекста", + "alert": "Сигурни ли сте, че искате да изтриете историята на съобщенията?", + "tip": "Тази операция не може да бъде отменена, моля, бъдете внимателни" + }, "danceList": "Списък с танци", "danceMarket": "Пазар на танци", "delSession": "Изтриване на сесия", @@ -52,11 +57,12 @@ "editRole": { "action": "Редактиране на роля" }, - "history": { - "action": "Изчисти контекста", - "alert": "Сигурни ли сте, че искате да изтриете историята на съобщенията?", - "tip": "Тази операция е необратима, моля, бъдете внимателни.", - "title": "История на чата" + "enableHistoryCount": { + "alias": "Без ограничения", + "limited": "Съдържа само {{number}} съобщения от сесията", + "setlimited": "Използвай брой съобщения от историята", + "title": "Ограничаване на броя на съобщенията в историята", + "unlimited": "Без ограничения на историята на съобщенията" }, "info": { "background": "Фон", diff --git a/locales/bg-BG/settings.json b/locales/bg-BG/settings.json index 77b0c990..c9888fcc 100644 --- a/locales/bg-BG/settings.json +++ b/locales/bg-BG/settings.json @@ -140,6 +140,20 @@ "title": "Езиков модел", "waitingForMore": "Още модели са в <1>планиране за интеграция, моля, очаквайте" }, + "systemAgent": { + "customPrompt": { + "addPrompt": "Добавяне на персонализиран подтик", + "desc": "След попълване, системният асистент ще използва персонализирания подтик при генериране на съдържание", + "placeholder": "Моля, въведете персонализиран подтик", + "title": "Персонализиран подтик" + }, + "emotionAnalysis": { + "label": "Модел за емоционален анализ", + "modelDesc": "Определете модела, който да се използва за емоционален анализ", + "title": "Автоматичен емоционален анализ" + }, + "title": "Системен агент" + }, "touch": { "title": "Настройки на допир" }, diff --git a/locales/de-DE/chat.json b/locales/de-DE/chat.json index a7d6d37f..ba6f8cba 100644 --- a/locales/de-DE/chat.json +++ b/locales/de-DE/chat.json @@ -45,6 +45,11 @@ "camera": "Videoanruf", "chat": "Chat", "chatList": "Chatliste", + "clear": { + "action": "Kontext löschen", + "alert": "Möchten Sie die Verlaufsmeldungen wirklich löschen?", + "tip": "Diese Aktion ist irreversibel, bitte vorsichtig sein" + }, "danceList": "Tanzliste", "danceMarket": "Tanzmarkt", "delSession": "Sitzung löschen", @@ -52,11 +57,12 @@ "editRole": { "action": "Rolle bearbeiten" }, - "history": { - "action": "Kontext löschen", - "alert": "Möchten Sie die historischen Nachrichten wirklich löschen?", - "tip": "Diese Aktion ist nicht umkehrbar, bitte vorsichtig handeln.", - "title": "Chatverlauf" + "enableHistoryCount": { + "alias": "Keine Einschränkung", + "limited": "Enthält nur {{number}} Sitzungsnachrichten", + "setlimited": "Verwendete Anzahl der Verlaufsmeldungen", + "title": "Einschränkung der Anzahl der Verlaufsmeldungen", + "unlimited": "Keine Einschränkung der Verlaufsmeldungen" }, "info": { "background": "Hintergrund", diff --git a/locales/de-DE/settings.json b/locales/de-DE/settings.json index 4d5589f5..6260b095 100644 --- a/locales/de-DE/settings.json +++ b/locales/de-DE/settings.json @@ -140,6 +140,20 @@ "title": "Sprachmodell", "waitingForMore": "Weitere Modelle werden gerade <1>geplant, bitte warten Sie." }, + "systemAgent": { + "customPrompt": { + "addPrompt": "Benutzerdefinierte Eingabe hinzufügen", + "desc": "Nachdem Sie dies ausgefüllt haben, wird der Systemassistent die benutzerdefinierte Eingabe bei der Inhaltserstellung verwenden", + "placeholder": "Bitte benutzerdefinierte Eingabe eingeben", + "title": "Benutzerdefinierte Eingabe" + }, + "emotionAnalysis": { + "label": "Emotionanalyse-Modell", + "modelDesc": "Das für die Emotionanalyse verwendete Modell angeben", + "title": "Automatische Emotionanalyse durchführen" + }, + "title": "System-Agent" + }, "touch": { "title": "Berührungseinstellungen" }, diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json index 4be05d33..e4e23bf4 100644 --- a/locales/en-US/chat.json +++ b/locales/en-US/chat.json @@ -45,6 +45,11 @@ "camera": "Video call", "chat": "Chat", "chatList": "Chat List", + "clear": { + "action": "Clear Context", + "alert": "Are you sure you want to delete the history messages?", + "tip": "This action is irreversible, please proceed with caution" + }, "danceList": "Dance List", "danceMarket": "Dance Market", "delSession": "Delete Session", @@ -52,11 +57,12 @@ "editRole": { "action": "Edit Role" }, - "history": { - "action": "Clear Context", - "alert": "Are you sure you want to delete the history messages?", - "tip": "This action is irreversible, please proceed with caution.", - "title": "Chat History" + "enableHistoryCount": { + "alias": "No Limit", + "limited": "Only includes {{number}} session messages", + "setlimited": "Set the number of historical messages", + "title": "Limit Historical Message Count", + "unlimited": "Unlimited Historical Message Count" }, "info": { "background": "Background", diff --git a/locales/en-US/settings.json b/locales/en-US/settings.json index 0597ba86..49683016 100644 --- a/locales/en-US/settings.json +++ b/locales/en-US/settings.json @@ -140,6 +140,20 @@ "title": "Language Model", "waitingForMore": "More models are currently <1>being planned for integration, please stay tuned." }, + "systemAgent": { + "customPrompt": { + "addPrompt": "Add Custom Prompt", + "desc": "Once filled out, the system assistant will use the custom prompt when generating content", + "placeholder": "Please enter custom prompt", + "title": "Custom Prompt" + }, + "emotionAnalysis": { + "label": "Emotion Analysis Model", + "modelDesc": "Specify the model used for emotion analysis", + "title": "Automatic Emotion Analysis" + }, + "title": "System Agent" + }, "touch": { "title": "Touch Settings" }, diff --git a/locales/es-ES/chat.json b/locales/es-ES/chat.json index 520f5e85..317dac4c 100644 --- a/locales/es-ES/chat.json +++ b/locales/es-ES/chat.json @@ -45,6 +45,11 @@ "camera": "Videollamada", "chat": "charlar", "chatList": "Lista de chat", + "clear": { + "action": "Borrar contexto", + "alert": "¿Estás seguro de que deseas eliminar los mensajes históricos?", + "tip": "Esta acción es irreversible, por favor actúa con precaución" + }, "danceList": "Lista de danzas", "danceMarket": "Mercado de danzas", "delSession": "Eliminar sesión", @@ -52,11 +57,12 @@ "editRole": { "action": "Editar rol" }, - "history": { - "action": "Borrar contexto", - "alert": "¿Estás seguro de que deseas eliminar los mensajes históricos?", - "tip": "Esta acción es irreversible, por favor actúa con precaución", - "title": "Registro de chat" + "enableHistoryCount": { + "alias": "Sin límite", + "limited": "Solo incluye {{number}} mensajes de sesión", + "setlimited": "Usar número de mensajes históricos", + "title": "Limitar el número de mensajes históricos", + "unlimited": "Sin límite en el número de mensajes históricos" }, "info": { "background": "Fondo", diff --git a/locales/es-ES/settings.json b/locales/es-ES/settings.json index e7bc2a33..d44b5cfc 100644 --- a/locales/es-ES/settings.json +++ b/locales/es-ES/settings.json @@ -140,6 +140,20 @@ "title": "Modelo de Lenguaje", "waitingForMore": "Más modelos están <1>programados para integrarse, por favor espera" }, + "systemAgent": { + "customPrompt": { + "addPrompt": "Agregar aviso personalizado", + "desc": "Al completarlo, el asistente del sistema utilizará el aviso personalizado al generar contenido", + "placeholder": "Introduce la palabra clave del aviso personalizado", + "title": "Palabra clave del aviso personalizado" + }, + "emotionAnalysis": { + "label": "Modelo de análisis de emociones", + "modelDesc": "Modelo designado para el análisis de emociones", + "title": "Análisis de emociones automático" + }, + "title": "Agente del sistema" + }, "touch": { "title": "Configuración de toque" }, diff --git a/locales/fr-FR/chat.json b/locales/fr-FR/chat.json index 91778220..1357cdc5 100644 --- a/locales/fr-FR/chat.json +++ b/locales/fr-FR/chat.json @@ -45,6 +45,11 @@ "camera": "Appel vidéo", "chat": "Discussion", "chatList": "Liste de discussion", + "clear": { + "action": "Effacer le contexte", + "alert": "Êtes-vous sûr de vouloir supprimer les messages historiques ?", + "tip": "Cette action est irréversible, veuillez agir avec prudence" + }, "danceList": "Liste des danses", "danceMarket": "Marché de la danse", "delSession": "Supprimer la session", @@ -52,11 +57,12 @@ "editRole": { "action": "Modifier le rôle" }, - "history": { - "action": "Effacer le contexte", - "alert": "Êtes-vous sûr de vouloir supprimer les messages historiques ?", - "tip": "Cette action est irréversible, veuillez agir avec prudence", - "title": "Historique des discussions" + "enableHistoryCount": { + "alias": "Pas de limite", + "limited": "Inclut seulement {{number}} messages de conversation", + "setlimited": "Utiliser le nombre de messages historiques", + "title": "Limiter le nombre de messages historiques", + "unlimited": "Pas de limite sur le nombre de messages historiques" }, "info": { "background": "Contexte", diff --git a/locales/fr-FR/settings.json b/locales/fr-FR/settings.json index 97a62f11..dbf23839 100644 --- a/locales/fr-FR/settings.json +++ b/locales/fr-FR/settings.json @@ -140,6 +140,20 @@ "title": "Modèle de Langue", "waitingForMore": "D'autres modèles sont en <1>planification d'intégration, restez à l'écoute" }, + "systemAgent": { + "customPrompt": { + "addPrompt": "Ajouter un prompt personnalisé", + "desc": "Une fois rempli, l'assistant système utilisera le prompt personnalisé lors de la génération de contenu", + "placeholder": "Veuillez entrer le mot-clé du prompt personnalisé", + "title": "Mot-clé du prompt personnalisé" + }, + "emotionAnalysis": { + "label": "Modèle d'analyse des émotions", + "modelDesc": "Modèle spécifié pour l'analyse des émotions", + "title": "Analyse des émotions automatique" + }, + "title": "Agent système" + }, "touch": { "title": "Paramètres de toucher" }, diff --git a/locales/it-IT/chat.json b/locales/it-IT/chat.json index 0092c7e1..1a2a8815 100644 --- a/locales/it-IT/chat.json +++ b/locales/it-IT/chat.json @@ -45,6 +45,11 @@ "camera": "Videochiamata", "chat": "Chat", "chatList": "Elenco chat", + "clear": { + "action": "Cancella contesto", + "alert": "Sei sicuro di voler eliminare i messaggi storici?", + "tip": "Questa operazione è irreversibile, procedi con cautela" + }, "danceList": "Elenco delle danze", "danceMarket": "Mercato delle danze", "delSession": "Elimina la sessione", @@ -52,11 +57,12 @@ "editRole": { "action": "Modifica ruolo" }, - "history": { - "action": "Cancella contesto", - "alert": "Sei sicuro di voler eliminare i messaggi storici?", - "tip": "Questa operazione è irreversibile, procedi con cautela", - "title": "Cronologia chat" + "enableHistoryCount": { + "alias": "Nessun limite", + "limited": "Include solo {{number}} messaggi di conversazione", + "setlimited": "Imposta il numero di messaggi storici", + "title": "Limita il numero di messaggi storici", + "unlimited": "Nessun limite ai messaggi storici" }, "info": { "background": "Sfondo", diff --git a/locales/it-IT/settings.json b/locales/it-IT/settings.json index a08f2c72..44633eae 100644 --- a/locales/it-IT/settings.json +++ b/locales/it-IT/settings.json @@ -140,6 +140,20 @@ "title": "Modello Linguistico", "waitingForMore": "Altri modelli sono in fase di <1>programmazione per l'integrazione, resta sintonizzato" }, + "systemAgent": { + "customPrompt": { + "addPrompt": "Aggiungi suggerimento personalizzato", + "desc": "Una volta compilato, l'assistente di sistema utilizzerà il suggerimento personalizzato nella generazione dei contenuti", + "placeholder": "Inserisci il suggerimento personalizzato", + "title": "Parola chiave personalizzata" + }, + "emotionAnalysis": { + "label": "Modello di analisi delle emozioni", + "modelDesc": "Specifica il modello da utilizzare per l'analisi delle emozioni", + "title": "Analisi delle emozioni automatica" + }, + "title": "Agente di sistema" + }, "touch": { "title": "Impostazioni di tocco" }, diff --git a/locales/ja-JP/chat.json b/locales/ja-JP/chat.json index 4cd24169..22b106b0 100644 --- a/locales/ja-JP/chat.json +++ b/locales/ja-JP/chat.json @@ -45,6 +45,11 @@ "camera": "ビデオ通話", "chat": "チャット", "chatList": "チャットリスト", + "clear": { + "action": "コンテキストをクリア", + "alert": "履歴メッセージを削除してもよろしいですか?", + "tip": "この操作は元に戻せませんので、慎重に行ってください" + }, "danceList": "ダンスリスト", "danceMarket": "ダンスマーケット", "delSession": "セッションを削除", @@ -52,11 +57,12 @@ "editRole": { "action": "ロールを編集" }, - "history": { - "action": "コンテキストをクリア", - "alert": "履歴メッセージを削除してもよろしいですか?", - "tip": "この操作は元に戻せませんので、慎重に行ってください", - "title": "チャット履歴" + "enableHistoryCount": { + "alias": "制限なし", + "limited": "{{number}} 件のセッションメッセージのみを含む", + "setlimited": "履歴メッセージ数を使用", + "title": "履歴メッセージ数を制限", + "unlimited": "履歴メッセージ数に制限なし" }, "info": { "background": "背景", diff --git a/locales/ja-JP/settings.json b/locales/ja-JP/settings.json index b0a09139..5226f889 100644 --- a/locales/ja-JP/settings.json +++ b/locales/ja-JP/settings.json @@ -140,6 +140,20 @@ "title": "言語モデル", "waitingForMore": "さらに多くのモデルが <1>接続予定 ですので、今しばらくお待ちください" }, + "systemAgent": { + "customPrompt": { + "addPrompt": "カスタムプロンプトを追加", + "desc": "入力後、システムアシスタントは生成するコンテンツにカスタムプロンプトを使用します", + "placeholder": "カスタムプロンプトを入力してください", + "title": "カスタムプロンプト" + }, + "emotionAnalysis": { + "label": "感情分析モデル", + "modelDesc": "感情分析に使用するモデルを指定", + "title": "自動感情分析を実行" + }, + "title": "システムエージェント" + }, "touch": { "title": "タッチ設定" }, diff --git a/locales/ko-KR/chat.json b/locales/ko-KR/chat.json index 19408e4a..cd156e44 100644 --- a/locales/ko-KR/chat.json +++ b/locales/ko-KR/chat.json @@ -45,6 +45,11 @@ "camera": "영상 통화", "chat": "채팅", "chatList": "채팅 목록", + "clear": { + "action": "컨텍스트 지우기", + "alert": "역사 메시지를 삭제하시겠습니까?", + "tip": "이 작업은 되돌릴 수 없으니 주의하시기 바랍니다." + }, "danceList": "댄스 목록", "danceMarket": "댄스 마켓", "delSession": "세션 삭제", @@ -52,11 +57,12 @@ "editRole": { "action": "역할 편집" }, - "history": { - "action": "문맥 지우기", - "alert": "역사 메시지를 삭제하시겠습니까?", - "tip": "이 작업은 되돌릴 수 없으니 신중하게 진행하세요.", - "title": "채팅 기록" + "enableHistoryCount": { + "alias": "제한 없음", + "limited": "단지 {{number}}개의 세션 메시지만 포함", + "setlimited": "역사 메시지 수 사용", + "title": "역사 메시지 수 제한", + "unlimited": "역사 메시지 수 제한 없음" }, "info": { "background": "배경", diff --git a/locales/ko-KR/settings.json b/locales/ko-KR/settings.json index 4185d3fe..9cd57bc9 100644 --- a/locales/ko-KR/settings.json +++ b/locales/ko-KR/settings.json @@ -140,6 +140,20 @@ "title": "언어 모델", "waitingForMore": "더 많은 모델이 <1>계획 중입니다, 기대해 주세요." }, + "systemAgent": { + "customPrompt": { + "addPrompt": "사용자 정의 프롬프트 추가", + "desc": "입력 후, 시스템 어시스턴트는 콘텐츠 생성 시 사용자 정의 프롬프트를 사용합니다", + "placeholder": "사용자 정의 프롬프트 입력", + "title": "사용자 정의 프롬프트" + }, + "emotionAnalysis": { + "label": "감정 분석 모델", + "modelDesc": "감정 분석에 사용할 모델 지정", + "title": "자동 감정 분석 수행" + }, + "title": "시스템 에이전트" + }, "touch": { "title": "터치 설정" }, diff --git a/locales/nl-NL/chat.json b/locales/nl-NL/chat.json index 0b998951..d41bef48 100644 --- a/locales/nl-NL/chat.json +++ b/locales/nl-NL/chat.json @@ -45,6 +45,11 @@ "camera": "Videobellen", "chat": "Chatten", "chatList": "Chatlijst", + "clear": { + "action": "Context wissen", + "alert": "Weet je zeker dat je de historische berichten wilt verwijderen?", + "tip": "Deze actie is onomkeerbaar, wees voorzichtig" + }, "danceList": "Danslijst", "danceMarket": "Dansmarkt", "delSession": "Verwijder sessie", @@ -52,11 +57,12 @@ "editRole": { "action": "Rol bewerken" }, - "history": { - "action": "Context wissen", - "alert": "Weet je zeker dat je de historische berichten wilt verwijderen?", - "tip": "Deze actie is onomkeerbaar, wees voorzichtig.", - "title": "Chatgeschiedenis" + "enableHistoryCount": { + "alias": "Geen beperking", + "limited": "Bevat alleen {{number}} gespreksberichten", + "setlimited": "Gebruik het aantal historische berichten", + "title": "Beperk het aantal historische berichten", + "unlimited": "Geen beperking op het aantal historische berichten" }, "info": { "background": "Achtergrond", diff --git a/locales/nl-NL/settings.json b/locales/nl-NL/settings.json index 77ab7cde..d3145dfc 100644 --- a/locales/nl-NL/settings.json +++ b/locales/nl-NL/settings.json @@ -140,6 +140,20 @@ "title": "Taalmodel", "waitingForMore": "Meer modellen zijn momenteel <1>in planning, blijf op de hoogte." }, + "systemAgent": { + "customPrompt": { + "addPrompt": "Voeg aangepaste prompt toe", + "desc": "Vul dit in, zodat de systeemassistent de aangepaste prompt gebruikt bij het genereren van inhoud", + "placeholder": "Voer aangepaste prompt in", + "title": "Aangepaste prompt" + }, + "emotionAnalysis": { + "label": "Emotie-analysemode", + "modelDesc": "Specificeer het model dat voor emotie-analyse moet worden gebruikt", + "title": "Automatische emotie-analyse" + }, + "title": "Systeemagent" + }, "touch": { "title": "Aanraakinstellingen" }, diff --git a/locales/pl-PL/chat.json b/locales/pl-PL/chat.json index b44b109b..aa0c3f2b 100644 --- a/locales/pl-PL/chat.json +++ b/locales/pl-PL/chat.json @@ -45,6 +45,11 @@ "camera": "Wideokonferencja", "chat": "Czat", "chatList": "Lista czatów", + "clear": { + "action": "Wyczyść kontekst", + "alert": "Czy na pewno chcesz usunąć historię wiadomości?", + "tip": "Ta operacja jest nieodwracalna, proszę działać ostrożnie" + }, "danceList": "Lista tańców", "danceMarket": "Rynek tańca", "delSession": "Usuń sesję", @@ -52,11 +57,12 @@ "editRole": { "action": "Edytuj rolę" }, - "history": { - "action": "Wyczyść kontekst", - "alert": "Czy na pewno chcesz usunąć historię wiadomości?", - "tip": "Ta operacja jest nieodwracalna, proszę działać ostrożnie", - "title": "Historia czatu" + "enableHistoryCount": { + "alias": "Brak ograniczeń", + "limited": "Zawiera tylko {{number}} wiadomości sesji", + "setlimited": "Ustaw liczbę wiadomości w historii", + "title": "Ogranicz liczbę wiadomości w historii", + "unlimited": "Brak ograniczeń w historii wiadomości" }, "info": { "background": "Tło", diff --git a/locales/pl-PL/settings.json b/locales/pl-PL/settings.json index 302ebaa8..2ef874a9 100644 --- a/locales/pl-PL/settings.json +++ b/locales/pl-PL/settings.json @@ -140,6 +140,20 @@ "title": "Model językowy", "waitingForMore": "Więcej modeli jest w <1>planowanej integracji, prosimy o cierpliwość" }, + "systemAgent": { + "customPrompt": { + "addPrompt": "Dodaj niestandardowy podpowiedź", + "desc": "Po wypełnieniu, asystent systemowy użyje niestandardowej podpowiedzi podczas generowania treści", + "placeholder": "Wprowadź niestandardowe słowo kluczowe", + "title": "Niestandardowe słowo kluczowe" + }, + "emotionAnalysis": { + "label": "Model analizy emocji", + "modelDesc": "Określ model używany do analizy emocji", + "title": "Automatyczna analiza emocji" + }, + "title": "Agent systemowy" + }, "touch": { "title": "Ustawienia dotykowe" }, diff --git a/locales/pt-BR/chat.json b/locales/pt-BR/chat.json index d5f0eace..ad5a1983 100644 --- a/locales/pt-BR/chat.json +++ b/locales/pt-BR/chat.json @@ -45,6 +45,11 @@ "camera": "Chamada de vídeo", "chat": "Bate-papo", "chatList": "Lista de Chats", + "clear": { + "action": "Limpar contexto", + "alert": "Tem certeza de que deseja excluir as mensagens históricas?", + "tip": "Esta ação é irreversível, por favor, proceda com cautela" + }, "danceList": "Lista de Danças", "danceMarket": "Mercado de Danças", "delSession": "Excluir sessão", @@ -52,11 +57,12 @@ "editRole": { "action": "Editar papel" }, - "history": { - "action": "Limpar Contexto", - "alert": "Tem certeza de que deseja excluir as mensagens do histórico?", - "tip": "Esta ação é irreversível, por favor, proceda com cautela.", - "title": "Histórico de Conversa" + "enableHistoryCount": { + "alias": "Sem restrições", + "limited": "Apenas inclui {{number}} mensagens de sessão", + "setlimited": "Usar número de mensagens históricas", + "title": "Limitar número de mensagens históricas", + "unlimited": "Sem limite de mensagens históricas" }, "info": { "background": "Fundo", diff --git a/locales/pt-BR/settings.json b/locales/pt-BR/settings.json index c67e5424..587f1add 100644 --- a/locales/pt-BR/settings.json +++ b/locales/pt-BR/settings.json @@ -140,6 +140,20 @@ "title": "Modelo de Linguagem", "waitingForMore": "Mais modelos estão <1>planejados para serem integrados, fique atento" }, + "systemAgent": { + "customPrompt": { + "addPrompt": "Adicionar Prompt Personalizado", + "desc": "Após preenchido, o assistente do sistema usará o prompt personalizado ao gerar conteúdo", + "placeholder": "Digite a palavra-chave do prompt personalizado", + "title": "Palavra-chave do Prompt Personalizado" + }, + "emotionAnalysis": { + "label": "Modelo de Análise de Emoção", + "modelDesc": "Modelo especificado para análise de emoção", + "title": "Análise de Emoção Automática" + }, + "title": "Agente do Sistema" + }, "touch": { "title": "Configurações de Toque" }, diff --git a/locales/ru-RU/chat.json b/locales/ru-RU/chat.json index a1c30902..08fd8208 100644 --- a/locales/ru-RU/chat.json +++ b/locales/ru-RU/chat.json @@ -45,6 +45,11 @@ "camera": "Видеозвонок", "chat": "Чат", "chatList": "Список чатов", + "clear": { + "action": "Очистить контекст", + "alert": "Вы уверены, что хотите удалить историю сообщений?", + "tip": "Это действие необратимо, пожалуйста, будьте осторожны" + }, "danceList": "Список танцев", "danceMarket": "Рынок танцев", "delSession": "Удалить сессию", @@ -52,11 +57,12 @@ "editRole": { "action": "Редактировать роль" }, - "history": { - "action": "Очистить контекст", - "alert": "Вы уверены, что хотите удалить историю сообщений?", - "tip": "Это действие необратимо, пожалуйста, будьте осторожны.", - "title": "История чата" + "enableHistoryCount": { + "alias": "Без ограничений", + "limited": "Содержит только {{number}} сообщений сессии", + "setlimited": "Использовать количество исторических сообщений", + "title": "Ограничить количество исторических сообщений", + "unlimited": "Неограниченное количество исторических сообщений" }, "info": { "background": "Фон", diff --git a/locales/ru-RU/settings.json b/locales/ru-RU/settings.json index ed6798c5..32174021 100644 --- a/locales/ru-RU/settings.json +++ b/locales/ru-RU/settings.json @@ -140,6 +140,20 @@ "title": "Языковая модель", "waitingForMore": "Больше моделей <1>планируется подключить, пожалуйста, ожидайте" }, + "systemAgent": { + "customPrompt": { + "addPrompt": "Добавить пользовательский запрос", + "desc": "После заполнения системный помощник будет использовать пользовательский запрос при генерации контента", + "placeholder": "Введите пользовательский запрос", + "title": "Пользовательский запрос" + }, + "emotionAnalysis": { + "label": "Модель анализа эмоций", + "modelDesc": "Укажите модель, используемую для анализа эмоций", + "title": "Автоматический анализ эмоций" + }, + "title": "Системный агент" + }, "touch": { "title": "Настройки касания" }, diff --git a/locales/tr-TR/chat.json b/locales/tr-TR/chat.json index 6bda719b..a5a6abef 100644 --- a/locales/tr-TR/chat.json +++ b/locales/tr-TR/chat.json @@ -45,6 +45,11 @@ "camera": "Görüntülü Arama", "chat": "sohbet", "chatList": "Sohbet Listesi", + "clear": { + "action": "Bağlamı temizle", + "alert": "Geçmiş mesajları silmek istediğinize emin misiniz?", + "tip": "Bu işlem geri alınamaz, lütfen dikkatli olun" + }, "danceList": "Dans Listesi", "danceMarket": "Dans Pazarı", "delSession": "Oturumu Sil", @@ -52,11 +57,12 @@ "editRole": { "action": "Rolü Düzenle" }, - "history": { - "action": "Bağlamı Temizle", - "alert": "Geçmiş mesajları silmek istediğinize emin misiniz?", - "tip": "Bu işlem geri alınamaz, lütfen dikkatli olun.", - "title": "Sohbet Geçmişi" + "enableHistoryCount": { + "alias": "Sınırsız", + "limited": "Sadece {{number}} oturum mesajını içerir", + "setlimited": "Geçmiş mesaj sayısını kullan", + "title": "Geçmiş mesaj sayısını sınırlama", + "unlimited": "Geçmiş mesaj sayısında sınırlama yok" }, "info": { "background": "Arka Plan", diff --git a/locales/tr-TR/settings.json b/locales/tr-TR/settings.json index 9390389a..341a974b 100644 --- a/locales/tr-TR/settings.json +++ b/locales/tr-TR/settings.json @@ -140,6 +140,20 @@ "title": "Dil Modeli", "waitingForMore": "Daha fazla model <1>planlanıyor, lütfen bekleyin" }, + "systemAgent": { + "customPrompt": { + "addPrompt": "Özel İpucu Ekle", + "desc": "Doldurduğunuzda, sistem asistanı içerik oluştururken özel ipucunu kullanacaktır", + "placeholder": "Lütfen özel ipucu kelimelerini girin", + "title": "Özel İpucu Kelimeleri" + }, + "emotionAnalysis": { + "label": "Duygu Analizi Modeli", + "modelDesc": "Duygu analizi için kullanılacak modeli belirtin", + "title": "Otomatik Duygu Analizi Yap" + }, + "title": "Sistem Ajanı" + }, "touch": { "title": "Dokunma Ayarları" }, diff --git a/locales/vi-VN/chat.json b/locales/vi-VN/chat.json index a8863fc0..fc4dc6d0 100644 --- a/locales/vi-VN/chat.json +++ b/locales/vi-VN/chat.json @@ -45,6 +45,11 @@ "camera": "Gọi video", "chat": "Trò chuyện", "chatList": "Danh sách trò chuyện", + "clear": { + "action": "Xóa ngữ cảnh", + "alert": "Bạn có chắc chắn muốn xóa tin nhắn lịch sử không?", + "tip": "Hành động này không thể hoàn tác, xin hãy cẩn thận" + }, "danceList": "Danh sách khiêu vũ", "danceMarket": "Thị trường khiêu vũ", "delSession": "Xóa cuộc trò chuyện", @@ -52,11 +57,12 @@ "editRole": { "action": "Chỉnh sửa vai trò" }, - "history": { - "action": "Xóa ngữ cảnh", - "alert": "Bạn có chắc chắn muốn xóa tin nhắn lịch sử không?", - "tip": "Hành động này không thể hoàn tác, xin hãy cẩn thận khi thực hiện.", - "title": "Lịch sử trò chuyện" + "enableHistoryCount": { + "alias": "Không giới hạn", + "limited": "Chỉ bao gồm {{number}} tin nhắn cuộc trò chuyện", + "setlimited": "Sử dụng số lượng tin nhắn lịch sử", + "title": "Giới hạn số lượng tin nhắn lịch sử", + "unlimited": "Không giới hạn số lượng tin nhắn lịch sử" }, "info": { "background": "Nền", diff --git a/locales/vi-VN/settings.json b/locales/vi-VN/settings.json index dfe78180..abefc712 100644 --- a/locales/vi-VN/settings.json +++ b/locales/vi-VN/settings.json @@ -140,6 +140,20 @@ "title": "Mô hình ngôn ngữ", "waitingForMore": "Nhiều mô hình hơn đang <1>được lên kế hoạch kết nối, xin hãy chờ đợi" }, + "systemAgent": { + "customPrompt": { + "addPrompt": "Thêm gợi ý tùy chỉnh", + "desc": "Sau khi điền, trợ lý hệ thống sẽ sử dụng gợi ý tùy chỉnh khi tạo nội dung", + "placeholder": "Vui lòng nhập từ gợi ý tùy chỉnh", + "title": "Từ gợi ý tùy chỉnh" + }, + "emotionAnalysis": { + "label": "Mô hình phân tích cảm xúc", + "modelDesc": "Chỉ định mô hình được sử dụng cho phân tích cảm xúc", + "title": "Tự động thực hiện phân tích cảm xúc" + }, + "title": "Đại lý hệ thống" + }, "touch": { "title": "Cài đặt chạm" }, diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json index 5be8338a..071b8b07 100644 --- a/locales/zh-CN/chat.json +++ b/locales/zh-CN/chat.json @@ -45,6 +45,11 @@ "camera": "视频通话", "chat": "聊天", "chatList": "聊天列表", + "clear": { + "alert": "确定删除历史消息?", + "action": "清除上下文", + "tip": "该操作不可逆,请谨慎操作" + }, "danceList": "舞蹈列表", "danceMarket": "舞蹈市场", "delSession": "删除会话", @@ -52,11 +57,12 @@ "editRole": { "action": "编辑角色" }, - "history": { - "title": "聊天记录", - "alert": "确定删除历史消息?", - "action": "清除上下文", - "tip": "该操作不可逆,请谨慎操作" + "enableHistoryCount": { + "alias": "不限制", + "limited": "只包含 {{number}} 条会话消息", + "setlimited": "使用历史消息数", + "title": "限制历史消息数", + "unlimited": "不限历史消息数" }, "info": { "chat": "聊天", diff --git a/locales/zh-CN/settings.json b/locales/zh-CN/settings.json index 8f5faca8..fd0a3957 100644 --- a/locales/zh-CN/settings.json +++ b/locales/zh-CN/settings.json @@ -140,6 +140,20 @@ }, "waitingForMore": "更多模型正在 <1>计划接入 中,敬请期待" }, + "systemAgent": { + "title": "系统代理", + "customPrompt": { + "addPrompt": "添加自定义提示", + "desc": "填写后,系统助理将在生成内容时使用自定义提示", + "placeholder": "请输入自定义提示词", + "title": "自定义提示词" + }, + "emotionAnalysis": { + "label": "情感分析模型", + "title": "自动进行情感分析", + "modelDesc": "指定用于情感分析的模型" + } + }, "touch": { "title": "触摸设定" }, diff --git a/locales/zh-TW/chat.json b/locales/zh-TW/chat.json index ae6b332b..47647f93 100644 --- a/locales/zh-TW/chat.json +++ b/locales/zh-TW/chat.json @@ -45,6 +45,11 @@ "camera": "視頻通話", "chat": "聊天", "chatList": "聊天列表", + "clear": { + "action": "清除上下文", + "alert": "確定刪除歷史消息?", + "tip": "該操作不可逆,請謹慎操作" + }, "danceList": "舞蹈列表", "danceMarket": "舞蹈市場", "delSession": "刪除會話", @@ -52,11 +57,12 @@ "editRole": { "action": "編輯角色" }, - "history": { - "action": "清除上下文", - "alert": "確定刪除歷史消息?", - "tip": "該操作不可逆,請謹慎操作", - "title": "聊天紀錄" + "enableHistoryCount": { + "alias": "不限制", + "limited": "只包含 {{number}} 條會話消息", + "setlimited": "使用歷史消息數", + "title": "限制歷史消息數", + "unlimited": "不限歷史消息數" }, "info": { "background": "背景", diff --git a/locales/zh-TW/settings.json b/locales/zh-TW/settings.json index fa51a252..058e010b 100644 --- a/locales/zh-TW/settings.json +++ b/locales/zh-TW/settings.json @@ -140,6 +140,20 @@ "title": "語言模型", "waitingForMore": "更多模型正在 <1>計劃接入 中,敬請期待" }, + "systemAgent": { + "customPrompt": { + "addPrompt": "添加自訂提示", + "desc": "填寫後,系統助理將在生成內容時使用自訂提示", + "placeholder": "請輸入自訂提示詞", + "title": "自訂提示詞" + }, + "emotionAnalysis": { + "label": "情感分析模型", + "modelDesc": "指定用於情感分析的模型", + "title": "自動進行情感分析" + }, + "title": "系統代理" + }, "touch": { "title": "觸摸設定" }, diff --git a/src/app/chat/ChatMode/ChatHeader/AgentMeta/index.tsx b/src/app/chat/ChatMode/ChatHeader/AgentMeta/index.tsx index 2a778e2f..84a0a111 100644 --- a/src/app/chat/ChatMode/ChatHeader/AgentMeta/index.tsx +++ b/src/app/chat/ChatMode/ChatHeader/AgentMeta/index.tsx @@ -2,7 +2,7 @@ import { Avatar } from '@lobehub/ui'; import { Space, Typography } from 'antd'; import React from 'react'; -import useSessionContext from '@/hooks/useSessionContext'; +import { sessionSelectors, useSessionStore } from '@/store/session'; import ModelSwitchPanel from '../actions/ModelSwitchPanel'; import { useStyles } from './style'; @@ -16,7 +16,7 @@ export default (props: AgentMetaProps) => { const { styles, cx } = useStyles(); const { style, className } = props; - const { sessionAgent } = useSessionContext(); + const sessionAgent = useSessionStore((s) => sessionSelectors.currentAgent(s)); const meta = sessionAgent?.meta; const { avatar, name, description } = meta || {}; diff --git a/src/app/chat/ChatMode/ChatHeader/actions/ShareButton/Preview.tsx b/src/app/chat/ChatMode/ChatHeader/actions/ShareButton/Preview.tsx index 797c2b6e..4c7a14c5 100644 --- a/src/app/chat/ChatMode/ChatHeader/actions/ShareButton/Preview.tsx +++ b/src/app/chat/ChatMode/ChatHeader/actions/ShareButton/Preview.tsx @@ -4,8 +4,8 @@ import { memo } from 'react'; import { Flexbox } from 'react-layout-kit'; import { DEFAULT_CHAT_MODEL } from '@/constants/agent'; -import useSessionContext from '@/hooks/useSessionContext'; import { siteUrl } from '@/server/utils/url'; +import { sessionSelectors, useSessionStore } from '@/store/session'; import ChatList from './ChatList'; import { useStyles } from './style'; @@ -13,7 +13,7 @@ import { FieldType } from './type'; const Preview = memo( ({ title, withSystemRole, withBackground, withFooter }) => { - const { sessionAgent } = useSessionContext(); + const sessionAgent = useSessionStore((s) => sessionSelectors.currentAgent(s)); const { styles } = useStyles(withBackground); if (!sessionAgent) return null; diff --git a/src/app/chat/ChatMode/ChatInfo/AgentDetail/index.tsx b/src/app/chat/ChatMode/ChatInfo/AgentDetail/index.tsx index 1215fdb2..e314ad54 100644 --- a/src/app/chat/ChatMode/ChatInfo/AgentDetail/index.tsx +++ b/src/app/chat/ChatMode/ChatInfo/AgentDetail/index.tsx @@ -4,14 +4,15 @@ import { Flexbox } from 'react-layout-kit'; import AgentCard from '@/components/agent/AgentCard'; import SystemRole from '@/components/agent/SystemRole'; -import useSessionContext from '@/hooks/useSessionContext'; +import { sessionSelectors, useSessionStore } from '@/store/session'; +import Clear from '../actions/Clear'; import EditRole from '../actions/EditRole'; import History from '../actions/History'; import TokenMini from '../actions/TokenMini'; const ChatInfo = () => { - const { sessionAgent } = useSessionContext(); + const sessionAgent = useSessionStore((s) => sessionSelectors.currentAgent(s)); return ( sessionAgent && ( @@ -21,6 +22,7 @@ const ChatInfo = () => { + diff --git a/src/app/chat/ChatMode/ChatInfo/actions/Clear.tsx b/src/app/chat/ChatMode/ChatInfo/actions/Clear.tsx new file mode 100644 index 00000000..b27a874b --- /dev/null +++ b/src/app/chat/ChatMode/ChatInfo/actions/Clear.tsx @@ -0,0 +1,24 @@ +import { ActionIcon } from '@lobehub/ui'; +import { Popconfirm } from 'antd'; +import { Eraser } from 'lucide-react'; +import { useTranslation } from 'react-i18next'; + +import { useSessionStore } from '@/store/session'; + +const Clear = () => { + const [clearHistory] = useSessionStore((s) => [s.clearHistory]); + const { t } = useTranslation('chat'); + return ( + + + + ); +}; + +export default Clear; diff --git a/src/app/chat/ChatMode/ChatInfo/actions/History.tsx b/src/app/chat/ChatMode/ChatInfo/actions/History.tsx index 36a24791..7992e9c6 100644 --- a/src/app/chat/ChatMode/ChatInfo/actions/History.tsx +++ b/src/app/chat/ChatMode/ChatInfo/actions/History.tsx @@ -1,24 +1,70 @@ -import { ActionIcon } from '@lobehub/ui'; -import { Popconfirm } from 'antd'; -import { Eraser } from 'lucide-react'; +import { ActionIcon, SliderWithInput } from '@lobehub/ui'; +import { Popover, Switch } from 'antd'; +import { Timer, TimerOff } from 'lucide-react'; +import { memo, useState } from 'react'; import { useTranslation } from 'react-i18next'; +import { Flexbox } from 'react-layout-kit'; -import { useSessionStore } from '@/store/session'; +import { useIsMobile } from '@/hooks/useIsMobile'; +import { sessionSelectors, useSessionStore } from '@/store/session'; -const History = () => { - const [clearHistory] = useSessionStore((s) => [s.clearHistory]); +const History = memo(() => { const { t } = useTranslation('chat'); + const [popoverOpen, setPopoverOpen] = useState(false); + + const [historyCount, enableHistoryCount, updateSessionChatConfig] = useSessionStore((s) => { + const config = sessionSelectors.currentSessionChatConfig(s); + return [config.historyCount, config.enableHistoryCount, s.updateSessionChatConfig]; + }); + + const title = t( + enableHistoryCount ? 'enableHistoryCount.limited' : 'enableHistoryCount.unlimited', + { number: historyCount || 0 }, + ); + const mobile = useIsMobile(); + return ( - + { + updateSessionChatConfig({ historyCount: v }); + }} + step={1} + style={{ width: mobile ? 160 : 300 }} + value={historyCount} + /> + + } + onOpenChange={setPopoverOpen} + open={popoverOpen} + placement={'top'} + title={ + + { + updateSessionChatConfig({ enableHistoryCount }); + }} + size={'small'} + /> + {t('enableHistoryCount.title')} + + } + trigger={'click'} > - - + + ); -}; +}); export default History; diff --git a/src/app/chat/ChatMode/ChatInfo/actions/TokenMini.tsx b/src/app/chat/ChatMode/ChatInfo/actions/TokenMini.tsx index 82bd06c5..cdb64933 100644 --- a/src/app/chat/ChatMode/ChatInfo/actions/TokenMini.tsx +++ b/src/app/chat/ChatMode/ChatInfo/actions/TokenMini.tsx @@ -3,10 +3,11 @@ import { useTranslation } from 'react-i18next'; import { OPENAI_MODEL_LIST } from '@/constants/openai'; import { useCalculateToken } from '@/hooks/useCalculateToken'; -import useSessionContext from '@/hooks/useSessionContext'; +import { sessionSelectors, useSessionStore } from '@/store/session'; const TokenMini = () => { - const model = useSessionContext()?.sessionAgent?.model; + const sessionAgent = useSessionStore((s) => sessionSelectors.currentAgent(s)); + const model = sessionAgent?.model; const usedTokens = useCalculateToken(); const { t } = useTranslation('chat'); diff --git a/src/app/chat/ChatMode/SideBar/SessionList/Elsa/index.tsx b/src/app/chat/ChatMode/SideBar/SessionList/Elsa/index.tsx index 17412c6a..7dd58f94 100644 --- a/src/app/chat/ChatMode/SideBar/SessionList/Elsa/index.tsx +++ b/src/app/chat/ChatMode/SideBar/SessionList/Elsa/index.tsx @@ -3,20 +3,23 @@ import { memo } from 'react'; import { useTranslation } from 'react-i18next'; import { LOBE_VIDOL_DEFAULT_AGENT_ID } from '@/constants/agent'; -import useSessionContext from '@/hooks/useSessionContext'; import { useAgentStore } from '@/store/agent'; +import { useSessionStore } from '@/store/session'; import ListItem from '../ListItem'; const Elsa = memo(() => { const { t } = useTranslation('common'); const defaultAgent = useAgentStore((s) => s.defaultAgent); - const { activeSessionId, switchSession } = useSessionContext(); + const { activeId, switchSession } = useSessionStore((s) => ({ + activeId: s.activeId, + switchSession: s.switchSession, + })); return ( switchSession(LOBE_VIDOL_DEFAULT_AGENT_ID)} - active={activeSessionId === LOBE_VIDOL_DEFAULT_AGENT_ID} + active={activeId === LOBE_VIDOL_DEFAULT_AGENT_ID} avatar={defaultAgent.meta.avatar} title={ diff --git a/src/constants/agent.ts b/src/constants/agent.ts index e8968bf3..448fb4a5 100644 --- a/src/constants/agent.ts +++ b/src/constants/agent.ts @@ -34,6 +34,11 @@ export const DEFAULT_AGENT_CONFIG = { ...DEFAULT_TTS_CONFIG_FEMALE, }; +export const DEFAULT_CHAT_CONFIG = { + enableHistoryCount: true, + historyCount: 8, +}; + export const LOBE_VIDOL_DEFAULT_AGENT: Agent = { agentId: LOBE_VIDOL_DEFAULT_AGENT_ID, author: 'LobeVidol', diff --git a/src/features/ChatItem/Actions/Tool.tsx b/src/features/ChatItem/Actions/Tool.tsx new file mode 100644 index 00000000..965b736f --- /dev/null +++ b/src/features/ChatItem/Actions/Tool.tsx @@ -0,0 +1,33 @@ +import { ActionIconGroup } from '@lobehub/ui'; +import { memo } from 'react'; + +import type { RenderAction } from '@/features/ChatItem/type'; +import { useChatListActionsBar } from '@/hooks/useChatListActionsBar'; + +const ToolActionsBar: RenderAction = ({ id }) => { + const { regenerate, del } = useChatListActionsBar(); + + if (id === 'default') return; + + return ( + { + switch (event.key) { + case 'regenerate': { + // await reInvokeToolMessage(id); + break; + } + + case 'del': { + // await deleteToolMessage(id); + break; + } + } + }} + type="ghost" + /> + ); +}; + +export default memo(ToolActionsBar); diff --git a/src/features/ChatItem/Actions/index.tsx b/src/features/ChatItem/Actions/index.tsx index 96795379..efc0eb0b 100644 --- a/src/features/ChatItem/Actions/index.tsx +++ b/src/features/ChatItem/Actions/index.tsx @@ -9,12 +9,14 @@ import { LLMRoleType } from '@/types/llm'; import AssistantActionsBar from './Assistant'; import SystemActionBar from './System'; +import ToolActionsBar from './Tool'; import UserActionsBar from './User'; export const renderActions: Record = { assistant: AssistantActionsBar, user: UserActionsBar, system: SystemActionBar, + tool: ToolActionsBar, }; export const useActionsClick = (): OnActionsClick => { diff --git a/src/hooks/useSessionContext.ts b/src/hooks/useSessionContext.ts deleted file mode 100644 index 307cdba7..00000000 --- a/src/hooks/useSessionContext.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { sessionSelectors, useSessionStore } from '@/store/session'; - -const useSessionContext = () => { - const [activeSessionId, switchSession] = useSessionStore((s) => [s.activeId, s.switchSession]); - - const getAgentById = sessionSelectors.getAgentById(useSessionStore.getState()); - const sessionAgent = getAgentById(activeSessionId); - - return { - activeSessionId, - sessionAgent, - switchSession, - getAgentById, - }; -}; - -export default useSessionContext; diff --git a/src/locales/default/chat.ts b/src/locales/default/chat.ts index c43a947b..ac2fa356 100644 --- a/src/locales/default/chat.ts +++ b/src/locales/default/chat.ts @@ -27,12 +27,18 @@ export default { background: '背景', stage: '舞台', }, - history: { - title: '聊天记录', + clear: { alert: '确定删除历史消息?', action: '清除上下文', tip: '该操作不可逆,请谨慎操作', }, + enableHistoryCount: { + alias: '不限制', + limited: '只包含 {{number}} 条会话消息', + setlimited: '使用历史消息数', + title: '限制历史消息数', + unlimited: '不限历史消息数', + }, editRole: { action: '编辑角色', }, diff --git a/src/services/chat.ts b/src/services/chat.ts index d568f84f..b589fdc8 100644 --- a/src/services/chat.ts +++ b/src/services/chat.ts @@ -183,7 +183,7 @@ export const chatCompletion = async ( params: Partial, options?: FetchOptions, ) => { - const { provider = DEFAULT_CHAT_PROVIDER, messages, ...res } = params; + const { provider = DEFAULT_CHAT_PROVIDER, ...res } = params; const { signal } = options ?? {}; let model = res.model || DEFAULT_CHAT_MODEL; @@ -197,12 +197,7 @@ export const chatCompletion = async ( if (deploymentName) model = deploymentName; } - const postMessages = messages.map((message) => ({ - role: message.role, - content: message.content, - })); - - const payload = { ...res, model, messages: postMessages }; + const payload = { ...res, model }; /** * Use browser agent runtime diff --git a/src/store/session/helpers.ts b/src/store/session/helpers.ts new file mode 100644 index 00000000..246c0fdd --- /dev/null +++ b/src/store/session/helpers.ts @@ -0,0 +1,24 @@ +import { ChatMessage } from '@/types/message'; +import { SessionChatConfig } from '@/types/session'; + +const getSlicedMessagesWithConfig = ( + messages: ChatMessage[], + config: SessionChatConfig, + includeNewUserMessage?: boolean, +): ChatMessage[] => { + // if historyCount is not enabled or set to 0, return all messages + if (!config.enableHistoryCount || !config.historyCount) return messages; + + // if user send message, history will include this message so the total length should +1 + const messagesCount = !!includeNewUserMessage ? config.historyCount + 1 : config.historyCount; + + // if historyCount is negative, return empty array + if (messagesCount <= 0) return []; + + // if historyCount is positive, return last N messages + return messages.slice(-messagesCount); +}; + +export const chatHelpers = { + getSlicedMessagesWithConfig, +}; diff --git a/src/store/session/index.ts b/src/store/session/index.ts index f2f04e01..837cd104 100644 --- a/src/store/session/index.ts +++ b/src/store/session/index.ts @@ -1,3 +1,4 @@ +import { DeepPartial } from '@trpc/server'; import { nanoid } from 'ai'; import dayjs from 'dayjs'; import { produce } from 'immer'; @@ -6,18 +7,25 @@ import { shallow } from 'zustand/shallow'; import { createWithEqualityFn } from 'zustand/traditional'; import { StateCreator } from 'zustand/vanilla'; -import { DEFAULT_LLM_CONFIG, LOBE_VIDOL_DEFAULT_AGENT_ID } from '@/constants/agent'; +import { + DEFAULT_CHAT_CONFIG, + DEFAULT_LLM_CONFIG, + LOBE_VIDOL_DEFAULT_AGENT_ID, +} from '@/constants/agent'; import { DEFAULT_USER_AVATAR_URL, LOADING_FLAG } from '@/constants/common'; import { chatCompletion, handleSpeakAi, handleStopSpeak } from '@/services/chat'; import { shareService } from '@/services/share'; import { Agent } from '@/types/agent'; import { ChatMessage } from '@/types/chat'; -import { Session } from '@/types/session'; +import { OpenAIChatMessage } from '@/types/provider/chat'; +import { Session, SessionChatConfig } from '@/types/session'; import { ShareGPTConversation } from '@/types/share'; +import { merge } from '@/utils/merge'; import { vidolStorage } from '@/utils/storage'; import { useAgentStore } from '../agent'; import { useGlobalStore } from '../global'; +import { chatHelpers } from './helpers'; import { initialState } from './initialState'; import { MessageActionType, messageReducer } from './reducers/message'; import { sessionSelectors } from './selectors'; @@ -154,6 +162,16 @@ export interface SessionStore { * @returns */ updateMessage: (id: string, content: string) => void; + /** + * 更新会话聊天配置 + * @param config + */ + updateSessionChatConfig: (config: DeepPartial) => void; + /** + * 更新会话配置 + * @param config + */ + updateSessionConfig: (config: DeepPartial) => void; /** * 更新会话消息 * @param messages @@ -175,23 +193,24 @@ export const createSessionStore: StateCreator { - const { sessionList } = get(); - if (agent.agentId === LOBE_VIDOL_DEFAULT_AGENT_ID) { - set({ activeId: agent.agentId }); - return; - } + const { sessionList, switchSession } = get(); const newSessionList = produce(sessionList, (draft) => { const index = draft.findIndex((session) => session.agentId === agent.agentId); if (index === -1) { - draft.push({ + const session = { agentId: agent.agentId, messages: [], - }); + config: { + chatConfig: DEFAULT_CHAT_CONFIG, + }, + }; + draft.push(session); } }); - set({ activeId: agent.agentId, sessionList: newSessionList }); + set({ sessionList: newSessionList }); + switchSession(agent.agentId); // 切换会话 }, deleteMessage: (id) => { const { dispatchMessage } = get(); @@ -243,8 +262,21 @@ export const createSessionStore: StateCreator ({ + role: message.role, + content: message.content, + })); await chatCompletion( { @@ -252,13 +284,7 @@ export const createSessionStore: StateCreator { @@ -497,22 +523,9 @@ export const createSessionStore: StateCreator { - const { sessionList } = get(); - if (agentId === LOBE_VIDOL_DEFAULT_AGENT_ID) { - set({ activeId: agentId }); - useAgentStore.setState({ currentIdentifier: agentId }); - return; - } - const targetSession = sessionList.find((session) => session.agentId === agentId); - if (!targetSession) { - const session = { - agentId: agentId, - messages: [], - }; - set({ sessionList: [...sessionList, session] }); - } + if (get().activeId === agentId) return; set({ activeId: agentId }); - useAgentStore.setState({ currentIdentifier: agentId }); + useAgentStore.setState({ currentIdentifier: agentId }, false, `switchSession/${agentId}`); }, toggleInteractive: () => { @@ -530,6 +543,26 @@ export const createSessionStore: StateCreator { + const { sessionList, activeId, defaultSession } = get(); + if (activeId === LOBE_VIDOL_DEFAULT_AGENT_ID) { + const mergeSession = produce(defaultSession, (draft) => { + draft.config = merge(draft.config, config); + }); + set({ defaultSession: mergeSession }); + } else { + const sessions = produce(sessionList, (draft) => { + const index = draft.findIndex((session) => session.agentId === activeId); + if (index === -1) return; + draft[index].config = merge(draft[index].config, config); + }); + set({ sessionList: sessions }); + } + }, + updateSessionChatConfig: (config) => { + const { updateSessionConfig } = get(); + updateSessionConfig({ chatConfig: config }); + }, updateSessionMessages: (messages) => { const { sessionList, activeId, defaultSession } = get(); if (activeId === LOBE_VIDOL_DEFAULT_AGENT_ID) { diff --git a/src/store/session/initialState.ts b/src/store/session/initialState.ts index d2c4e1c6..bf34b41f 100644 --- a/src/store/session/initialState.ts +++ b/src/store/session/initialState.ts @@ -1,8 +1,11 @@ -import { LOBE_VIDOL_DEFAULT_AGENT_ID } from '@/constants/agent'; +import { DEFAULT_CHAT_CONFIG, LOBE_VIDOL_DEFAULT_AGENT_ID } from '@/constants/agent'; import { Session } from '@/types/session'; const defaultSession: Session = { agentId: LOBE_VIDOL_DEFAULT_AGENT_ID, + config: { + chatConfig: DEFAULT_CHAT_CONFIG, + }, messages: [], }; diff --git a/src/store/session/selectors.ts b/src/store/session/selectors.ts index 85439dc3..7bae5269 100644 --- a/src/store/session/selectors.ts +++ b/src/store/session/selectors.ts @@ -1,9 +1,10 @@ -import { LOBE_VIDOL_DEFAULT_AGENT_ID } from '@/constants/agent'; +import { DEFAULT_CHAT_CONFIG, LOBE_VIDOL_DEFAULT_AGENT_ID } from '@/constants/agent'; import { DEFAULT_USER_AVATAR } from '@/constants/common'; import { useAgentStore } from '@/store/agent'; import { useSettingStore } from '@/store/setting'; import { ChatMessage } from '@/types/chat'; import { Session } from '@/types/session'; +import { merge } from '@/utils/merge'; import { SessionStore } from './index'; @@ -15,6 +16,15 @@ const currentSession = (s: SessionStore): Session | undefined => { return sessionList.find((item) => item.agentId === activeId); }; +const currentSessionConfig = (s: SessionStore): Session['config'] => { + const session = currentSession(s); + return merge(DEFAULT_CHAT_CONFIG, session?.config); +}; + +const currentSessionChatConfig = (s: SessionStore): Session['config']['chatConfig'] => { + return currentSessionConfig(s).chatConfig || DEFAULT_CHAT_CONFIG; +}; + const sessionListIds = (s: SessionStore): string[] => { const { sessionList } = s; return sessionList.map((item) => item.agentId); @@ -133,6 +143,8 @@ export const sessionSelectors = { currentChats, currentChatsString, getChatMessageById, + currentSessionConfig, + currentSessionChatConfig, currentSession, currentSystemRole, sessionListIds, diff --git a/src/types/llm.ts b/src/types/llm.ts index ddff490b..a61a2f62 100644 --- a/src/types/llm.ts +++ b/src/types/llm.ts @@ -2,7 +2,7 @@ import { ReactNode } from 'react'; export type ModelPriceCurrency = 'CNY' | 'USD'; -export type LLMRoleType = 'user' | 'assistant' | 'system'; +export type LLMRoleType = 'user' | 'system' | 'assistant' | 'tool'; export interface SmoothingParams { speed?: number; diff --git a/src/types/session.ts b/src/types/session.ts index 84d01000..e4bff010 100644 --- a/src/types/session.ts +++ b/src/types/session.ts @@ -2,11 +2,33 @@ import { ChatMessage } from './chat'; export type ChatMode = 'camera' | 'chat' | 'call'; +export interface SessionChatConfig { + /** + * 是否启用历史消息数量限制 + */ + enableHistoryCount: boolean; + /** + * 历史消息数量限制 + */ + historyCount: number; +} + +export interface SessionConfig { + /** + * 会话配置 + */ + chatConfig: SessionChatConfig; +} + export interface Session { /** * 会话对应的 Agent ID */ agentId: string; + /** + * 会话配置 + */ + config: SessionConfig; /** * 会话消息列表 */