mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-05 07:10:29 +08:00
Feat: Agent api (#14157)
### What problem does this PR solve?
1. **List agents**
**Prev API**:
- `/v1/canvas/list GET`
- `/api/v1/agents GET`
**Current API**: `/api/v2/agents GET`
2. **Get canvas template**
**Prev API**: `/v1/canvas/templates GET`
**Current API**: `/api/v2/agents/templates GET`
3. **Delete an agent**
**Prev API**:
- `/v1/canvas/rm POST`
- `/api/v1/agents/<agent_id> DELETE`
**Current API**: `/api/v2/agents/<agent_id> DELETE`
4. **Update an agent**
**Prev API**:
- `/api/v1/agents/<agent_id> PUT`
- `/v1/canvas/setting POST `
**Current API**: `/api/v2/agents/<agent_id> PATCH`
5. **Create an agent**
**Prev API**:
- `/v1/canvas/set POST`
- `/api/v1/agents POST`
**Current API**: `/api/v2/agents POST`
6. **Get an agent**
**Prev API**:
- `/v1/canvas/get/<canvas_id> GET `
**Current API**: `/api/v2/agents/<agent_id> GET`
7. **Reset an agent**
**Prev API**:
- `/v1/canvas/reset POST`
**Current API**: `/api/v2/agents/<agent_id>/reset POST`
8. **Upload a file to an agent**
**Prev API**:
- `/v1/canvas/upload/<canvas_id> POST`
**Current API**: `/api/v2/agents/<agent_id>/upload POST`
9. **Input form**
**Prev API**:
- `/v1/canvas/input_form GET`
**Current API**:
`/api/v2/agents/<agent_id>/components/<component_id>/input-form GET`
10. **Debug an agent**
**Prev API**:
- `/v1/canvas/debug POST`
**Current API**:
`/api/v2/agents/<agent_id>/components/<component_id>/debug POST`
11. **Trace an agent**
**Prev API**:
- `/v1/canvas/trace GET`
**Current API**: `/api/v2/agents/<agent_id>/logs/<message_id> GET`
12. **Get an agent version list**
**Prev API**:
- `/v1/canvas/getlistversion/<canvas_id>`
**Current API**: `/api/v2/agents/<agent_id>/versions GET`
13. **Get a version of agent**
**Prev API**:
- `/v1/canvas/getversion/<version_id>`
**Current API**: `/api/v2/agents/<agent_id>/versions/<version_id> GET`
14. **Test db connection**
**Prev API**:
- `/v1/canvas/test_db_connect POST`
**Current API**: `/api/v2/agents/test_db_connection`
15. **Rerun the agent**
**Prev API**:
- `/v1/canvas/rerun POST`
**Current API**: `/api/v2/agents/rerun POST`
16. **Get prompts**
**Prev API**:
- `/v1/canvas/prompts GET`
**Current API**: `/api/v2/agents/prompts GET`
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
---------
Co-authored-by: chanx <1243304602@qq.com>
This commit is contained in:
@@ -47,12 +47,12 @@ def test_list_agents_success_and_error(monkeypatch):
|
||||
captured["path"] = path
|
||||
captured["params"] = params
|
||||
captured["json"] = json
|
||||
return _DummyResponse({"code": 0, "data": [{"id": "agent-1", "title": "Agent One"}]})
|
||||
return _DummyResponse({"code": 0, "data": {"canvas": [{"id": "agent-1", "title": "Agent One"}], "total": 1}})
|
||||
|
||||
monkeypatch.setattr(client, "get", _ok_get)
|
||||
agents = client.list_agents(title="Agent One")
|
||||
agents = client.list_agents()
|
||||
assert captured["path"] == "/agents"
|
||||
assert captured["params"]["title"] == "Agent One"
|
||||
assert captured["params"] == {"page": 1, "page_size": 30, "orderby": "update_time", "desc": True}
|
||||
assert isinstance(agents[0], Agent), str(agents)
|
||||
assert agents[0].id == "agent-1", str(agents[0])
|
||||
assert agents[0].title == "Agent One", str(agents[0])
|
||||
|
||||
@@ -160,8 +160,10 @@ def test_session_module_streaming_and_helper_paths_unit(monkeypatch):
|
||||
assert calls[0][2]["session_id"] == "session-chat"
|
||||
assert calls[0][2]["temperature"] == 0.2
|
||||
assert calls[0][3] is True
|
||||
assert calls[1][1] == "/agents/agent-1/completions"
|
||||
assert calls[1][2]["question"] == "hello agent"
|
||||
assert calls[1][1] == "/agents/chat/completion"
|
||||
assert calls[1][2]["agent_id"] == "agent-1"
|
||||
assert calls[1][2]["query"] == "hello agent"
|
||||
assert calls[1][2]["session_id"] == "session-agent"
|
||||
assert calls[1][2]["openai-compatible"] is False
|
||||
assert calls[1][2]["top_p"] == 0.8
|
||||
assert calls[1][3] is True
|
||||
|
||||
Reference in New Issue
Block a user