[PR #8281] [CLOSED] feat: VECTOR_LENGTH configurable through environment variable #37827

Closed
opened 2026-04-25 11:07:48 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/8281
Author: @binaryYuki
Created: 1/2/2025
Status: Closed

Base: devHead: main


📝 Commits (4)

  • 91b647f Make VECTOR_LENGTH configurable in pgvector.py
  • 70106e5 Merge pull request #1 from binaryYuki/configurable-vector-length
  • 7ac8c4e Update pgvector.py to use configurable vector length
  • 7573c2d Update 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

Removed

Removed static references to the hardcoded VECTOR_LENGTH to 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:


🔄 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/8281 **Author:** [@binaryYuki](https://github.com/binaryYuki) **Created:** 1/2/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `main` --- ### 📝 Commits (4) - [`91b647f`](https://github.com/open-webui/open-webui/commit/91b647f998fe4437b93ae99d60d1e2c0264d8432) Make VECTOR_LENGTH configurable in pgvector.py - [`70106e5`](https://github.com/open-webui/open-webui/commit/70106e522bd738ea134d0f5adafaab89b9531baf) Merge pull request #1 from binaryYuki/configurable-vector-length - [`7ac8c4e`](https://github.com/open-webui/open-webui/commit/7ac8c4ed3cecbb3181f3966a36a9a6ed2a15096a) Update `pgvector.py` to use configurable vector length - [`7573c2d`](https://github.com/open-webui/open-webui/commit/7573c2d42a915023a30bb6a8dc0aac3b956e1920) Update env variable name ### 📊 Changes **1 file changed** (+9 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/retrieval/vector/dbs/pgvector.py` (+9 -8) </details> ### 📄 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`](diffhunk://#diff-28a6dc0ae8b8aecb38ddec790ac95fca054271e96eb3ecf2b2cd4cf7a7c1adb2L88-R94): Updated the `adjust_vector_length` method to use `self.vector_length` instead of a hardcoded value. * [`backend/open_webui/retrieval/vector/dbs/pgvector.py`](diffhunk://#diff-28a6dc0ae8b8aecb38ddec790ac95fca054271e96eb3ecf2b2cd4cf7a7c1adb2L167-R172): Updated the `search` method to use `self.vector_length` for casting vectors. ### Removed Removed static references to the hardcoded `VECTOR_LENGTH` to 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`](diffhunk://#diff-28a6dc0ae8b8aecb38ddec790ac95fca054271e96eb3ecf2b2cd4cf7a7c1adb2R1): Imported the `os` module to access environment variables. * [`backend/open_webui/retrieval/vector/dbs/pgvector.py`](diffhunk://#diff-28a6dc0ae8b8aecb38ddec790ac95fca054271e96eb3ecf2b2cd4cf7a7c1adb2L24-R40): Modified the `vector` column in the `DocumentChunk` class to use a configurable vector length from the `VECTOR_LENGTH` environment variable, with a default of 1536. * [`backend/open_webui/retrieval/vector/dbs/pgvector.py`](diffhunk://#diff-28a6dc0ae8b8aecb38ddec790ac95fca054271e96eb3ecf2b2cd4cf7a7c1adb2L88-R94): Added `self.vector_length` to the `PgvectorClient` class to store the configurable vector length. --- <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 2026-04-25 11:07:48 -05: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#37827