refac
This commit is contained in:
1 parent
b58b0ea7ca
commit
ab84bbf08c
2 files changed
+5
No files matched your search
@@ -916,6 +916,8 @@ RAG_FILE_MAX_COUNT = int(os.getenv('RAG_FILE_MAX_COUNT')) if os.getenv('RAG_FILE
|
|||||||
|
|
||||||
RAG_FILE_MAX_SIZE = int(os.getenv('RAG_FILE_MAX_SIZE')) if os.getenv('RAG_FILE_MAX_SIZE') else None
|
RAG_FILE_MAX_SIZE = int(os.getenv('RAG_FILE_MAX_SIZE')) if os.getenv('RAG_FILE_MAX_SIZE') else None
|
||||||
|
|
||||||
|
RAG_FILE_CONTENT_SEARCH_MAX_CHARS = int(os.getenv('RAG_FILE_CONTENT_SEARCH_MAX_CHARS', str(64 * 1024 * 1024)))
|
||||||
|
|
||||||
FILE_IMAGE_COMPRESSION_WIDTH = int(os.getenv('FILE_IMAGE_COMPRESSION_WIDTH')) if os.getenv('FILE_IMAGE_COMPRESSION_WIDTH') else None
|
FILE_IMAGE_COMPRESSION_WIDTH = int(os.getenv('FILE_IMAGE_COMPRESSION_WIDTH')) if os.getenv('FILE_IMAGE_COMPRESSION_WIDTH') else None
|
||||||
|
|
||||||
FILE_IMAGE_COMPRESSION_HEIGHT = int(os.getenv('FILE_IMAGE_COMPRESSION_HEIGHT')) if os.getenv('FILE_IMAGE_COMPRESSION_HEIGHT') else None
|
FILE_IMAGE_COMPRESSION_HEIGHT = int(os.getenv('FILE_IMAGE_COMPRESSION_HEIGHT')) if os.getenv('FILE_IMAGE_COMPRESSION_HEIGHT') else None
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import time
|
|||||||
import uuid
|
import uuid
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
from open_webui.config import RAG_FILE_CONTENT_SEARCH_MAX_CHARS
|
||||||
from open_webui.internal.db import Base, JSONField, get_async_db_context
|
from open_webui.internal.db import Base, JSONField, get_async_db_context
|
||||||
from open_webui.models.access_grants import AccessGrantModel, AccessGrants
|
from open_webui.models.access_grants import AccessGrantModel, AccessGrants
|
||||||
from open_webui.models.files import (
|
from open_webui.models.files import (
|
||||||
@@ -381,6 +382,7 @@ class KnowledgeTable:
|
|||||||
# to avoid PostgreSQL "invalid memory alloc request
|
# to avoid PostgreSQL "invalid memory alloc request
|
||||||
# size" on large extracted-content rows (#24670).
|
# size" on large extracted-content rows (#24670).
|
||||||
content_text = File.data['content'].as_string()
|
content_text = File.data['content'].as_string()
|
||||||
|
content_text = func.substr(content_text, 1, RAG_FILE_CONTENT_SEARCH_MAX_CHARS)
|
||||||
search_filter = or_(
|
search_filter = or_(
|
||||||
File.filename.ilike(f'%{q}%'),
|
File.filename.ilike(f'%{q}%'),
|
||||||
content_text.ilike(f'%{q}%'),
|
content_text.ilike(f'%{q}%'),
|
||||||
@@ -573,6 +575,7 @@ class KnowledgeTable:
|
|||||||
# to avoid PostgreSQL memory allocation failures on
|
# to avoid PostgreSQL memory allocation failures on
|
||||||
# large content (#24670).
|
# large content (#24670).
|
||||||
content_text = File.data['content'].as_string()
|
content_text = File.data['content'].as_string()
|
||||||
|
content_text = func.substr(content_text, 1, RAG_FILE_CONTENT_SEARCH_MAX_CHARS)
|
||||||
stmt = stmt.filter(
|
stmt = stmt.filter(
|
||||||
or_(
|
or_(
|
||||||
File.filename.ilike(f'%{query_key}%'),
|
File.filename.ilike(f'%{query_key}%'),
|
||||||
|
|||||||
Reference in new issue
Block a user