mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
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:
@ -1460,21 +1460,13 @@ while True:
|
||||
### Create session with agent
|
||||
|
||||
```python
|
||||
Agent.create_session(id,rag, **kwargs) -> Session
|
||||
Agent.create_session(**kwargs) -> Session
|
||||
```
|
||||
|
||||
Creates a session with the current agent.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### id: `str`, *Required*
|
||||
|
||||
The id of agent
|
||||
|
||||
##### rag:`RAGFlow object`
|
||||
|
||||
The RAGFlow object
|
||||
|
||||
##### **kwargs
|
||||
|
||||
The parameters in `begin` component.
|
||||
@ -1494,7 +1486,8 @@ from ragflow_sdk import RAGFlow, Agent
|
||||
|
||||
rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
||||
AGENT_ID = "AGENT_ID"
|
||||
session = Agent.create_session(AGENT_ID, rag_object)
|
||||
agent = rag_object.list_agents(id = AGENT_id)[0]
|
||||
session = agent.create_session()
|
||||
```
|
||||
|
||||
---
|
||||
@ -1571,7 +1564,8 @@ from ragflow_sdk import RAGFlow, Agent
|
||||
|
||||
rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
||||
AGENT_id = "AGENT_ID"
|
||||
session = Agent.create_session(AGENT_id, rag_object)
|
||||
agent = rag_object.list_agents(id = AGENT_id)[0]
|
||||
session = agent.create_session()
|
||||
|
||||
print("\n===== Miss R ====\n")
|
||||
print("Hello. What can I do for you?")
|
||||
@ -1592,8 +1586,6 @@ while True:
|
||||
|
||||
```python
|
||||
Agent.list_sessions(
|
||||
agent_id,
|
||||
rag
|
||||
page: int = 1,
|
||||
page_size: int = 30,
|
||||
orderby: str = "update_time",
|
||||
@ -1640,11 +1632,42 @@ The ID of the agent session to retrieve. Defaults to `None`.
|
||||
from ragflow_sdk import RAGFlow
|
||||
|
||||
rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
||||
agent_id = "2710f2269b4611ef8fdf0242ac120006"
|
||||
sessions=Agent.list_sessions(agent_id,rag_object)
|
||||
AGENT_id = "AGENT_ID"
|
||||
agent = rag_object.list_agents(id = AGENT_id)[0]
|
||||
sessons = agent.list_sessions()
|
||||
for session in sessions:
|
||||
print(session)
|
||||
```
|
||||
---
|
||||
### Delete agent's sessions
|
||||
|
||||
```python
|
||||
Agent.delete_sessions(ids: list[str] = None)
|
||||
```
|
||||
|
||||
Deletes sessions of a agent by ID.
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### ids: `list[str]`
|
||||
|
||||
The IDs of the sessions to delete. Defaults to `None`. If it is not specified, all sessions associated with the agent will be deleted.
|
||||
|
||||
#### Returns
|
||||
|
||||
- Success: No value is returned.
|
||||
- Failure: `Exception`
|
||||
|
||||
#### Examples
|
||||
|
||||
```python
|
||||
from ragflow_sdk import RAGFlow
|
||||
|
||||
rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:9380")
|
||||
AGENT_id = "AGENT_ID"
|
||||
agent = rag_object.list_agents(id = AGENT_id)[0]
|
||||
agent.delete_sessions(ids=["id_1","id_2"])
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user