Skip to content

Commit

Permalink
[FIX] Fixed error : langchain_community is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
pathfindermilan committed Oct 13, 2024
1 parent d864a0f commit 5d75cd3
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions backend/console/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,19 @@ def create(self, validated_data):
avatar_instance.save(avatar_new_name, ContentFile(avatar_content), save=False)
order.agent.identity.save()

fileitem_instance = order.agent.knowledge.knowledgefileitem.file_item
if fileitem_instance:
_ , fileitem_file_name = fileitem_instance.name.split('/')
fileitem_new_name = f"{order.id}__{fileitem_file_name}"

with fileitem_instance.open('rb') as f:
fileitem_content = f.read()
fileitem_instance.delete(save=False)
fileitem_instance.save(fileitem_new_name, ContentFile(fileitem_content), save=False)
order.agent.knowledge.knowledgefileitem.save()
try:
fileitem_instance = order.agent.knowledge.knowledgefileitem.file_item
if fileitem_instance:
_ , fileitem_file_name = fileitem_instance.name.split('/')
fileitem_new_name = f"{order.id}__{fileitem_file_name}"

with fileitem_instance.open('rb') as f:
fileitem_content = f.read()
fileitem_instance.delete(save=False)
fileitem_instance.save(fileitem_new_name, ContentFile(fileitem_content), save=False)
order.agent.knowledge.knowledgefileitem.save()
except:
pass
return order

def update(self, instance, validated_data):
Expand All @@ -224,15 +227,19 @@ def update(self, instance, validated_data):
avatar_instance.save(avatar_new_name, ContentFile(avatar_content), save=False)
instance.agent.identity.save()

fileitem_instance = instance.agent.knowledge.knowledgefileitem.file_item
_ , fileitem_file_name = fileitem_instance.name.split('/')
fileitem_new_name = f"{instance.id}__{fileitem_file_name}"

with fileitem_instance.open('rb') as f:
fileitem_content = f.read()
fileitem_instance.delete(save=False)
fileitem_instance.save(fileitem_new_name, ContentFile(fileitem_content), save=False)
instance.agent.knowledge.knowledgefileitem.save()
try:
fileitem_instance = instance.agent.knowledge.knowledgefileitem.file_item
if fileitem_instance:
_ , fileitem_file_name = fileitem_instance.name.split('/')
fileitem_new_name = f"{instance.id}__{fileitem_file_name}"

with fileitem_instance.open('rb') as f:
fileitem_content = f.read()
fileitem_instance.delete(save=False)
fileitem_instance.save(fileitem_new_name, ContentFile(fileitem_content), save=False)
instance.agent.knowledge.knowledgefileitem.save()
except:
pass

for attr, value in validated_data.items():
setattr(instance, attr, value)
Expand Down

0 comments on commit 5d75cd3

Please sign in to comment.