mirror of
https://github.com/open-webui/open-webui
synced 2025-03-16 10:28:28 +00:00
Merge pull request #8432 from juananpe/kb-detachment-from-models
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Python CI / Format Backend (3.11) (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run
Integration Test / Run Cypress Integration Tests (push) Waiting to run
Integration Test / Run Migration Tests (push) Waiting to run
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Python CI / Format Backend (3.11) (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run
Integration Test / Run Cypress Integration Tests (push) Waiting to run
Integration Test / Run Migration Tests (push) Waiting to run
fix: Knowledge Base Detachment from Models
This commit is contained in:
commit
88614ec70a
@ -25,6 +25,7 @@ from open_webui.utils.access_control import has_access, has_permission
|
|||||||
|
|
||||||
|
|
||||||
from open_webui.env import SRC_LOG_LEVELS
|
from open_webui.env import SRC_LOG_LEVELS
|
||||||
|
from open_webui.models.models import Models, ModelForm
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -473,6 +474,36 @@ async def delete_knowledge_by_id(id: str, user=Depends(get_verified_user)):
|
|||||||
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
|
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
log.info(f"Deleting knowledge base: {id} (name: {knowledge.name})")
|
||||||
|
|
||||||
|
# Get all models
|
||||||
|
models = Models.get_all_models()
|
||||||
|
log.info(f"Found {len(models)} models to check for knowledge base {id}")
|
||||||
|
|
||||||
|
# Update models that reference this knowledge base
|
||||||
|
for model in models:
|
||||||
|
if model.meta and hasattr(model.meta, "knowledge"):
|
||||||
|
knowledge_list = model.meta.knowledge or []
|
||||||
|
# Filter out the deleted knowledge base
|
||||||
|
updated_knowledge = [k for k in knowledge_list if k.get("id") != id]
|
||||||
|
|
||||||
|
# If the knowledge list changed, update the model
|
||||||
|
if len(updated_knowledge) != len(knowledge_list):
|
||||||
|
log.info(f"Updating model {model.id} to remove knowledge base {id}")
|
||||||
|
model.meta.knowledge = updated_knowledge
|
||||||
|
# Create a ModelForm for the update
|
||||||
|
model_form = ModelForm(
|
||||||
|
id=model.id,
|
||||||
|
name=model.name,
|
||||||
|
base_model_id=model.base_model_id,
|
||||||
|
meta=model.meta,
|
||||||
|
params=model.params,
|
||||||
|
access_control=model.access_control,
|
||||||
|
is_active=model.is_active,
|
||||||
|
)
|
||||||
|
Models.update_model_by_id(model.id, model_form)
|
||||||
|
|
||||||
|
# Clean up vector DB
|
||||||
try:
|
try:
|
||||||
VECTOR_DB_CLIENT.delete_collection(collection_name=id)
|
VECTOR_DB_CLIENT.delete_collection(collection_name=id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -74,7 +74,6 @@ export const processResponseContent = (content: string) => {
|
|||||||
return content.trim();
|
return content.trim();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export function unescapeHtml(html: string) {
|
export function unescapeHtml(html: string) {
|
||||||
const doc = new DOMParser().parseFromString(html, 'text/html');
|
const doc = new DOMParser().parseFromString(html, 'text/html');
|
||||||
return doc.documentElement.textContent;
|
return doc.documentElement.textContent;
|
||||||
|
Loading…
Reference in New Issue
Block a user