mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: 修复应用修改模型后,历史对话未使用最新模型 (#487)
This commit is contained in:
parent
03b662beec
commit
84c7728d00
|
|
@ -41,7 +41,7 @@ from setting.serializers.provider_serializers import ModelSerializer
|
||||||
from smartdoc.conf import PROJECT_DIR
|
from smartdoc.conf import PROJECT_DIR
|
||||||
|
|
||||||
token_cache = cache.caches['token_cache']
|
token_cache = cache.caches['token_cache']
|
||||||
chat_cache = cache.caches['chat_cache']
|
chat_cache = cache.caches['model_cache']
|
||||||
|
|
||||||
|
|
||||||
class ModelDatasetAssociation(serializers.Serializer):
|
class ModelDatasetAssociation(serializers.Serializer):
|
||||||
|
|
@ -532,6 +532,7 @@ class ApplicationSerializer(serializers.Serializer):
|
||||||
QuerySet(ApplicationDatasetMapping).bulk_create(
|
QuerySet(ApplicationDatasetMapping).bulk_create(
|
||||||
[ApplicationDatasetMapping(application_id=application_id, dataset_id=dataset_id) for dataset_id in
|
[ApplicationDatasetMapping(application_id=application_id, dataset_id=dataset_id) for dataset_id in
|
||||||
dataset_id_list]) if len(dataset_id_list) > 0 else None
|
dataset_id_list]) if len(dataset_id_list) > 0 else None
|
||||||
|
chat_cache.clear_by_application_id(application_id)
|
||||||
return self.one(with_valid=False)
|
return self.one(with_valid=False)
|
||||||
|
|
||||||
def list_dataset(self, with_valid=True):
|
def list_dataset(self, with_valid=True):
|
||||||
|
|
|
||||||
|
|
@ -29,3 +29,15 @@ class MemCache(LocMemCache):
|
||||||
pickled = self._cache[key]
|
pickled = self._cache[key]
|
||||||
self._cache.move_to_end(key, last=False)
|
self._cache.move_to_end(key, last=False)
|
||||||
return pickled
|
return pickled
|
||||||
|
|
||||||
|
def clear_by_application_id(self, application_id):
|
||||||
|
delete_keys = []
|
||||||
|
for key in self._cache.keys():
|
||||||
|
value = self._cache.get(key)
|
||||||
|
if (hasattr(value,
|
||||||
|
'application') and value.application is not None and value.application.id is not None and
|
||||||
|
str(
|
||||||
|
value.application.id) == application_id):
|
||||||
|
delete_keys.append(key)
|
||||||
|
for key in delete_keys:
|
||||||
|
self._delete(key)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue