Update the component of the agent API with parameters. (#4131)

### What problem does this PR solve?

Update the  component of the agent API with parameters.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring

---------

Co-authored-by: liuhua <10215101452@stu.ecun.edu.cn>
Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
Co-authored-by: writinwaters <93570324+writinwaters@users.noreply.github.com>
This commit is contained in:
liuhua
2024-12-20 17:34:16 +08:00
committed by GitHub
parent a0dc9e1bdf
commit 35580af875
8 changed files with 152 additions and 185 deletions

View File

@ -1,4 +1,4 @@
---
from scipy.special import kwargs---
sidebar_position: 2
slug: /python_api_reference
---
@ -1312,7 +1312,7 @@ assistant.delete_sessions(ids=["id_1","id_2"])
### Converse with chat assistant
```python
Session.ask(question: str, stream: bool = False) -> Optional[Message, iter[Message]]
Session.ask(question: str = "", stream: bool = False, **kwargs) -> Optional[Message, iter[Message]]
```
Asks a specified chat assistant a question to start an AI-powered conversation.
@ -1325,7 +1325,7 @@ In streaming mode, not all responses include a reference, as this depends on the
##### question: `str`, *Required*
The question to start an AI-powered conversation.
The question to start an AI-powered conversation. Defalut to `""`
##### stream: `bool`
@ -1334,6 +1334,10 @@ Indicates whether to output responses in a streaming way:
- `True`: Enable streaming (default).
- `False`: Disable streaming.
##### **kwargs
The parameters in prompt(system).
#### Returns
- A `Message` object containing the response to the question if `stream` is set to `False`.
@ -1402,11 +1406,25 @@ while True:
### Create session with agent
```python
Agent.create_session(id,rag) -> Session
Agent.create_session(id,rag, **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.
#### Returns
- Success: A `Session` object containing the following attributes:
@ -1430,7 +1448,7 @@ session = create_session(AGENT_ID,rag_object)
### Converse with agent
```python
Session.ask(question: str, stream: bool = False) -> Optional[Message, iter[Message]]
Session.ask(question: str="", stream: bool = False) -> Optional[Message, iter[Message]]
```
Asks a specified agent a question to start an AI-powered conversation.
@ -1441,9 +1459,9 @@ In streaming mode, not all responses include a reference, as this depends on the
#### Parameters
##### question: `str`, *Required*
##### question: `str`
The question to start an AI-powered conversation.
The question to start an AI-powered conversation. If the `begin` component takes parameters, a question is not required.
##### stream: `bool`