Skip to content

Commit e802f40

Browse files
committed
Updated the version number to 0.0.70, added new strings for multilingual support, including “Switch Sidebar,” “Delete Chat,” “Select All,” “New Chat,” “Send,” and “More.” At the same time, fixed the formatting issue with the “Data Synchronization” string and made corresponding updates in the relevant files.
1 parent 124ea8a commit e802f40

15 files changed

Lines changed: 214 additions & 101 deletions

lib/generated/app_localizations.dart

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,42 @@ abstract class AppLocalizations {
17001700
/// In en, this message translates to:
17011701
/// **'In Memory'**
17021702
String get inmemory;
1703+
1704+
/// No description provided for @toggleSidebar.
1705+
///
1706+
/// In en, this message translates to:
1707+
/// **'Toggle Sidebar'**
1708+
String get toggleSidebar;
1709+
1710+
/// No description provided for @deleteChat.
1711+
///
1712+
/// In en, this message translates to:
1713+
/// **'Delete Chat'**
1714+
String get deleteChat;
1715+
1716+
/// No description provided for @selectAll.
1717+
///
1718+
/// In en, this message translates to:
1719+
/// **'Select All'**
1720+
String get selectAll;
1721+
1722+
/// No description provided for @newChat.
1723+
///
1724+
/// In en, this message translates to:
1725+
/// **'New Chat'**
1726+
String get newChat;
1727+
1728+
/// No description provided for @send.
1729+
///
1730+
/// In en, this message translates to:
1731+
/// **'Send'**
1732+
String get send;
1733+
1734+
/// No description provided for @more.
1735+
///
1736+
/// In en, this message translates to:
1737+
/// **'More'**
1738+
String get more;
17031739
}
17041740

17051741
class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {

lib/generated/app_localizations_en.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,4 +854,22 @@ class AppLocalizationsEn extends AppLocalizations {
854854

855855
@override
856856
String get inmemory => 'In Memory';
857+
858+
@override
859+
String get toggleSidebar => 'Toggle Sidebar';
860+
861+
@override
862+
String get deleteChat => 'Delete Chat';
863+
864+
@override
865+
String get selectAll => 'Select All';
866+
867+
@override
868+
String get newChat => 'New Chat';
869+
870+
@override
871+
String get send => 'Send';
872+
873+
@override
874+
String get more => 'More';
857875
}

lib/generated/app_localizations_tr.dart

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ class AppLocalizationsTr extends AppLocalizations {
627627
String get saved => 'Kaydedildi';
628628

629629
@override
630-
String get dataSync => 'Veri Senkronizasyonu:';
630+
String get dataSync => 'Veri Senkronizasyonu';
631631

632632
@override
633633
String get syncServerRunning => 'Senkronizasyon sunucusu çalışıyor';
@@ -853,4 +853,22 @@ class AppLocalizationsTr extends AppLocalizations {
853853

854854
@override
855855
String get inmemory => 'En Memoria';
856+
857+
@override
858+
String get toggleSidebar => 'Kenar Çubuğunu Değiştir';
859+
860+
@override
861+
String get deleteChat => 'Sohbeti Sil';
862+
863+
@override
864+
String get selectAll => 'Tümünü Seç';
865+
866+
@override
867+
String get newChat => 'Yeni Sohbet';
868+
869+
@override
870+
String get send => 'Gönder';
871+
872+
@override
873+
String get more => 'Daha Fazla';
856874
}

lib/generated/app_localizations_zh.dart

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ class AppLocalizationsZh extends AppLocalizations {
621621
String get saved => '已保存';
622622

623623
@override
624-
String get dataSync => '数据同步';
624+
String get dataSync => '数据同步';
625625

626626
@override
627627
String get syncServerRunning => '同步服务器运行中';
@@ -847,4 +847,22 @@ class AppLocalizationsZh extends AppLocalizations {
847847

848848
@override
849849
String get inmemory => '内置';
850+
851+
@override
852+
String get toggleSidebar => '切换侧边栏';
853+
854+
@override
855+
String get deleteChat => '删除聊天';
856+
857+
@override
858+
String get selectAll => '全选';
859+
860+
@override
861+
String get newChat => '新聊天';
862+
863+
@override
864+
String get send => '发送';
865+
866+
@override
867+
String get more => '更多';
850868
}

lib/l10n/app_en.arb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,5 +270,11 @@
270270
"clearAllConnectionHistory": "All connection history cleared",
271271
"unknownDevice": "Unknown Device",
272272
"unknownPlatform": "Unknown Platform",
273-
"inmemory": "In Memory"
273+
"inmemory": "In Memory",
274+
"toggleSidebar": "Toggle Sidebar",
275+
"deleteChat": "Delete Chat",
276+
"selectAll": "Select All",
277+
"newChat": "New Chat",
278+
"send": "Send",
279+
"more": "More"
274280
}

lib/l10n/app_tr.arb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
"mobileStep1": "1. \"QR Kod Tarayarak Bağlan\" düğmesine tıklayın",
230230
"mobileStep2": "2. Masaüstünde gösterilen QR kodu tarayın",
231231
"mobileStep3": "3. Senkronizasyon yönünü seçin (yükleme/indirme)",
232-
"dataSync": "Veri Senkronizasyonu:",
232+
"dataSync": "Veri Senkronizasyonu",
233233
"uploadDescription": "• Yükleme: Yerel cihaz verilerini sunucuya gönder",
234234
"downloadDescription": "• İndirme: Sunucudan yerel cihaza veri al",
235235
"syncContent": "• Senkronizasyon İçeriği: Sohbet geçmişi, ayarlar, MCP yapılandırmaları",
@@ -270,5 +270,11 @@
270270
"clearAllConnectionHistory": "Tüm bağlantı geçmişi temizlendi",
271271
"unknownDevice": "Bilinmeyen Cihaz",
272272
"unknownPlatform": "Bilinmeyen Platform",
273-
"inmemory": "En Memoria"
273+
"inmemory": "En Memoria",
274+
"toggleSidebar": "Kenar Çubuğunu Değiştir",
275+
"deleteChat": "Sohbeti Sil",
276+
"selectAll": "Tümünü Seç",
277+
"newChat": "Yeni Sohbet",
278+
"send": "Gönder",
279+
"more": "Daha Fazla"
274280
}

lib/l10n/app_zh.arb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
"mobileStep1": "1. 点击\"扫描二维码连接\"",
230230
"mobileStep2": "2. 扫描桌面端显示的二维码",
231231
"mobileStep3": "3. 选择同步方向(上传/下载)",
232-
"dataSync": "数据同步",
232+
"dataSync": "数据同步",
233233
"uploadDescription": "• 上传:将本设备数据推送到服务器",
234234
"downloadDescription": "• 下载:从服务器获取数据到本设备",
235235
"syncContent": "• 同步内容:聊天记录、设置、MCP配置",
@@ -270,5 +270,11 @@
270270
"clearAllConnectionHistory": "已清空所有连接历史",
271271
"unknownDevice": "未知设备",
272272
"unknownPlatform": "未知平台",
273-
"inmemory": "内置"
273+
"inmemory": "内置",
274+
"toggleSidebar": "切换侧边栏",
275+
"deleteChat": "删除聊天",
276+
"selectAll": "全选",
277+
"newChat": "新聊天",
278+
"send": "发送",
279+
"more": "更多"
274280
}

lib/llm/ollama_client.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ class OllamaClient extends BaseLLMClient {
121121
body['tool_choice'] = 'auto';
122122
}
123123

124+
Logger.root.fine('Ollama request: ${jsonEncode(body)}');
125+
124126
try {
125127
final request = http.Request('POST', Uri.parse("$baseUrl/v1/chat/completions"));
126128
request.headers.addAll(_headers);

lib/llm/prompt.dart

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
import 'dart:convert';
22

3+
import 'package:chatmcp/provider/provider_manager.dart';
4+
35
class SystemPromptGenerator {
4-
/// Default prompt template
5-
final String template = '''
6+
/// Base prompt template without tool instructions
7+
final String baseTemplate = '''
68
<system_prompt>
79
You will select appropriate tools and call them to solve user queries
810
911
**CRITICAL CONSTRAINT: You MUST call only ONE tool per response. Never call multiple tools simultaneously.**
10-
</system_prompt>
12+
</system_prompt>''';
13+
14+
/// Tool-related template parts
15+
final String toolDefinitionsTemplate = '''
1116
1217
**Tool Definitions:**
1318
Here are the functions available, described in JSONSchema format:
1419
<tool_definitions>
1520
{{ TOOL DEFINITIONS IN JSON SCHEMA }}
16-
</tool_definitions>
21+
</tool_definitions>''';
22+
23+
final String toolUsageTemplate = '''
1724
1825
<tool_usage_instructions>
1926
TOOL USE
@@ -40,12 +47,10 @@ For example:
4047
</function>
4148
4249
Always adhere to this format for the tool use to ensure proper parsing and execution.
43-
</tool_usage_instructions>
44-
''';
50+
</tool_usage_instructions>''';
4551

4652
/// Default user system prompt
47-
final String defaultUserSystemPrompt =
48-
'You are an intelligent assistant capable of using tools to solve user queries effectively.';
53+
final String defaultUserSystemPrompt = 'You are an intelligent assistant capable of using tools to solve user queries effectively.';
4954

5055
/// Default tool configuration
5156
final String defaultToolConfig = 'No additional configuration is required.';
@@ -58,16 +63,28 @@ Always adhere to this format for the tool use to ensure proper parsing and execu
5863
String generatePrompt({
5964
required List<Map<String, dynamic>> tools,
6065
}) {
61-
// Use provided values or defaults
62-
final finalUserPrompt = defaultUserSystemPrompt;
66+
// Start with base template
67+
68+
var userPrompt = ProviderManager.settingsProvider.generalSetting.systemPrompt;
69+
70+
var language = ProviderManager.settingsProvider.generalSetting.locale;
71+
72+
var prompt = "$userPrompt\n$baseTemplate";
73+
if (language.isNotEmpty) {
74+
prompt += "\n\nLanguage: $language";
75+
}
76+
77+
// Only add tool-related sections if tools are available
78+
if (tools.isNotEmpty) {
79+
// Convert tools JSON to formatted string
80+
final toolsJsonSchema = const JsonEncoder.withIndent(' ').convert(tools);
6381

64-
// Convert tools JSON to formatted string
65-
final toolsJsonSchema = const JsonEncoder.withIndent(' ').convert(tools);
82+
// Add tool definitions section
83+
prompt += toolDefinitionsTemplate.replaceAll('{{ TOOL DEFINITIONS IN JSON SCHEMA }}', toolsJsonSchema);
6684

67-
// Replace placeholders in template
68-
var prompt = template
69-
.replaceAll('{{ TOOL DEFINITIONS IN JSON SCHEMA }}', toolsJsonSchema)
70-
.replaceAll('{{ USER SYSTEM PROMPT }}', finalUserPrompt);
85+
// Add tool usage instructions
86+
prompt += toolUsageTemplate;
87+
}
7188

7289
return prompt;
7390
}

0 commit comments

Comments
 (0)