mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-03 18:17:56 -05:00
fix: info logs flooded by per-request trace lines (#35538)
The info log was filled with step-by-step lines that fire on every chat with knowledge or web search, chat search, file upload, document parsing, knowledge base update or search, image generation, note chat and collaborative note editing, so running at INFO in production buried the lines an admin actually needs. Every sign-in also wrote the user's email address to the info log. These lines, the email one included, now only show with GLOBAL_LOG_LEVEL=DEBUG. Results such as documents added to or removed from the vector database and admin actions keep their line at info. A few unused internal leftovers are removed, which no setting or feature relied on. Fixes #35535
This commit is contained in:
1 parent
1924c30ff5
commit
03cdec3fab
25 files changed
+126
-209
No files matched your search
@@ -298,7 +298,7 @@ class AuthsTable:
|
||||
) -> UserModel | None:
|
||||
"""Create an Auth + User pair inside a single transaction."""
|
||||
async with get_async_db_context(db) as session:
|
||||
log.info('insert_new_auth')
|
||||
log.debug('insert_new_auth')
|
||||
|
||||
new_id = str(uuid.uuid4())
|
||||
|
||||
@@ -334,7 +334,7 @@ class AuthsTable:
|
||||
db: AsyncSession | None = None,
|
||||
) -> tuple[UserModel, AuthModel] | None:
|
||||
"""Verify email + password credentials and return the matching user."""
|
||||
log.info('authenticate_user: %s', email)
|
||||
log.debug('authenticate_user: %s', email)
|
||||
resolved = await Users.get_user_by_email(email, db=db)
|
||||
if not resolved:
|
||||
await verify_password(PLACEHOLDER_HASH)
|
||||
@@ -349,25 +349,13 @@ class AuthsTable:
|
||||
return
|
||||
return resolved, AuthModel.model_validate(credential)
|
||||
|
||||
async def authenticate_user_by_api_key(
|
||||
self,
|
||||
api_key: str,
|
||||
db: AsyncSession | None = None,
|
||||
) -> UserModel | None:
|
||||
"""Look up the user that owns the given API key."""
|
||||
log.info('authenticate_user_by_api_key')
|
||||
if not api_key:
|
||||
return
|
||||
# delegate to the Users model for the actual lookup
|
||||
return await Users.get_user_by_api_key(api_key, db=db)
|
||||
|
||||
async def authenticate_user_by_email(
|
||||
self,
|
||||
email: str,
|
||||
db: AsyncSession | None = None,
|
||||
) -> UserModel | None:
|
||||
"""Single-query auth via JOIN on Auth ↔ User, filtered by active flag."""
|
||||
log.info('authenticate_user_by_email: %s', email)
|
||||
log.debug('authenticate_user_by_email: %s', email)
|
||||
# single JOIN avoids N+1 — returns (Auth, User) tuple or None
|
||||
async with get_async_db_context(db) as session:
|
||||
joined_query = (
|
||||
|
||||
@@ -2404,7 +2404,7 @@ class ChatTable:
|
||||
result = await session.execute(stmt)
|
||||
all_chats = result.mappings().all()
|
||||
|
||||
log.info('The number of chats: %s', len(all_chats))
|
||||
log.debug('The number of chats: %s', len(all_chats))
|
||||
|
||||
# Validate and return chats
|
||||
return [ChatTitleIdResponse.model_validate(chat) for chat in all_chats]
|
||||
@@ -2919,17 +2919,6 @@ class ChatTable:
|
||||
for chat in all_chats
|
||||
]
|
||||
|
||||
async def count_chats_by_folder_id_and_user_id(
|
||||
self, folder_id: str, user_id: str, db: AsyncSession | None = None
|
||||
) -> int:
|
||||
async with get_async_db_context(db) as session:
|
||||
stmt = select(func.count(Chat.id)).filter_by(user_id=user_id, folder_id=folder_id)
|
||||
result = await session.execute(stmt.where(Chat.meta['internal'].as_boolean().is_not(True)))
|
||||
count = result.scalar()
|
||||
|
||||
log.info("Count of chats for folder '%s': %s", folder_id, count)
|
||||
return count
|
||||
|
||||
async def count_chats_by_folder_ids_and_user_id(
|
||||
self, folder_ids: list[str], user_id: str, db: AsyncSession | None = None
|
||||
) -> int:
|
||||
|
||||
@@ -85,7 +85,7 @@ class DatalabMarkerLoader:
|
||||
if self.additional_config and self.additional_config.strip():
|
||||
form_data['additional_config'] = self.additional_config
|
||||
|
||||
log.info(
|
||||
log.debug(
|
||||
"Datalab Marker POST request parameters: {'filename': '%s', 'mime_type': '%s', **%s}",
|
||||
filename,
|
||||
mime_type,
|
||||
@@ -183,7 +183,7 @@ class DatalabMarkerLoader:
|
||||
else:
|
||||
# Self-hosted direct response - content in "output" field
|
||||
if 'output' in result:
|
||||
log.info('Self-hosted Marker returned direct response without polling')
|
||||
log.debug('Self-hosted Marker returned direct response without polling')
|
||||
raw_content = result.get('output')
|
||||
final_result = result
|
||||
else:
|
||||
@@ -220,7 +220,7 @@ class DatalabMarkerLoader:
|
||||
try:
|
||||
with open(output_path, 'w', encoding='utf-8') as f:
|
||||
f.write(full_text)
|
||||
log.info('Saved Marker output to: %s', output_path)
|
||||
log.debug('Saved Marker output to: %s', output_path)
|
||||
except Exception as e:
|
||||
log.warning(f'Failed to write marker output to disk: {e}')
|
||||
|
||||
|
||||
@@ -473,7 +473,7 @@ class Loader:
|
||||
try:
|
||||
text = raw.decode(enc)
|
||||
if text.strip() and self._has_cjk_characters(text):
|
||||
log.info(
|
||||
log.debug(
|
||||
'Detected encoding %s for %s (chardet guessed %s)',
|
||||
enc,
|
||||
file_path,
|
||||
@@ -489,7 +489,7 @@ class Loader:
|
||||
if chardet_encoding:
|
||||
try:
|
||||
raw.decode(chardet_encoding)
|
||||
log.info(
|
||||
log.debug(
|
||||
'Using chardet-detected encoding %s for %s',
|
||||
chardet_encoding,
|
||||
file_path,
|
||||
|
||||
@@ -154,7 +154,7 @@ class MinerULoader:
|
||||
Load document using Local API (synchronous).
|
||||
Posts file to /file_parse endpoint and gets immediate response.
|
||||
"""
|
||||
log.info('Using MinerU Local API at %s', self.api_url)
|
||||
log.debug('Using MinerU Local API at %s', self.api_url)
|
||||
|
||||
filename = os.path.basename(self.file_path)
|
||||
|
||||
@@ -178,7 +178,7 @@ class MinerULoader:
|
||||
with open(self.file_path, 'rb') as f:
|
||||
files = {'files': (filename, f, 'application/octet-stream')}
|
||||
|
||||
log.info('Sending file to MinerU Local API: %s', filename)
|
||||
log.debug('Sending file to MinerU Local API: %s', filename)
|
||||
log.debug('Local API parameters: %s', form_data)
|
||||
|
||||
response = requests.post(
|
||||
@@ -277,7 +277,7 @@ class MinerULoader:
|
||||
Load document using the MinerU 4.x V1 API (asynchronous).
|
||||
Uploads the file, submits a parse job, polls it and downloads the markdown.
|
||||
"""
|
||||
log.info('Using MinerU V1 API at %s', self.api_url)
|
||||
log.debug('Using MinerU V1 API at %s', self.api_url)
|
||||
|
||||
filename = os.path.basename(self.file_path)
|
||||
|
||||
@@ -309,7 +309,7 @@ class MinerULoader:
|
||||
},
|
||||
).json()
|
||||
|
||||
log.info('Polling MinerU V1 job: %s', job['job_id'])
|
||||
log.debug('Polling MinerU V1 job: %s', job['job_id'])
|
||||
deadline = time.monotonic() + self.timeout if self.timeout else None
|
||||
while job['status'] in ['queued', 'running']:
|
||||
if deadline and time.monotonic() > deadline:
|
||||
@@ -351,7 +351,7 @@ class MinerULoader:
|
||||
|
||||
def _load_tasks_api(self) -> List[Document]:
|
||||
"""Load document using the MinerU 4.1 Tasks API (asynchronous)."""
|
||||
log.info('Using MinerU Tasks API at %s', self.api_url)
|
||||
log.debug('Using MinerU Tasks API at %s', self.api_url)
|
||||
|
||||
filename = os.path.basename(self.file_path)
|
||||
|
||||
@@ -373,7 +373,7 @@ class MinerULoader:
|
||||
with open(self.file_path, 'rb') as f:
|
||||
self._request_v1_api('PUT', upload['url'], headers=upload['headers'], data=f)
|
||||
|
||||
log.info('Polling MinerU task: %s', task['task_id'])
|
||||
log.debug('Polling MinerU task: %s', task['task_id'])
|
||||
deadline = time.monotonic() + self.timeout if self.timeout else None
|
||||
while True:
|
||||
task = self._request_v1_api('GET', f'/v1/tasks/{task["task_id"]}').json()
|
||||
@@ -441,7 +441,7 @@ class MinerULoader:
|
||||
Load document using Cloud API (asynchronous).
|
||||
Uses batch upload endpoint to avoid need for public file URLs.
|
||||
"""
|
||||
log.info('Using MinerU Cloud API at %s', self.api_url)
|
||||
log.debug('Using MinerU Cloud API at %s', self.api_url)
|
||||
|
||||
filename = os.path.basename(self.file_path)
|
||||
|
||||
@@ -493,7 +493,7 @@ class MinerULoader:
|
||||
if self.page_ranges:
|
||||
request_body['files'][0]['page_ranges'] = self.page_ranges
|
||||
|
||||
log.info('Requesting upload URL for: %s', filename)
|
||||
log.debug('Requesting upload URL for: %s', filename)
|
||||
log.debug('Cloud API request body: %s', request_body)
|
||||
|
||||
try:
|
||||
@@ -545,7 +545,7 @@ class MinerULoader:
|
||||
)
|
||||
|
||||
upload_url = file_urls[0]
|
||||
log.info('Received upload URL for batch: %s', batch_id)
|
||||
log.debug('Received upload URL for batch: %s', batch_id)
|
||||
|
||||
return batch_id, upload_url
|
||||
|
||||
@@ -553,7 +553,7 @@ class MinerULoader:
|
||||
"""
|
||||
Upload file to presigned URL (no authentication needed).
|
||||
"""
|
||||
log.info(f'Uploading file to presigned URL')
|
||||
log.debug('Uploading file to presigned URL')
|
||||
|
||||
try:
|
||||
with open(self.file_path, 'rb') as f:
|
||||
@@ -581,7 +581,7 @@ class MinerULoader:
|
||||
detail=f'Error uploading file: {str(e)}',
|
||||
)
|
||||
|
||||
log.info('File uploaded successfully')
|
||||
log.debug('File uploaded successfully')
|
||||
|
||||
def _poll_batch_status(self, batch_id: str, filename: str) -> dict:
|
||||
"""
|
||||
@@ -595,7 +595,7 @@ class MinerULoader:
|
||||
max_iterations = 300 # 10 minutes max (2 seconds per iteration)
|
||||
poll_interval = 2 # seconds
|
||||
|
||||
log.info('Polling batch status: %s', batch_id)
|
||||
log.debug('Polling batch status: %s', batch_id)
|
||||
|
||||
for iteration in range(max_iterations):
|
||||
try:
|
||||
@@ -654,7 +654,7 @@ class MinerULoader:
|
||||
state = file_result.get('state')
|
||||
|
||||
if state == 'done':
|
||||
log.info('Processing complete for %s', filename)
|
||||
log.debug('Processing complete for %s', filename)
|
||||
return file_result
|
||||
elif state == 'failed':
|
||||
error_msg = file_result.get('err_msg', 'Unknown error')
|
||||
@@ -665,7 +665,7 @@ class MinerULoader:
|
||||
elif state in ['waiting-file', 'pending', 'running', 'converting']:
|
||||
# Still processing
|
||||
if iteration % 10 == 0: # Log every 20 seconds
|
||||
log.info('Processing status: %s (iteration %s/%s)', state, iteration + 1, max_iterations)
|
||||
log.debug('Processing status: %s (iteration %s/%s)', state, iteration + 1, max_iterations)
|
||||
time.sleep(poll_interval)
|
||||
else:
|
||||
log.warning(f'Unknown state: {state}')
|
||||
@@ -682,7 +682,7 @@ class MinerULoader:
|
||||
Download ZIP file from CDN and extract markdown content.
|
||||
Returns the markdown content as a string.
|
||||
"""
|
||||
log.info('Downloading results from: %s', zip_url)
|
||||
log.debug('Downloading results from: %s', zip_url)
|
||||
|
||||
try:
|
||||
headers = (
|
||||
@@ -718,7 +718,7 @@ class MinerULoader:
|
||||
read_errors = []
|
||||
|
||||
for member in md_members:
|
||||
log.info('Found markdown file in ZIP: %s', member.filename)
|
||||
log.debug('Found markdown file in ZIP: %s', member.filename)
|
||||
try:
|
||||
with zip_ref.open(member, 'r') as f:
|
||||
if self.max_markdown_bytes is None:
|
||||
@@ -790,5 +790,5 @@ class MinerULoader:
|
||||
detail='Extracted markdown content is empty',
|
||||
)
|
||||
|
||||
log.info('Successfully extracted markdown content (%s characters)', len(markdown_content))
|
||||
log.debug('Successfully extracted markdown content (%s characters)', len(markdown_content))
|
||||
return markdown_content
|
||||
@@ -178,7 +178,7 @@ class MistralLoader:
|
||||
Although streaming is not enabled for this endpoint, the file is opened
|
||||
in a context manager to minimize memory usage duration.
|
||||
"""
|
||||
log.info('Uploading file to Mistral API')
|
||||
log.debug('Uploading file to Mistral API')
|
||||
url = f'{self.base_url}/files'
|
||||
|
||||
def upload_request():
|
||||
@@ -206,7 +206,7 @@ class MistralLoader:
|
||||
file_id = response_data.get('id')
|
||||
if not file_id:
|
||||
raise ValueError('File ID not found in upload response.')
|
||||
log.info('File uploaded successfully. File ID: %s', file_id)
|
||||
log.debug('File uploaded successfully. File ID: %s', file_id)
|
||||
return file_id
|
||||
except Exception as e:
|
||||
log.error(f'Failed to upload file: {e}')
|
||||
@@ -214,7 +214,7 @@ class MistralLoader:
|
||||
|
||||
def _get_signed_url(self, file_id: str) -> str:
|
||||
"""Retrieves a temporary signed URL for the uploaded file."""
|
||||
log.info('Getting signed URL for file ID: %s', file_id)
|
||||
log.debug('Getting signed URL for file ID: %s', file_id)
|
||||
url = f'{self.base_url}/files/{file_id}/url'
|
||||
params = {'expiry': 1}
|
||||
signed_url_headers = {**self.headers, 'Accept': 'application/json'}
|
||||
@@ -228,7 +228,7 @@ class MistralLoader:
|
||||
signed_url = response_data.get('url')
|
||||
if not signed_url:
|
||||
raise ValueError('Signed URL not found in response.')
|
||||
log.info('Signed URL received.')
|
||||
log.debug('Signed URL received.')
|
||||
return signed_url
|
||||
except Exception as e:
|
||||
log.error(f'Failed to get signed URL: {e}')
|
||||
@@ -236,7 +236,7 @@ class MistralLoader:
|
||||
|
||||
def _process_ocr(self, signed_url: str) -> Dict[str, Any]:
|
||||
"""Sends the signed URL to the OCR endpoint for processing."""
|
||||
log.info('Processing OCR via Mistral API')
|
||||
log.debug('Processing OCR via Mistral API')
|
||||
url = f'{self.base_url}/ocr'
|
||||
ocr_headers = {
|
||||
**self.headers,
|
||||
@@ -259,7 +259,7 @@ class MistralLoader:
|
||||
|
||||
try:
|
||||
ocr_response = self._retry_request_sync(ocr_request)
|
||||
log.info('OCR processing done.')
|
||||
log.debug('OCR processing done.')
|
||||
self._debug_log('OCR response: %s', ocr_response)
|
||||
return ocr_response
|
||||
except Exception as e:
|
||||
@@ -273,13 +273,13 @@ class MistralLoader:
|
||||
|
||||
def _delete_file(self, file_id: str) -> None:
|
||||
"""Deletes the file from Mistral storage."""
|
||||
log.info('Deleting uploaded file ID: %s', file_id)
|
||||
log.debug('Deleting uploaded file ID: %s', file_id)
|
||||
url = f'{self.base_url}/files/{file_id}'
|
||||
|
||||
try:
|
||||
response = requests.delete(url, headers=self.headers, timeout=self.cleanup_timeout)
|
||||
delete_response = self._handle_response(response)
|
||||
log.info('File deleted successfully: %s', delete_response)
|
||||
log.debug('File deleted successfully: %s', delete_response)
|
||||
except Exception as e:
|
||||
# Log error but don't necessarily halt execution if deletion fails
|
||||
log.error(f'Failed to delete file ID {file_id}: {e}')
|
||||
|
||||
@@ -35,7 +35,7 @@ class PaddleOCRVLLoader:
|
||||
self.file_name = os.path.basename(file_path)
|
||||
|
||||
def load(self) -> List[Document]:
|
||||
log.info('Processing with PaddleOCR-vl: %s', self.file_path)
|
||||
log.debug('Processing with PaddleOCR-vl: %s', self.file_path)
|
||||
|
||||
try:
|
||||
with open(self.file_path, 'rb') as file:
|
||||
|
||||
@@ -35,7 +35,7 @@ class ExternalReranker(BaseReranker):
|
||||
}
|
||||
|
||||
try:
|
||||
log.info('ExternalReranker:predict:model %s', self.model)
|
||||
log.debug('ExternalReranker:predict:model %s', self.model)
|
||||
|
||||
headers = {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
@@ -833,7 +833,7 @@ async def query_collection_with_hybrid_search(
|
||||
|
||||
collection_results = dict(await asyncio.gather(*(_fetch_collection(name) for name in collection_names)))
|
||||
|
||||
log.info('Starting hybrid search for %s queries in %s collections...', len(queries), len(collection_names))
|
||||
log.debug('Starting hybrid search for %s queries in %s collections...', len(queries), len(collection_names))
|
||||
|
||||
async def process_query(collection_name, query):
|
||||
try:
|
||||
|
||||
@@ -360,7 +360,7 @@ class MilvusClient(VectorDBBase):
|
||||
index_type = MILVUS_INDEX_TYPE.upper()
|
||||
metric_type = MILVUS_METRIC_TYPE.upper()
|
||||
|
||||
log.info('Using Milvus index type: %s, metric type: %s', index_type, metric_type)
|
||||
log.debug('Using Milvus index type: %s, metric type: %s', index_type, metric_type)
|
||||
|
||||
index_creation_params = {}
|
||||
if index_type == 'HNSW':
|
||||
@@ -368,18 +368,18 @@ class MilvusClient(VectorDBBase):
|
||||
'M': MILVUS_HNSW_M,
|
||||
'efConstruction': MILVUS_HNSW_EFCONSTRUCTION,
|
||||
}
|
||||
log.info('HNSW params: %s', index_creation_params)
|
||||
log.debug('HNSW params: %s', index_creation_params)
|
||||
elif index_type == 'IVF_FLAT':
|
||||
index_creation_params = {'nlist': MILVUS_IVF_FLAT_NLIST}
|
||||
log.info('IVF_FLAT params: %s', index_creation_params)
|
||||
log.debug('IVF_FLAT params: %s', index_creation_params)
|
||||
elif index_type == 'DISKANN':
|
||||
index_creation_params = {
|
||||
'max_degree': MILVUS_DISKANN_MAX_DEGREE,
|
||||
'search_list_size': MILVUS_DISKANN_SEARCH_LIST_SIZE,
|
||||
}
|
||||
log.info('DISKANN params: %s', index_creation_params)
|
||||
log.debug('DISKANN params: %s', index_creation_params)
|
||||
elif index_type in ['FLAT', 'AUTOINDEX']:
|
||||
log.info('Using %s index with no specific build-time params.', index_type)
|
||||
log.debug('Using %s index with no specific build-time params.', index_type)
|
||||
else:
|
||||
log.warning(
|
||||
f"Unsupported MILVUS_INDEX_TYPE: '{index_type}'. "
|
||||
@@ -507,7 +507,7 @@ class MilvusClient(VectorDBBase):
|
||||
self.client.load_collection(collection_name=f'{self.collection_prefix}_{collection_name}')
|
||||
|
||||
try:
|
||||
log.info(
|
||||
log.debug(
|
||||
"Querying collection %s_%s with filter: '%s', limit: %s",
|
||||
self.collection_prefix,
|
||||
collection_name,
|
||||
@@ -558,7 +558,7 @@ class MilvusClient(VectorDBBase):
|
||||
# Insert the items into the collection, if the collection does not exist, it will be created.
|
||||
collection_name = collection_name.replace('-', '_')
|
||||
if not self.client.has_collection(collection_name=f'{self.collection_prefix}_{collection_name}'):
|
||||
log.info('Collection %s_%s does not exist. Creating now.', self.collection_prefix, collection_name)
|
||||
log.debug('Collection %s_%s does not exist. Creating now.', self.collection_prefix, collection_name)
|
||||
if not items:
|
||||
log.error(
|
||||
f'Cannot create collection {self.collection_prefix}_{collection_name} without items to determine dimension.'
|
||||
@@ -566,7 +566,7 @@ class MilvusClient(VectorDBBase):
|
||||
raise ValueError('Cannot create Milvus collection without items to determine vector dimension.')
|
||||
self._create_collection(collection_name=collection_name, dimension=len(items[0]['vector']))
|
||||
|
||||
log.info('Inserting %s items into collection %s_%s.', len(items), self.collection_prefix, collection_name)
|
||||
log.debug('Inserting %s items into collection %s_%s.', len(items), self.collection_prefix, collection_name)
|
||||
has_bm25 = _has_bm25_field(self.client, f'{self.collection_prefix}_{collection_name}')
|
||||
data = []
|
||||
for item in items:
|
||||
@@ -597,7 +597,7 @@ class MilvusClient(VectorDBBase):
|
||||
# Update the items in the collection, if the items are not present, insert them. If the collection does not exist, it will be created.
|
||||
collection_name = collection_name.replace('-', '_')
|
||||
if not self.client.has_collection(collection_name=f'{self.collection_prefix}_{collection_name}'):
|
||||
log.info(
|
||||
log.debug(
|
||||
'Collection %s_%s does not exist for upsert. Creating now.', self.collection_prefix, collection_name
|
||||
)
|
||||
if not items:
|
||||
@@ -609,7 +609,7 @@ class MilvusClient(VectorDBBase):
|
||||
)
|
||||
self._create_collection(collection_name=collection_name, dimension=len(items[0]['vector']))
|
||||
|
||||
log.info('Upserting %s items into collection %s_%s.', len(items), self.collection_prefix, collection_name)
|
||||
log.debug('Upserting %s items into collection %s_%s.', len(items), self.collection_prefix, collection_name)
|
||||
has_bm25 = _has_bm25_field(self.client, f'{self.collection_prefix}_{collection_name}')
|
||||
data = []
|
||||
for item in items:
|
||||
|
||||
@@ -185,7 +185,7 @@ class OpenGaussClient(VectorDBBase):
|
||||
new_items.append(new_chunk)
|
||||
self.session.bulk_save_objects(new_items)
|
||||
self.session.commit()
|
||||
log.info("Inserting %s items into collection '%s'.", len(new_items), collection_name)
|
||||
log.debug("Inserting %s items into collection '%s'.", len(new_items), collection_name)
|
||||
except Exception as e:
|
||||
self.session.rollback()
|
||||
log.exception(f'Failed to insert data: {e}')
|
||||
@@ -211,7 +211,7 @@ class OpenGaussClient(VectorDBBase):
|
||||
)
|
||||
self.session.add(new_chunk)
|
||||
self.session.commit()
|
||||
log.info("Inserting/updating %s items in collection '%s'.", len(items), collection_name)
|
||||
log.debug("Inserting/updating %s items in collection '%s'.", len(items), collection_name)
|
||||
except Exception as e:
|
||||
self.session.rollback()
|
||||
log.exception(f'Failed to insert or update data.: {e}')
|
||||
|
||||
@@ -33,7 +33,6 @@ import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import threading
|
||||
import time
|
||||
from decimal import Decimal
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
@@ -185,65 +184,6 @@ class Oracle23aiClient(VectorDBBase):
|
||||
else:
|
||||
raise
|
||||
|
||||
def start_health_monitor(self, interval_seconds: int = 60):
|
||||
"""
|
||||
Start a background thread to periodically check the health of the connection pool.
|
||||
|
||||
Args:
|
||||
interval_seconds (int): Number of seconds between health checks
|
||||
"""
|
||||
|
||||
def _monitor():
|
||||
while True:
|
||||
try:
|
||||
log.info('[HealthCheck] Running periodic DB health check...')
|
||||
self.ensure_connection()
|
||||
log.info('[HealthCheck] Connection is healthy.')
|
||||
except Exception as e:
|
||||
log.exception(f'[HealthCheck] Connection health check failed: {e}')
|
||||
time.sleep(interval_seconds)
|
||||
|
||||
thread = threading.Thread(target=_monitor, daemon=True)
|
||||
thread.start()
|
||||
log.info('Started DB health monitor every %s seconds.', interval_seconds)
|
||||
|
||||
def _reconnect_pool(self):
|
||||
"""
|
||||
Attempt to reinitialize the connection pool if it's been closed or broken.
|
||||
"""
|
||||
try:
|
||||
log.info('Attempting to reinitialize the Oracle connection pool...')
|
||||
|
||||
# Close existing pool if it exists
|
||||
if self.pool:
|
||||
try:
|
||||
self.pool.close()
|
||||
except Exception as close_error:
|
||||
log.warning(f'Error closing existing pool: {close_error}')
|
||||
|
||||
# Re-create the appropriate connection pool based on DB type
|
||||
if ORACLE_DB_USE_WALLET:
|
||||
self._create_adb_pool()
|
||||
else: # DBCS
|
||||
self._create_dbcs_pool()
|
||||
|
||||
log.info('Connection pool reinitialized.')
|
||||
except Exception as e:
|
||||
log.exception(f'Failed to reinitialize the connection pool: {e}')
|
||||
raise
|
||||
|
||||
def ensure_connection(self):
|
||||
"""
|
||||
Ensure the database connection is alive, reconnecting pool if needed.
|
||||
"""
|
||||
try:
|
||||
with self.get_connection() as connection:
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute('SELECT 1 FROM dual')
|
||||
except Exception as e:
|
||||
log.exception(f'Connection check failed: {e}, attempting to reconnect pool...')
|
||||
self._reconnect_pool()
|
||||
|
||||
def _output_type_handler(self, cursor, metadata):
|
||||
"""
|
||||
Handle Oracle vector type conversion.
|
||||
@@ -433,7 +373,7 @@ class Oracle23aiClient(VectorDBBase):
|
||||
... ]
|
||||
>>> client.insert("my_collection", items)
|
||||
"""
|
||||
log.info("Inserting %s items into collection '%s'.", len(items), collection_name)
|
||||
log.debug("Inserting %s items into collection '%s'.", len(items), collection_name)
|
||||
|
||||
with self.get_connection() as connection:
|
||||
try:
|
||||
@@ -458,7 +398,7 @@ class Oracle23aiClient(VectorDBBase):
|
||||
)
|
||||
|
||||
connection.commit()
|
||||
log.info("Successfully inserted %s items into collection '%s'.", len(items), collection_name)
|
||||
log.debug("Successfully inserted %s items into collection '%s'.", len(items), collection_name)
|
||||
|
||||
except Exception as e:
|
||||
connection.rollback()
|
||||
@@ -487,7 +427,7 @@ class Oracle23aiClient(VectorDBBase):
|
||||
... ]
|
||||
>>> client.upsert("my_collection", items)
|
||||
"""
|
||||
log.info("Upserting %s items into collection '%s'.", len(items), collection_name)
|
||||
log.debug("Upserting %s items into collection '%s'.", len(items), collection_name)
|
||||
|
||||
with self.get_connection() as connection:
|
||||
try:
|
||||
@@ -526,7 +466,7 @@ class Oracle23aiClient(VectorDBBase):
|
||||
)
|
||||
|
||||
connection.commit()
|
||||
log.info("Successfully upserted %s items into collection '%s'.", len(items), collection_name)
|
||||
log.debug("Successfully upserted %s items into collection '%s'.", len(items), collection_name)
|
||||
|
||||
except Exception as e:
|
||||
connection.rollback()
|
||||
@@ -562,7 +502,7 @@ class Oracle23aiClient(VectorDBBase):
|
||||
... for i, (id, dist) in enumerate(zip(results.ids[0], results.distances[0])):
|
||||
... log.info(f"Match {i+1}: id={id}, distance={dist}")
|
||||
"""
|
||||
log.info("Searching items from collection '%s' with limit %s.", collection_name, limit)
|
||||
log.debug("Searching items from collection '%s' with limit %s.", collection_name, limit)
|
||||
|
||||
try:
|
||||
if not vectors:
|
||||
@@ -610,7 +550,7 @@ class Oracle23aiClient(VectorDBBase):
|
||||
metadatas[qid].append(self._json_to_metadata(metadata_str))
|
||||
distances[qid].append(float(row[3]))
|
||||
|
||||
log.info('Search completed. Found %s total results.', sum(len(ids[i]) for i in range(num_queries)))
|
||||
log.debug('Search completed. Found %s total results.', sum(len(ids[i]) for i in range(num_queries)))
|
||||
|
||||
return SearchResult(ids=ids, distances=distances, documents=documents, metadatas=metadatas)
|
||||
|
||||
@@ -639,7 +579,7 @@ class Oracle23aiClient(VectorDBBase):
|
||||
>>> if results:
|
||||
... print(f"Found {len(results.ids[0])} matching documents")
|
||||
"""
|
||||
log.info("Querying items from collection '%s' with filters.", collection_name)
|
||||
log.debug("Querying items from collection '%s' with filters.", collection_name)
|
||||
|
||||
try:
|
||||
limit = limit or 100
|
||||
@@ -666,7 +606,7 @@ class Oracle23aiClient(VectorDBBase):
|
||||
results = cursor.fetchall()
|
||||
|
||||
if not results:
|
||||
log.info('No results found for query.')
|
||||
log.debug('No results found for query.')
|
||||
return None
|
||||
|
||||
ids = [[row[0] for row in results]]
|
||||
@@ -679,7 +619,7 @@ class Oracle23aiClient(VectorDBBase):
|
||||
]
|
||||
]
|
||||
|
||||
log.info('Query completed. Found %s results.', len(results))
|
||||
log.debug('Query completed. Found %s results.', len(results))
|
||||
|
||||
return GetResult(ids=ids, documents=documents, metadatas=metadatas)
|
||||
|
||||
@@ -725,7 +665,7 @@ class Oracle23aiClient(VectorDBBase):
|
||||
results = cursor.fetchall()
|
||||
|
||||
if not results:
|
||||
log.info('No results found.')
|
||||
log.debug('No results found.')
|
||||
return None
|
||||
|
||||
ids = [[row[0] for row in results]]
|
||||
@@ -770,7 +710,7 @@ class Oracle23aiClient(VectorDBBase):
|
||||
>>> # Or delete by metadata filter
|
||||
>>> client.delete("my_collection", filter={"source": "deprecated_source"})
|
||||
"""
|
||||
log.info("Deleting items from collection '%s'.", collection_name)
|
||||
log.debug("Deleting items from collection '%s'.", collection_name)
|
||||
|
||||
try:
|
||||
query = 'DELETE FROM document_chunk WHERE collection_name = :collection_name'
|
||||
@@ -898,7 +838,7 @@ class Oracle23aiClient(VectorDBBase):
|
||||
>>> client = Oracle23aiClient()
|
||||
>>> client.delete_collection("obsolete_collection")
|
||||
"""
|
||||
log.info("Deleting collection '%s'.", collection_name)
|
||||
log.debug("Deleting collection '%s'.", collection_name)
|
||||
|
||||
try:
|
||||
with self.get_connection() as connection:
|
||||
|
||||
@@ -376,7 +376,7 @@ class PgvectorClient(VectorDBBase):
|
||||
},
|
||||
)
|
||||
self.session.commit()
|
||||
log.info("Encrypted & inserted %s into '%s'", len(items), collection_name)
|
||||
log.debug("Encrypted & inserted %s into '%s'", len(items), collection_name)
|
||||
|
||||
else:
|
||||
new_items = []
|
||||
@@ -392,7 +392,7 @@ class PgvectorClient(VectorDBBase):
|
||||
new_items.append(new_chunk)
|
||||
self.session.bulk_save_objects(new_items)
|
||||
self.session.commit()
|
||||
log.info("Inserted %s items into collection '%s'.", len(new_items), collection_name)
|
||||
log.debug("Inserted %s items into collection '%s'.", len(new_items), collection_name)
|
||||
except Exception as e:
|
||||
self.session.rollback()
|
||||
log.exception(f'Error during insert: {e}')
|
||||
@@ -431,7 +431,7 @@ class PgvectorClient(VectorDBBase):
|
||||
},
|
||||
)
|
||||
self.session.commit()
|
||||
log.info("Encrypted & upserted %s into '%s'", len(items), collection_name)
|
||||
log.debug("Encrypted & upserted %s into '%s'", len(items), collection_name)
|
||||
else:
|
||||
for item in items:
|
||||
vector = self.adjust_vector_length(item['vector'])
|
||||
@@ -451,7 +451,7 @@ class PgvectorClient(VectorDBBase):
|
||||
)
|
||||
self.session.add(new_chunk)
|
||||
self.session.commit()
|
||||
log.info("Upserted %s items into collection '%s'.", len(items), collection_name)
|
||||
log.debug("Upserted %s items into collection '%s'.", len(items), collection_name)
|
||||
except Exception as e:
|
||||
self.session.rollback()
|
||||
log.exception(f'Error during upsert: {e}')
|
||||
|
||||
@@ -275,7 +275,7 @@ class PineconeClient(VectorDBBase):
|
||||
raise
|
||||
elapsed = time.time() - start_time
|
||||
log.debug('Insert of %s vectors took %.2f seconds', len(points), elapsed)
|
||||
log.info(
|
||||
log.debug(
|
||||
"Successfully inserted %s vectors in parallel batches into '%s'", len(points), collection_name_with_prefix
|
||||
)
|
||||
|
||||
@@ -304,7 +304,7 @@ class PineconeClient(VectorDBBase):
|
||||
raise
|
||||
elapsed = time.time() - start_time
|
||||
log.debug('Upsert of %s vectors took %.2f seconds', len(points), elapsed)
|
||||
log.info(
|
||||
log.debug(
|
||||
"Successfully upserted %s vectors in parallel batches into '%s'", len(points), collection_name_with_prefix
|
||||
)
|
||||
|
||||
@@ -326,7 +326,7 @@ class PineconeClient(VectorDBBase):
|
||||
if isinstance(result, Exception):
|
||||
log.error(f'Error in async insert batch: {result}')
|
||||
raise result
|
||||
log.info(
|
||||
log.debug(
|
||||
"Successfully async inserted %s vectors in batches into '%s'", len(points), collection_name_with_prefix
|
||||
)
|
||||
|
||||
@@ -348,7 +348,7 @@ class PineconeClient(VectorDBBase):
|
||||
if isinstance(result, Exception):
|
||||
log.error(f'Error in async upsert batch: {result}')
|
||||
raise result
|
||||
log.info(
|
||||
log.debug(
|
||||
"Successfully async upserted %s vectors in batches into '%s'", len(points), collection_name_with_prefix
|
||||
)
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ class S3VectorClient(VectorDBBase):
|
||||
return
|
||||
|
||||
try:
|
||||
log.info("Deleting collection '%s'", collection_name)
|
||||
log.debug("Deleting collection '%s'", collection_name)
|
||||
self.client.delete_index(vectorBucketName=self.bucket_name, indexName=collection_name)
|
||||
log.info("Successfully deleted collection '%s'", collection_name)
|
||||
except Exception as e:
|
||||
@@ -158,7 +158,7 @@ class S3VectorClient(VectorDBBase):
|
||||
|
||||
try:
|
||||
if not self.has_collection(collection_name):
|
||||
log.info("Index '%s' does not exist. Creating index.", collection_name)
|
||||
log.debug("Index '%s' does not exist. Creating index.", collection_name)
|
||||
self._create_index(
|
||||
index_name=collection_name,
|
||||
dimension=dimension,
|
||||
@@ -204,11 +204,11 @@ class S3VectorClient(VectorDBBase):
|
||||
indexName=collection_name,
|
||||
vectors=batch,
|
||||
)
|
||||
log.info(
|
||||
log.debug(
|
||||
"Inserted batch %s: %s vectors into index '%s'.", i // batch_size + 1, len(batch), collection_name
|
||||
)
|
||||
|
||||
log.info("Completed insertion of %s vectors into index '%s'.", len(vectors), collection_name)
|
||||
log.debug("Completed insertion of %s vectors into index '%s'.", len(vectors), collection_name)
|
||||
except Exception as e:
|
||||
log.error(f'Error inserting vectors: {e}')
|
||||
raise
|
||||
@@ -222,11 +222,11 @@ class S3VectorClient(VectorDBBase):
|
||||
return
|
||||
|
||||
dimension = len(items[0]['vector'])
|
||||
log.info('Upsert dimension: %s', dimension)
|
||||
log.debug('Upsert dimension: %s', dimension)
|
||||
|
||||
try:
|
||||
if not self.has_collection(collection_name):
|
||||
log.info("Index '%s' does not exist. Creating index for upsert.", collection_name)
|
||||
log.debug("Index '%s' does not exist. Creating index for upsert.", collection_name)
|
||||
self._create_index(
|
||||
index_name=collection_name,
|
||||
dimension=dimension,
|
||||
@@ -267,7 +267,7 @@ class S3VectorClient(VectorDBBase):
|
||||
for i in range(0, len(vectors), batch_size):
|
||||
batch = vectors[i : i + batch_size]
|
||||
if i == 0: # Log sample info for first batch only
|
||||
log.info(
|
||||
log.debug(
|
||||
'Upserting batch 1: %s vectors. First vector sample: key=%s, data_type=%s, data_len=%s',
|
||||
len(batch),
|
||||
batch[0]['key'],
|
||||
@@ -275,7 +275,7 @@ class S3VectorClient(VectorDBBase):
|
||||
len(batch[0]['data']['float32']),
|
||||
)
|
||||
else:
|
||||
log.info('Upserting batch %s: %s vectors.', i // batch_size + 1, len(batch))
|
||||
log.debug('Upserting batch %s: %s vectors.', i // batch_size + 1, len(batch))
|
||||
|
||||
self.client.put_vectors(
|
||||
vectorBucketName=self.bucket_name,
|
||||
@@ -283,7 +283,7 @@ class S3VectorClient(VectorDBBase):
|
||||
vectors=batch,
|
||||
)
|
||||
|
||||
log.info("Completed upsert of %s vectors into index '%s'.", len(vectors), collection_name)
|
||||
log.debug("Completed upsert of %s vectors into index '%s'.", len(vectors), collection_name)
|
||||
except Exception as e:
|
||||
log.error(f'Error upserting vectors: {e}')
|
||||
raise
|
||||
@@ -308,7 +308,7 @@ class S3VectorClient(VectorDBBase):
|
||||
return None
|
||||
|
||||
try:
|
||||
log.info("Searching collection '%s' with %s query vectors, limit=%s", collection_name, len(vectors), limit)
|
||||
log.debug("Searching collection '%s' with %s query vectors, limit=%s", collection_name, len(vectors), limit)
|
||||
vector_filter = normalize_filter(filter)
|
||||
|
||||
# Initialize result lists
|
||||
@@ -377,7 +377,7 @@ class S3VectorClient(VectorDBBase):
|
||||
all_metadatas.append(query_metadatas)
|
||||
all_distances.append(query_distances)
|
||||
|
||||
log.info('Search completed. Found results for %s queries', len(all_ids))
|
||||
log.debug('Search completed. Found results for %s queries', len(all_ids))
|
||||
|
||||
# Return SearchResult format
|
||||
return SearchResult(
|
||||
@@ -417,7 +417,7 @@ class S3VectorClient(VectorDBBase):
|
||||
return self.get(collection_name)
|
||||
|
||||
try:
|
||||
log.info("Querying collection '%s' with filter: %s", collection_name, filter)
|
||||
log.debug("Querying collection '%s' with filter: %s", collection_name, filter)
|
||||
|
||||
# For S3 Vector, we need to use list_vectors and then filter results
|
||||
# Since S3 Vector may not support complex server-side filtering,
|
||||
@@ -452,7 +452,7 @@ class S3VectorClient(VectorDBBase):
|
||||
if limit and len(filtered_ids) >= limit:
|
||||
break
|
||||
|
||||
log.info('Filter applied: %s vectors match out of %s total', len(filtered_ids), len(all_ids))
|
||||
log.debug('Filter applied: %s vectors match out of %s total', len(filtered_ids), len(all_ids))
|
||||
|
||||
# Return GetResult format
|
||||
if filtered_ids:
|
||||
@@ -487,7 +487,7 @@ class S3VectorClient(VectorDBBase):
|
||||
return GetResult(ids=[[]], documents=[[]], metadatas=[[]])
|
||||
|
||||
try:
|
||||
log.info("Retrieving all vectors from collection '%s'", collection_name)
|
||||
log.debug("Retrieving all vectors from collection '%s'", collection_name)
|
||||
|
||||
# Initialize result lists
|
||||
all_ids = []
|
||||
@@ -549,7 +549,7 @@ class S3VectorClient(VectorDBBase):
|
||||
if not next_token:
|
||||
break
|
||||
|
||||
log.info("Retrieved %s vectors from collection '%s'", len(all_ids), collection_name)
|
||||
log.debug("Retrieved %s vectors from collection '%s'", len(all_ids), collection_name)
|
||||
|
||||
# Return in GetResult format
|
||||
# The Open WebUI GetResult expects lists of lists, so we wrap each list
|
||||
@@ -591,7 +591,7 @@ class S3VectorClient(VectorDBBase):
|
||||
try:
|
||||
if ids:
|
||||
# Delete by specific vector IDs/keys
|
||||
log.info("Deleting %s vectors by IDs from collection '%s'", len(ids), collection_name)
|
||||
log.debug("Deleting %s vectors by IDs from collection '%s'", len(ids), collection_name)
|
||||
# S3 Vectors accepts at most 500 keys per delete request.
|
||||
for start in range(0, len(ids), 500):
|
||||
self.client.delete_vectors(
|
||||
@@ -603,7 +603,7 @@ class S3VectorClient(VectorDBBase):
|
||||
|
||||
elif filter:
|
||||
# Handle filter-based deletion
|
||||
log.info("Deleting vectors by filter from collection '%s': %s", collection_name, filter)
|
||||
log.debug("Deleting vectors by filter from collection '%s': %s", collection_name, filter)
|
||||
|
||||
# If this is a knowledge collection and we have a file_id filter,
|
||||
# also clean up the corresponding file-specific collection
|
||||
@@ -611,7 +611,7 @@ class S3VectorClient(VectorDBBase):
|
||||
file_id = filter['file_id']
|
||||
file_collection_name = f'file-{file_id}'
|
||||
if self.has_collection(file_collection_name):
|
||||
log.info(
|
||||
log.debug(
|
||||
"Found related file-specific collection '%s', deleting it to prevent duplicates",
|
||||
file_collection_name,
|
||||
)
|
||||
@@ -622,7 +622,7 @@ class S3VectorClient(VectorDBBase):
|
||||
query_result = self.query(collection_name, filter)
|
||||
if query_result and query_result.ids and query_result.ids[0]:
|
||||
matching_ids = query_result.ids[0]
|
||||
log.info('Found %s vectors matching filter, deleting them', len(matching_ids))
|
||||
log.debug('Found %s vectors matching filter, deleting them', len(matching_ids))
|
||||
|
||||
# Delete the matching vectors by ID
|
||||
self.delete(collection_name, ids=matching_ids)
|
||||
|
||||
@@ -24,7 +24,7 @@ def search_exa(
|
||||
filter_list (list[str] | None): List of domains to filter results by
|
||||
max_content_length (int | None): Maximum characters per result; None leaves text unlimited.
|
||||
"""
|
||||
log.info('Searching with Exa')
|
||||
log.debug('Searching with Exa')
|
||||
|
||||
headers = {'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json'}
|
||||
|
||||
@@ -42,7 +42,7 @@ def search_exa(
|
||||
data = response.json()
|
||||
|
||||
results = data['results']
|
||||
log.info('Found %s results', len(results))
|
||||
log.debug('Found %s results', len(results))
|
||||
return [
|
||||
SearchResult(
|
||||
link=result['url'],
|
||||
|
||||
@@ -23,7 +23,7 @@ def search_ollama_cloud(
|
||||
count (int): Number of results to return
|
||||
filter_list (Optional[list[str]]): List of domains to filter results by
|
||||
"""
|
||||
log.info('Searching with Ollama')
|
||||
log.debug('Searching with Ollama')
|
||||
|
||||
headers = {'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json'}
|
||||
payload = {'query': query, 'max_results': count}
|
||||
@@ -34,7 +34,7 @@ def search_ollama_cloud(
|
||||
data = response.json()
|
||||
|
||||
results = data.get('results', [])
|
||||
log.info('Found %s results', len(results))
|
||||
log.debug('Found %s results', len(results))
|
||||
|
||||
if filter_list:
|
||||
results = get_filtered_results(results, filter_list)
|
||||
|
||||
@@ -27,7 +27,7 @@ def search_serply(
|
||||
hl (str): Host Language code to display results in (reference https://developers.google.com/custom-search/docs/xml_results?hl=en#wsInterfaceLanguages)
|
||||
limit (int): The maximum number of results to return [10-100, defaults to 10]
|
||||
"""
|
||||
log.info('Searching with Serply')
|
||||
log.debug('Searching with Serply')
|
||||
|
||||
url = 'https://api.serply.io/v1/search/'
|
||||
|
||||
|
||||
@@ -1824,7 +1824,7 @@ async def delete_knowledge_by_id(
|
||||
|
||||
# Get all models
|
||||
models = await Models.get_all_models(db=db)
|
||||
log.info('Found %s models to check for knowledge base %s', len(models), id)
|
||||
log.debug('Found %s models to check for knowledge base %s', len(models), id)
|
||||
|
||||
# Update models that reference this knowledge base
|
||||
for model in models:
|
||||
@@ -2187,7 +2187,7 @@ async def add_files_to_knowledge_batch(
|
||||
await _verify_directory_in_knowledge(id, directory_id, db, detail='Target directory not found.')
|
||||
|
||||
# Batch-fetch all files to avoid N+1 queries
|
||||
log.info('files/batch/add - %s files', len(form_data))
|
||||
log.debug('files/batch/add - %s files', len(form_data))
|
||||
file_ids = [form.file_id for form in form_data]
|
||||
files = await Files.get_files_by_ids(file_ids, db=db)
|
||||
|
||||
|
||||
@@ -432,7 +432,7 @@ async def get_note_chat_by_id(
|
||||
user=Depends(get_verified_user),
|
||||
db: AsyncSession = Depends(get_async_session),
|
||||
):
|
||||
log.info('[note-chat] get-or-create requested note_id=%s user_id=%s', id, user.id)
|
||||
log.debug('[note-chat] get-or-create requested note_id=%s user_id=%s', id, user.id)
|
||||
await check_notes_access(user, db=db)
|
||||
|
||||
note = await Notes.get_note_by_id(id, db=db)
|
||||
@@ -444,7 +444,7 @@ async def get_note_chat_by_id(
|
||||
|
||||
chat = await Chats.get_internal_chat_by_note_id(note.id, user.id, db=db)
|
||||
if chat:
|
||||
log.info('[note-chat] reusing hidden chat note_id=%s chat_id=%s user_id=%s', note.id, chat.id, user.id)
|
||||
log.debug('[note-chat] reusing hidden chat note_id=%s chat_id=%s user_id=%s', note.id, chat.id, user.id)
|
||||
params = {**((chat.chat or {}).get('params') or {})}
|
||||
changed = False
|
||||
if 'note_id' in params:
|
||||
@@ -497,7 +497,7 @@ async def get_note_chat_by_id(
|
||||
log.error('[note-chat] failed creating hidden chat note_id=%s user_id=%s', note.id, user.id)
|
||||
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=ERROR_MESSAGES.DEFAULT())
|
||||
|
||||
log.info('[note-chat] created hidden chat note_id=%s chat_id=%s user_id=%s', note.id, chat.id, user.id)
|
||||
log.debug('[note-chat] created hidden chat note_id=%s chat_id=%s user_id=%s', note.id, chat.id, user.id)
|
||||
return chat
|
||||
|
||||
|
||||
@@ -589,7 +589,7 @@ async def create_note_chat_by_id(
|
||||
log.error('[note-chat] failed creating hidden chat note_id=%s user_id=%s', note.id, user.id)
|
||||
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=ERROR_MESSAGES.DEFAULT())
|
||||
|
||||
log.info('[note-chat] created hidden chat note_id=%s chat_id=%s user_id=%s', note.id, chat.id, user.id)
|
||||
log.debug('[note-chat] created hidden chat note_id=%s chat_id=%s user_id=%s', note.id, chat.id, user.id)
|
||||
return chat
|
||||
|
||||
|
||||
|
||||
@@ -1722,11 +1722,11 @@ async def upload_model(
|
||||
async def file_process_stream():
|
||||
nonlocal ollama_url
|
||||
total_size = os.path.getsize(file_path)
|
||||
log.info('Total Model Size: %s', total_size)
|
||||
log.debug('Total Model Size: %s', total_size)
|
||||
|
||||
# Stage 2: hash the file and emit SSE progress
|
||||
file_hash = await asyncio.to_thread(calculate_sha256, file_path, chunk_size)
|
||||
log.info('Model Hash: %s', file_hash)
|
||||
log.debug('Model Hash: %s', file_hash)
|
||||
|
||||
try:
|
||||
bytes_read = 0
|
||||
@@ -1760,7 +1760,7 @@ async def upload_model(
|
||||
if not resp.ok:
|
||||
raise Exception('Ollama: Could not create blob, Please try again.')
|
||||
|
||||
log.info('Uploaded to /api/blobs')
|
||||
log.debug('Uploaded to /api/blobs')
|
||||
await asyncio.to_thread(os.remove, file_path)
|
||||
|
||||
# Stage 4: create the model
|
||||
@@ -1772,7 +1772,7 @@ async def upload_model(
|
||||
'files': {filename: f'sha256:{file_hash}'},
|
||||
'stream': False,
|
||||
}
|
||||
log.info('Model Payload: %s', create_payload)
|
||||
log.debug('Model Payload: %s', create_payload)
|
||||
|
||||
async with session.post(
|
||||
f'{ollama_url}/api/create',
|
||||
|
||||
@@ -1440,12 +1440,12 @@ def _chunk_docs(
|
||||
# Check if entries with the same hash (metadata.hash) already exist
|
||||
if metadata and 'hash' in metadata:
|
||||
if has_duplicate_content(collection_name, metadata['hash'], metadata.get('file_id')):
|
||||
log.info('Document with hash %s already exists', metadata['hash'])
|
||||
log.debug('Document with hash %s already exists', metadata['hash'])
|
||||
raise ValueError(ERROR_MESSAGES.DUPLICATE_CONTENT)
|
||||
|
||||
if split:
|
||||
if config['rag.enable_markdown_header_text_splitter']:
|
||||
log.info('Using markdown header text splitter')
|
||||
log.debug('Using markdown header text splitter')
|
||||
# Define headers to split on - covering most common markdown header levels
|
||||
markdown_splitter = MarkdownHeaderTextSplitter(
|
||||
headers_to_split_on=[
|
||||
@@ -1483,7 +1483,7 @@ def _chunk_docs(
|
||||
)
|
||||
docs = text_splitter.split_documents(docs)
|
||||
elif config['rag.text_splitter'] == 'token':
|
||||
log.info('Using token text splitter: %s', config['rag.tiktoken_encoding_name'])
|
||||
log.debug('Using token text splitter: %s', config['rag.tiktoken_encoding_name'])
|
||||
|
||||
tiktoken.get_encoding(str(config['rag.tiktoken_encoding_name']))
|
||||
text_splitter = TokenTextSplitter(
|
||||
@@ -1495,7 +1495,7 @@ def _chunk_docs(
|
||||
)
|
||||
docs = text_splitter.split_documents(docs)
|
||||
elif config['rag.text_splitter'] == 'token_transformers':
|
||||
log.info('Using transformers token text splitter')
|
||||
log.debug('Using transformers token text splitter')
|
||||
|
||||
text_splitter = RecursiveCharacterTextSplitter(
|
||||
chunk_size=config['rag.chunk_size'],
|
||||
@@ -1542,16 +1542,16 @@ async def save_docs_to_vector_db(
|
||||
|
||||
try:
|
||||
if await ASYNC_VECTOR_DB_CLIENT.has_collection(collection_name=collection_name):
|
||||
log.info('collection %s already exists', collection_name)
|
||||
log.debug('collection %s already exists', collection_name)
|
||||
|
||||
if overwrite:
|
||||
await ASYNC_VECTOR_DB_CLIENT.delete_collection(collection_name=collection_name)
|
||||
log.info('deleting existing collection %s', collection_name)
|
||||
elif add is False:
|
||||
log.info('collection %s already exists, overwrite is False and add is False', collection_name)
|
||||
log.debug('collection %s already exists, overwrite is False and add is False', collection_name)
|
||||
return True
|
||||
|
||||
log.info('generating embeddings for %s', collection_name)
|
||||
log.debug('generating embeddings for %s', collection_name)
|
||||
embedding_function = get_embedding_function(
|
||||
config['rag.embedding_engine'],
|
||||
config['rag.embedding_model'],
|
||||
@@ -1590,7 +1590,7 @@ async def save_docs_to_vector_db(
|
||||
|
||||
embedding_timeout = RAG_EMBEDDING_TIMEOUT
|
||||
|
||||
log.info('adding to collection %s', collection_name)
|
||||
log.debug('adding to collection %s', collection_name)
|
||||
inserted_ids = []
|
||||
try:
|
||||
for start in range(0, len(texts), buffer_size):
|
||||
@@ -1606,7 +1606,7 @@ async def save_docs_to_vector_db(
|
||||
)
|
||||
if embedding_timeout is not None:
|
||||
embedding_timeout = max(embedding_timeout - (time.monotonic() - started_at), 0)
|
||||
log.info('embeddings generated %s for %s items', len(embeddings), len(buffer_texts))
|
||||
log.debug('embeddings generated %s for %s items', len(embeddings), len(buffer_texts))
|
||||
|
||||
items = [
|
||||
{
|
||||
@@ -1858,7 +1858,7 @@ async def index_file(
|
||||
add=(True if form_data.collection_name else False),
|
||||
user=user,
|
||||
)
|
||||
log.info('added %s items to collection %s', len(docs), collection_name)
|
||||
log.debug('added %s items to collection %s', len(docs), collection_name)
|
||||
|
||||
if result:
|
||||
# Fresh session for the final update.
|
||||
|
||||
@@ -398,7 +398,7 @@ async def generate_queries(request: Request, form_data: dict, user=Depends(get_v
|
||||
)
|
||||
|
||||
if getattr(request.state, 'cached_queries', None):
|
||||
log.info('Reusing cached queries')
|
||||
log.debug('Reusing cached queries')
|
||||
return request.state.cached_queries
|
||||
|
||||
models = await add_tether_model(request, user, form_data.get('model'))
|
||||
|
||||
@@ -1125,7 +1125,7 @@ async def ydoc_document_join(sid, data):
|
||||
log.warning('User %s is at the open-document limit. Rejecting join.', user_id)
|
||||
return
|
||||
|
||||
log.info('User %s joining document %s', user_id, document_id)
|
||||
log.debug('User %s joining document %s', user_id, document_id)
|
||||
await YDOC_MANAGER.add_user(document_id=document_id, user_id=sid)
|
||||
|
||||
# Join Socket.IO room
|
||||
@@ -1173,7 +1173,7 @@ async def ydoc_document_join(sid, data):
|
||||
skip_sid=sid,
|
||||
)
|
||||
|
||||
log.info('User %s successfully joined document %s', user_id, document_id)
|
||||
log.debug('User %s successfully joined document %s', user_id, document_id)
|
||||
|
||||
except Exception as e:
|
||||
log.error(f'Error in yjs_document_join: {e}')
|
||||
@@ -1395,7 +1395,7 @@ async def yjs_document_leave(sid, data):
|
||||
try:
|
||||
document_id = normalize_document_id(data['document_id'])
|
||||
|
||||
log.info('User %s leaving document %s', user['id'], document_id)
|
||||
log.debug('User %s leaving document %s', user['id'], document_id)
|
||||
|
||||
# Remove user from the document
|
||||
await YDOC_MANAGER.remove_user(document_id=document_id, user_id=sid)
|
||||
@@ -1411,7 +1411,7 @@ async def yjs_document_leave(sid, data):
|
||||
)
|
||||
|
||||
if not await YDOC_MANAGER.get_users(document_id) and not await has_active_tasks(REDIS, document_id):
|
||||
log.info('Cleaning up document %s as no users are left', document_id)
|
||||
log.debug('Cleaning up document %s as no users are left', document_id)
|
||||
await YDOC_MANAGER.clear_document(document_id)
|
||||
|
||||
except Exception as e:
|
||||
|
||||
@@ -17,7 +17,7 @@ default_headers = {'User-Agent': 'Mozilla/5.0'}
|
||||
|
||||
|
||||
async def queue_prompt(prompt, client_id, base_url, api_key):
|
||||
log.info('queue_prompt')
|
||||
log.debug('queue_prompt')
|
||||
p = {'prompt': prompt, 'client_id': client_id}
|
||||
log.debug('queue_prompt data: %s', p)
|
||||
try:
|
||||
@@ -36,7 +36,7 @@ async def queue_prompt(prompt, client_id, base_url, api_key):
|
||||
|
||||
|
||||
async def get_image(filename, subfolder, folder_type, base_url, api_key):
|
||||
log.info('get_image')
|
||||
log.debug('get_image')
|
||||
data = {'filename': filename, 'subfolder': subfolder, 'type': folder_type}
|
||||
url_values = urllib.parse.urlencode(data)
|
||||
session = await get_session()
|
||||
@@ -50,14 +50,14 @@ async def get_image(filename, subfolder, folder_type, base_url, api_key):
|
||||
|
||||
|
||||
def get_image_url(filename, subfolder, folder_type, base_url):
|
||||
log.info('get_image')
|
||||
log.debug('get_image')
|
||||
data = {'filename': filename, 'subfolder': subfolder, 'type': folder_type}
|
||||
url_values = urllib.parse.urlencode(data)
|
||||
return f'{base_url}/view?{url_values}'
|
||||
|
||||
|
||||
async def get_history(prompt_id, base_url, api_key):
|
||||
log.info('get_history')
|
||||
log.debug('get_history')
|
||||
session = await get_session()
|
||||
async with session.get(
|
||||
f'{base_url}/history/{prompt_id}',
|
||||
@@ -223,8 +223,8 @@ async def comfyui_create_image(model: str, payload: ComfyUICreateImageForm, clie
|
||||
headers=headers,
|
||||
ssl=AIOHTTP_CLIENT_SESSION_SSL,
|
||||
) as ws:
|
||||
log.info('WebSocket connection established.')
|
||||
log.info('Sending workflow to WebSocket server.')
|
||||
log.debug('WebSocket connection established.')
|
||||
log.debug('Sending workflow to WebSocket server.')
|
||||
log.debug('Workflow: %s', workflow)
|
||||
images = await _ws_get_images(ws, workflow, client_id, base_url, api_key)
|
||||
except aiohttp.WSServerHandshakeError as e:
|
||||
@@ -264,8 +264,8 @@ async def comfyui_edit_image(model: str, payload: ComfyUIEditImageForm, client_i
|
||||
headers=headers,
|
||||
ssl=AIOHTTP_CLIENT_SESSION_SSL,
|
||||
) as ws:
|
||||
log.info('WebSocket connection established.')
|
||||
log.info('Sending workflow to WebSocket server.')
|
||||
log.debug('WebSocket connection established.')
|
||||
log.debug('Sending workflow to WebSocket server.')
|
||||
log.debug('Workflow: %s', workflow)
|
||||
images = await _ws_get_images(ws, workflow, client_id, base_url, api_key)
|
||||
except aiohttp.WSServerHandshakeError as e:
|
||||
|
||||
Reference in new issue
Block a user