Skip to content

Commit

Permalink
Handle file retrieval when agent is None
Browse files Browse the repository at this point in the history
  • Loading branch information
sabaimran committed Nov 5, 2024
1 parent e3ca52b commit b6145df
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/khoj/database/adapters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,8 @@ async def auser_has_entries(user: KhojUser):

@staticmethod
async def aagent_has_entries(agent: Agent):
if agent is None:
return False
return await Entry.objects.filter(agent=agent).aexists()

@staticmethod
Expand All @@ -1495,6 +1497,8 @@ async def adelete_entries_by_filenames(user: KhojUser, filenames: List[str], bat

@staticmethod
async def aget_agent_entry_filepaths(agent: Agent):
if agent is None:
return []
return await sync_to_async(set)(
Entry.objects.filter(agent=agent).distinct("file_path").values_list("file_path", flat=True)
)
Expand Down

0 comments on commit b6145df

Please sign in to comment.