Skip to content

Commit

Permalink
feat: return information on attached agents when getting list of sour…
Browse files Browse the repository at this point in the history
…ces from API (#1172)
  • Loading branch information
cpacker authored Mar 21, 2024
1 parent d664e25 commit 97b7834
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions memgpt/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1362,11 +1362,21 @@ def list_all_sources(self, user_id: uuid.UUID) -> List[SourceModel]:

passages = self.list_data_source_passages(user_id=user_id, source_id=source.id)
documents = self.list_data_source_documents(user_id=user_id, source_id=source.id)
agent_ids = self.ms.list_attached_agents(source_id=source.id)
# add the agent name information
attached_agents = [
{
"id": str(a_id),
"name": self.ms.get_agent(user_id=user_id, agent_id=a_id).name,
}
for a_id in agent_ids
]

# Overwrite metadata field, should be empty anyways
source.metadata_ = dict(
num_documents=len(passages),
num_passages=len(documents),
attached_agents=attached_agents,
)

sources_with_metadata.append(source)
Expand Down

0 comments on commit 97b7834

Please sign in to comment.