[PR #2161] [MERGED] feat: add {{prompt:middletruncate:<length>}} to title gen #7711

Closed
opened 2025-11-11 17:33:58 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/2161
Author: @cheahjs
Created: 5/10/2024
Status: Merged
Merged: 5/14/2024
Merged by: @tjbck

Base: devHead: fix/handlebars-harden


📝 Commits (3)

  • 34a6d55 feat: add {{prompt:middletruncate:}} to title gen
  • a789b78 feat: add unit tests for prompt templates
  • 564a3a2 Merge branch 'dev' into fix/handlebars-harden

📊 Changes

6 files changed (+1128 additions, -25 deletions)

View changed files

📝 .github/workflows/format-build-frontend.yaml (+18 -0)
📝 package-lock.json (+1006 -6)
📝 package.json (+4 -2)
📝 src/lib/constants.ts (+2 -2)
src/lib/utils/index.test.ts (+66 -0)
📝 src/lib/utils/index.ts (+32 -15)

📄 Description

Pull Request Checklist

  • Target branch: Pull requests should target the dev branch.
  • Description: Briefly describe the changes in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests for the changes?
  • Code Review: Have you self-reviewed your code and addressed any coding standard issues?

Description

Adds a {{prompt:middletruncate:<length>}} placeholder for title generation to better address issues with overlapping prompts when using {{prompt:start:<length>}} with {{prompt:end:<length>}}. This also hardens the replacement logic, with all the replacements being done in one pass so it doesn't suffer from issues with placeholders containing placeholders.

As a side thing, add vitest and a GitHub Action workflow to run frontend unit tests, it's just tests for promptTemplate for now, but it will be available if anyone else wants to write unit tests.


Changelog Entry

Added

  • Prompt Template: A new {{prompt:middletruncate:<length>}} placeholder allows for truncating prompts with an ellipsis in the middle, improving title generation.
  • Unit Tests: Vitest and a GitHub Action workflow have been added to enable frontend unit testing

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/2161 **Author:** [@cheahjs](https://github.com/cheahjs) **Created:** 5/10/2024 **Status:** ✅ Merged **Merged:** 5/14/2024 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `fix/handlebars-harden` --- ### 📝 Commits (3) - [`34a6d55`](https://github.com/open-webui/open-webui/commit/34a6d5550536552130a0a4789c0cb78b9d13a160) feat: add {{prompt:middletruncate:<length>}} to title gen - [`a789b78`](https://github.com/open-webui/open-webui/commit/a789b785b477aea3579fd7c79de1eb40e212efb5) feat: add unit tests for prompt templates - [`564a3a2`](https://github.com/open-webui/open-webui/commit/564a3a293ffa3d5f3d55a2433a24344ac4465be8) Merge branch 'dev' into fix/handlebars-harden ### 📊 Changes **6 files changed** (+1128 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/format-build-frontend.yaml` (+18 -0) 📝 `package-lock.json` (+1006 -6) 📝 `package.json` (+4 -2) 📝 `src/lib/constants.ts` (+2 -2) ➕ `src/lib/utils/index.test.ts` (+66 -0) 📝 `src/lib/utils/index.ts` (+32 -15) </details> ### 📄 Description ## Pull Request Checklist - [x] **Target branch:** Pull requests should target the `dev` branch. - [x] **Description:** Briefly describe the changes in this pull request. - [ ] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [ ] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources? - [ ] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [x] **Testing:** Have you written and run sufficient tests for the changes? - [x] **Code Review:** Have you self-reviewed your code and addressed any coding standard issues? --- ## Description Adds a `{{prompt:middletruncate:<length>}}` placeholder for title generation to better address issues with overlapping prompts when using `{{prompt:start:<length>}}` with `{{prompt:end:<length>}}`. This also hardens the replacement logic, with all the replacements being done in one pass so it doesn't suffer from issues with placeholders containing placeholders. As a side thing, add `vitest` and a GitHub Action workflow to run frontend unit tests, it's just tests for `promptTemplate` for now, but it will be available if anyone else wants to write unit tests. --- ### Changelog Entry ### Added - Prompt Template: A new `{{prompt:middletruncate:<length>}}` placeholder allows for truncating prompts with an ellipsis in the middle, improving title generation. - Unit Tests: Vitest and a GitHub Action workflow have been added to enable frontend unit testing --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-11 17:33:58 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#7711