mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 02:48:13 -05:00
[PR #8281] [CLOSED] feat: VECTOR_LENGTH configurable through environment variable #8993
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/8281
Author: @binaryYuki
Created: 1/2/2025
Status: ❌ Closed
Base:
dev← Head:main📝 Commits (4)
91b647fMake VECTOR_LENGTH configurable in pgvector.py70106e5Merge pull request #1 from binaryYuki/configurable-vector-length7ac8c4eUpdatepgvector.pyto use configurable vector length7573c2dUpdate env variable name📊 Changes
1 file changed (+9 additions, -8 deletions)
View changed files
📝
backend/open_webui/retrieval/vector/dbs/pgvector.py(+9 -8)📄 Description
PR for https://github.com/open-webui/open-webui/discussions/8271
Description
This pull request introduces several updates and improvements to the backend/open_webui/retrieval/vector.py file. These changes focus on making the system more flexible and configurable by replacing hardcoded values with environment-driven configurations, improving maintainability and adaptability to different deployment environments.
The following changes were made to enhance the functionality and configuration capabilities of the retrieval/vector.py module:
Added
Import of os and int libraries from os and builtins respectively to enable environment-based configurations.
docs update: https://github.com/open-webui/docs/pull/348
Changed
backend/open_webui/retrieval/vector/dbs/pgvector.py: Updated theadjust_vector_lengthmethod to useself.vector_lengthinstead of a hardcoded value.backend/open_webui/retrieval/vector/dbs/pgvector.py: Updated thesearchmethod to useself.vector_lengthfor casting vectors.Removed
Removed static references to the hardcoded
VECTOR_LENGTHto increase adaptability and eliminate redundancy.Additional Information
Motivation: The hardcoded approach previously used for VECTOR_LENGTH restricted the flexibility of the system. Making VECTOR_LENGTH configurable allows the retrieval module to adapt to different deployments and environments without requiring code changes.
Impact: These changes improve configurability and simplify deployment across environments by leveraging environment variables.
Relevant Sections Modified:
backend/open_webui/retrieval/vector/dbs/pgvector.py: Imported theosmodule to access environment variables.backend/open_webui/retrieval/vector/dbs/pgvector.py: Modified thevectorcolumn in theDocumentChunkclass to use a configurable vector length from theVECTOR_LENGTHenvironment variable, with a default of 1536.backend/open_webui/retrieval/vector/dbs/pgvector.py: Addedself.vector_lengthto thePgvectorClientclass to store the configurable vector length.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.