Skip to content

Conversation

IAmStoxe
Copy link
Contributor

Problem

Previously, when a preprompt was provided, it would completely replace any user-configured system message instead of being prepended to it.

Solution

  • Added explicit detection of existing system messages
  • When a system message exists and preprompt is defined, prepend preprompt to the existing content
  • When a system message exists and no preprompt is defined, preserve the user's message unchanged
  • When no system message exists, create one with either preprompt or empty string
  • Maintained handling for models that don't support system roles

Testing

Scenario User System Prompt Preprompt Result
1 ❌ No ❌ No System message with empty content is created
2 ❌ No ✅ Yes System message with preprompt content is created
3 ✅ Yes ❌ No User's system prompt is preserved unchanged
4 ✅ Yes ✅ Yes Preprompt + "\n\n" + User's system prompt

Breaking Changes

None - this change preserves all existing functionality while fixing the prompt handling logic.

IAmStoxe and others added 2 commits March 21, 2025 15:00
Previously, when a preprompt was provided, it would completely replace any user-configured system message instead of being prepended to it.
Copy link
Contributor

@nsarrazin nsarrazin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@nsarrazin nsarrazin merged commit 7ba7d14 into huggingface:main Apr 11, 2025
3 checks passed
csanz91 pushed a commit to csanz91/chat-ui that referenced this pull request Apr 24, 2025
huggingface#1764)

Previously, when a preprompt was provided, it would completely replace any user-configured system message instead of being prepended to it.

Co-authored-by: Nathan Sarrazin <[email protected]>
maksym-work pushed a commit to siilats/chat-ui that referenced this pull request Jul 2, 2025
huggingface#1764)

Previously, when a preprompt was provided, it would completely replace any user-configured system message instead of being prepended to it.

Co-authored-by: Nathan Sarrazin <[email protected]>
Matsenas pushed a commit to Matsenas/chat-ui that referenced this pull request Jul 4, 2025
huggingface#1764)

Previously, when a preprompt was provided, it would completely replace any user-configured system message instead of being prepended to it.

Co-authored-by: Nathan Sarrazin <[email protected]>
Matsenas pushed a commit to Matsenas/chat-ui that referenced this pull request Jul 4, 2025
huggingface#1764)

Previously, when a preprompt was provided, it would completely replace any user-configured system message instead of being prepended to it.

Co-authored-by: Nathan Sarrazin <[email protected]>
gary149 pushed a commit to gary149/chat-ui that referenced this pull request Aug 29, 2025
huggingface#1764)

Previously, when a preprompt was provided, it would completely replace any user-configured system message instead of being prepended to it.

Co-authored-by: Nathan Sarrazin <[email protected]>
gary149 pushed a commit to gary149/chat-ui that referenced this pull request Aug 29, 2025
huggingface#1764)

Previously, when a preprompt was provided, it would completely replace any user-configured system message instead of being prepended to it.

Co-authored-by: Nathan Sarrazin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants