Feat: add 'delete' for agent's sessions api and unify apis of agent sdk (#5525)

### What problem does this PR solve?

Add sessions deletion support for agent in http and python api

### Type of change

- [ ] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)
- [ ] Documentation Update
- [x] Refactoring
- [ ] Performance Improvement
- [ ] Other (please describe):

---------

Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
Debug Doctor
2025-03-03 17:15:16 +08:00
committed by GitHub
parent 65d7c19979
commit 76cb4cd174
5 changed files with 158 additions and 35 deletions

View File

@ -14,7 +14,7 @@
# limitations under the License.
#
from ragflow_sdk import RAGFlow, Agent
from ragflow_sdk import RAGFlow
from common import HOST_ADDRESS
import pytest
@ -117,20 +117,29 @@ def test_list_sessions_with_success(get_api_key_fixture):
def test_create_agent_session_with_success(get_api_key_fixture):
API_KEY = "ragflow-BkOGNhYjIyN2JiODExZWY5MzVhMDI0Mm"
rag = RAGFlow(API_KEY, HOST_ADDRESS)
Agent.create_session("2e45b5209c1011efa3e90242ac120006", rag)
agent = rag.list_agents(id="2e45b5209c1011efa3e90242ac120006")[0]
agent.create_session()
@pytest.mark.skip(reason="")
def test_create_agent_conversation_with_success(get_api_key_fixture):
API_KEY = "ragflow-BkOGNhYjIyN2JiODExZWY5MzVhMDI0Mm"
rag = RAGFlow(API_KEY, HOST_ADDRESS)
session = Agent.create_session("2e45b5209c1011efa3e90242ac120006", rag)
agent = rag.list_agents(id="2e45b5209c1011efa3e90242ac120006")[0]
session = agent.create_session()
session.ask("What is this job")
@pytest.mark.skip(reason="")
def test_list_agent_sessions_with_success(get_api_key_fixture):
API_KEY = "ragflow-BkOGNhYjIyN2JiODExZWY5MzVhMDI0Mm"
agent_id = "2710f2269b4611ef8fdf0242ac120006"
rag = RAGFlow(API_KEY, HOST_ADDRESS)
Agent.list_sessions(agent_id, rag)
agent = rag.list_agents(id="2e45b5209c1011efa3e90242ac120006")[0]
agent.list_sessions()
@pytest.mark.skip(reason="")
def test_delete_session_of_agent_with_success(get_api_key_fixture):
API_KEY = "ragflow-BkOGNhYjIyN2JiODExZWY5MzVhMDI0Mm"
rag = RAGFlow(API_KEY, HOST_ADDRESS)
agent = rag.list_agents(id="2e45b5209c1011efa3e90242ac120006")[0]
agent.delete_sessions(ids=["test_1"])