Co-authored-by: colvin <colvin.zhang@boaocloud.com>
This commit is contained in:
parent
d5214e4644
commit
c60749678b
@ -9,7 +9,7 @@ from core.rag.datasource.vdb.vector_factory import Vector
|
|||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from extensions.ext_redis import redis_client
|
from extensions.ext_redis import redis_client
|
||||||
from models.dataset import Dataset
|
from models.dataset import Dataset
|
||||||
from models.model import App, AppAnnotationSetting
|
from models.model import App, AppAnnotationSetting, MessageAnnotation
|
||||||
|
|
||||||
|
|
||||||
@shared_task(queue='dataset')
|
@shared_task(queue='dataset')
|
||||||
@ -25,7 +25,7 @@ def disable_annotation_reply_task(job_id: str, app_id: str, tenant_id: str):
|
|||||||
App.tenant_id == tenant_id,
|
App.tenant_id == tenant_id,
|
||||||
App.status == 'normal'
|
App.status == 'normal'
|
||||||
).first()
|
).first()
|
||||||
|
annotations_count = db.session.query(MessageAnnotation).filter(MessageAnnotation.app_id == app_id).count()
|
||||||
if not app:
|
if not app:
|
||||||
raise NotFound("App not found")
|
raise NotFound("App not found")
|
||||||
|
|
||||||
@ -49,8 +49,9 @@ def disable_annotation_reply_task(job_id: str, app_id: str, tenant_id: str):
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
vector = Vector(dataset, attributes=['doc_id', 'annotation_id', 'app_id'])
|
if annotations_count > 0:
|
||||||
vector.delete_by_metadata_field('app_id', app_id)
|
vector = Vector(dataset, attributes=['doc_id', 'annotation_id', 'app_id'])
|
||||||
|
vector.delete_by_metadata_field('app_id', app_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.exception("Delete annotation index failed when annotation deleted.")
|
logging.exception("Delete annotation index failed when annotation deleted.")
|
||||||
redis_client.setex(disable_app_annotation_job_key, 600, 'completed')
|
redis_client.setex(disable_app_annotation_job_key, 600, 'completed')
|
||||||
|
Loading…
Reference in New Issue
Block a user