mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-14 02:15:06 +00:00
fix(agents): list source-less agents and select only the uploaded source
Review follow-ups: - The agents list and the pinned list dropped agents that had neither a source nor a retriever. Publishing such an agent is now allowed, so it vanished from the list right after publish. Both filters are gone; a source-less agent skips retrieval and is still runnable. Tests cover both listings. - The agent form selected an uploaded source by diffing the source catalog before and after the upload, which would also pick up any source created or shared in the meantime. Upload now passes the id of the source it created to onSuccessfulUpload, and the form selects only that id.
This commit is contained in:
1 parent
79d418f32a
commit
0fe059db12
4 files changed
+69
-38
No files matched your search
@@ -481,18 +481,11 @@ class GetAgents(Resource):
|
||||
shared_ids = [aid for aid in team_shared if aid not in owned_ids]
|
||||
shared_agents = agents_repo.list_by_ids(shared_ids)
|
||||
|
||||
def _is_runnable(agent: dict) -> bool:
|
||||
return bool(
|
||||
agent.get("source_id")
|
||||
or (agent.get("extra_source_ids") or [])
|
||||
or agent.get("retriever")
|
||||
or agent.get("agent_type") == "workflow"
|
||||
)
|
||||
|
||||
# Every agent is listed: one with no source skips retrieval and
|
||||
# answers from the model and its tools, so it is still runnable.
|
||||
list_agents = [
|
||||
_format_agent_output(agent, pinned=str(agent["id"]) in pinned_ids)
|
||||
for agent in agents
|
||||
if _is_runnable(agent)
|
||||
]
|
||||
list_agents += [
|
||||
_format_agent_output(
|
||||
@@ -501,7 +494,6 @@ class GetAgents(Resource):
|
||||
team_access=team_shared.get(str(agent["id"])),
|
||||
)
|
||||
for agent in shared_agents
|
||||
if _is_runnable(agent)
|
||||
]
|
||||
except Exception as err:
|
||||
current_app.logger.error(f"Error retrieving agents: {err}", exc_info=True)
|
||||
@@ -1511,8 +1503,6 @@ class PinnedAgents(Resource):
|
||||
list_pinned_agents = []
|
||||
for agent in pinned_agents:
|
||||
source_id = agent.get("source_id")
|
||||
if not source_id and not agent.get("retriever"):
|
||||
continue
|
||||
list_pinned_agents.append(
|
||||
{
|
||||
"id": str(agent["id"]),
|
||||
|
||||
Reference in new issue
Block a user