fix: bugs with system prompt
This commit is contained in:
@@ -543,6 +543,27 @@ Future<String> _preseedAssistantAndPersist(
|
|||||||
return assistantMessageId;
|
return assistantMessageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String? _extractSystemPromptFromSettings(Map<String, dynamic>? settings) {
|
||||||
|
if (settings == null) return null;
|
||||||
|
|
||||||
|
final rootValue = settings['system'];
|
||||||
|
if (rootValue is String) {
|
||||||
|
final trimmed = rootValue.trim();
|
||||||
|
if (trimmed.isNotEmpty) return trimmed;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ui = settings['ui'];
|
||||||
|
if (ui is Map<String, dynamic>) {
|
||||||
|
final uiValue = ui['system'];
|
||||||
|
if (uiValue is String) {
|
||||||
|
final trimmed = uiValue.trim();
|
||||||
|
if (trimmed.isNotEmpty) return trimmed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Start a new chat (unified function for both "New Chat" button and home screen)
|
// Start a new chat (unified function for both "New Chat" button and home screen)
|
||||||
void startNewChat(dynamic ref) {
|
void startNewChat(dynamic ref) {
|
||||||
// Clear active conversation
|
// Clear active conversation
|
||||||
@@ -763,13 +784,7 @@ Future<void> regenerateMessage(
|
|||||||
String? userSystemPrompt;
|
String? userSystemPrompt;
|
||||||
try {
|
try {
|
||||||
userSettingsData = await api!.getUserSettings();
|
userSettingsData = await api!.getUserSettings();
|
||||||
final systemValue = userSettingsData?['system'];
|
userSystemPrompt = _extractSystemPromptFromSettings(userSettingsData);
|
||||||
if (systemValue is String) {
|
|
||||||
final trimmed = systemValue.trim();
|
|
||||||
if (trimmed.isNotEmpty) {
|
|
||||||
userSystemPrompt = trimmed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
|
||||||
if ((activeConversation.systemPrompt == null ||
|
if ((activeConversation.systemPrompt == null ||
|
||||||
@@ -1106,13 +1121,7 @@ Future<void> _sendMessageInternal(
|
|||||||
if (!reviewerMode && api != null) {
|
if (!reviewerMode && api != null) {
|
||||||
try {
|
try {
|
||||||
userSettingsData = await api.getUserSettings();
|
userSettingsData = await api.getUserSettings();
|
||||||
final systemValue = userSettingsData?['system'];
|
userSystemPrompt = _extractSystemPromptFromSettings(userSettingsData);
|
||||||
if (systemValue is String) {
|
|
||||||
final trimmed = systemValue.trim();
|
|
||||||
if (trimmed.isNotEmpty) {
|
|
||||||
userSystemPrompt = trimmed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user