LibreChat/api/models
Danny Avila 8bdc808074
Some checks are pending
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Waiting to run
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Waiting to run
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Waiting to run
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Waiting to run
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions
refactor: Optimize & Standardize Tokenizer Usage (#10777)
* refactor: Token Limit Processing with Enhanced Efficiency

- Added a new test suite for `processTextWithTokenLimit`, ensuring comprehensive coverage of various scenarios including under, at, and exceeding token limits.
- Refactored the `processTextWithTokenLimit` function to utilize a ratio-based estimation method, significantly reducing the number of token counting function calls compared to the previous binary search approach.
- Improved handling of edge cases and variable token density, ensuring accurate truncation and performance across diverse text inputs.
- Included direct comparisons with the old implementation to validate correctness and efficiency improvements.

* refactor: Remove Tokenizer Route and Related References

- Deleted the tokenizer route from the server and removed its references from the routes index and server files, streamlining the API structure.
- This change simplifies the routing configuration by eliminating unused endpoints.

* refactor: Migrate countTokens Utility to API Module

- Removed the local countTokens utility and integrated it into the @librechat/api module for centralized access.
- Updated various files to reference the new countTokens import from the API module, ensuring consistent usage across the application.
- Cleaned up unused references and imports related to the previous countTokens implementation.

* refactor: Centralize escapeRegExp Utility in API Module

- Moved the escapeRegExp function from local utility files to the @librechat/api module for consistent usage across the application.
- Updated imports in various files to reference the new centralized escapeRegExp function, ensuring cleaner code and reducing redundancy.
- Removed duplicate implementations of escapeRegExp from multiple files, streamlining the codebase.

* refactor: Enhance Token Counting Flexibility in Text Processing

- Updated the `processTextWithTokenLimit` function to accept both synchronous and asynchronous token counting functions, improving its versatility.
- Introduced a new `TokenCountFn` type to define the token counting function signature.
- Added comprehensive tests to validate the behavior of `processTextWithTokenLimit` with both sync and async token counting functions, ensuring consistent results.
- Implemented a wrapper to track call counts for the `countTokens` function, optimizing performance and reducing unnecessary calls.
- Enhanced existing tests to compare the performance of the new implementation against the old one, demonstrating significant improvements in efficiency.

* chore: documentation for Truncation Safety Buffer in Token Processing

- Added a safety buffer multiplier to the character position estimates during text truncation to prevent overshooting token limits.
- Updated the `processTextWithTokenLimit` function to utilize the new `TRUNCATION_SAFETY_BUFFER` constant, enhancing the accuracy of token limit processing.
- Improved documentation to clarify the rationale behind the buffer and its impact on performance and efficiency in token counting.
2025-12-02 12:22:04 -05:00
..
Action.js 🏗️ refactor: Extract DB layers to data-schemas for shared use (#7650) 2025-05-30 22:18:13 -04:00
Agent.js 🗑️ fix: Remove All User Metadata on Deletion (#10534) 2025-11-21 12:03:26 -05:00
Agent.spec.js 🏷️ fix: Add user ID to MCP tools cache keys (#10201) 2025-10-30 17:09:56 -04:00
Assistant.js 🏗️ refactor: Extract DB layers to data-schemas for shared use (#7650) 2025-05-30 22:18:13 -04:00
balanceMethods.js 🛜 refactor: Streamline App Config Usage (#9234) 2025-08-26 12:10:18 -04:00
Banner.js 🏗️ refactor: Extract DB layers to data-schemas for shared use (#7650) 2025-05-30 22:18:13 -04:00
Categories.js 🧹 chore: Cleanup Logger and Utility Imports (#9935) 2025-10-01 23:30:47 -04:00
Conversation.js 🕵️ refactor: Optimize Message Search Performance (#9818) 2025-09-24 16:27:34 -04:00
Conversation.spec.js 🛜 refactor: Streamline App Config Usage (#9234) 2025-08-26 12:10:18 -04:00
ConversationTag.js 🏷️ fix: Increment Tag Counters When Forking/Duplicating Conversations (#9737) 2025-09-19 22:02:09 -04:00
convoStructure.spec.js 🐛 fix: String Interpolation in Messages Endpoint from #9155 (#9312) 2025-08-27 13:48:48 -04:00
File.js 🔄 refactor: Convert OCR Tool Resource to Context (#9699) 2025-09-18 20:06:59 -04:00
File.spec.js 🗃️ refactor: File Access via Agent; Deny Deletion if not Editor, Allow Viewer (#9357) 2025-08-28 21:16:23 -04:00
index.js 🛜 refactor: Streamline App Config Usage (#9234) 2025-08-26 12:10:18 -04:00
interface.js 🛜 refactor: Streamline App Config Usage (#9234) 2025-08-26 12:10:18 -04:00
inviteUser.js 🪐 feat: MCP OAuth 2.0 Discovery Support (#7924) 2025-06-17 13:50:33 -04:00
Message.js 🗑️ fix: Remove All User Metadata on Deletion (#10534) 2025-11-21 12:03:26 -05:00
Message.spec.js 🛜 refactor: Streamline App Config Usage (#9234) 2025-08-26 12:10:18 -04:00
Preset.js 🏗️ refactor: Extract DB layers to data-schemas for shared use (#7650) 2025-05-30 22:18:13 -04:00
Project.js 🏗️ refactor: Extract DB layers to data-schemas for shared use (#7650) 2025-05-30 22:18:13 -04:00
Prompt.js refactor: Optimize & Standardize Tokenizer Usage (#10777) 2025-12-02 12:22:04 -05:00
Prompt.spec.js 🛂 feat: Role as Permission Principal Type 2025-08-13 16:24:23 -04:00
PromptGroupMigration.spec.js 🔧 refactor: Integrate PrincipalModel Enum for Principal Handling 2025-08-13 16:24:22 -04:00
Role.js 🗞️ refactor: Apply Role Permissions at Startup only if Missing or Configured 2025-08-13 16:24:25 -04:00
Role.spec.js 🏗️ refactor: Extract DB layers to data-schemas for shared use (#7650) 2025-05-30 22:18:13 -04:00
spendTokens.js 🧹 chore: Cleanup Logger and Utility Imports (#9935) 2025-10-01 23:30:47 -04:00
spendTokens.spec.js 🛜 refactor: Streamline App Config Usage (#9234) 2025-08-26 12:10:18 -04:00
ToolCall.js 🏗️ refactor: Extract DB layers to data-schemas for shared use (#7650) 2025-05-30 22:18:13 -04:00
Transaction.js 🗄️ feat: Allow Skipping Transactions When Balance is Disabled (#9419) 2025-09-05 11:21:02 -04:00
Transaction.spec.js 🗄️ feat: Allow Skipping Transactions When Balance is Disabled (#9419) 2025-09-05 11:21:02 -04:00
tx.js 🤖 feat: Tool Calling Support for DeepSeek V3.2 + OpenRouter Reasoning (#10752) 2025-12-01 14:27:08 -05:00
tx.spec.js 🤖 feat: Tool Calling Support for DeepSeek V3.2 + OpenRouter Reasoning (#10752) 2025-12-01 14:27:08 -05:00
userMethods.js 🛜 refactor: Streamline App Config Usage (#9234) 2025-08-26 12:10:18 -04:00