Browse Source

Updated descriptions of agent APIs (#3407)

### What problem does this PR solve?


### Type of change


- [x] Documentation Update
tags/v0.14.0
writinwaters 11 months ago
parent
commit
df9d054551
No account linked to committer's email address
2 changed files with 92 additions and 54 deletions
  1. 58
    33
      docs/references/http_api_reference.md
  2. 34
    21
      docs/references/python_api_reference.md

+ 58
- 33
docs/references/http_api_reference.md View File

The name of the embedding model to use. For example: `"BAAI/bge-zh-v1.5"` The name of the embedding model to use. For example: `"BAAI/bge-zh-v1.5"`


- `"permission"`: (*Body parameter*), `string` - `"permission"`: (*Body parameter*), `string`
Specifies who can access the dataset to create. You can set it only to `"me"` for now.
Specifies who can access the dataset to create. Available options:
- `"me"`: (Default) Only you can manage the dataset.
- `"team"`: All team members can manage the dataset.


- `"chunk_method"`: (*Body parameter*), `enum<string>` - `"chunk_method"`: (*Body parameter*), `enum<string>`
The chunking method of the dataset to create. Available options: The chunking method of the dataset to create. Available options:
} }
``` ```


## Create session
## Create session with chat assistant


**POST** `/api/v1/chats/{chat_id}/sessions` **POST** `/api/v1/chats/{chat_id}/sessions`


Creates a chat session.
Creates a session with a chat assistant.


### Request ### Request




**PUT** `/api/v1/chats/{chat_id}/sessions/{session_id}` **PUT** `/api/v1/chats/{chat_id}/sessions/{session_id}`


Updates a chat session.
Updates a session of a specified chat assistant.


### Request ### Request




**DELETE** `/api/v1/chats/{chat_id}/sessions` **DELETE** `/api/v1/chats/{chat_id}/sessions`


Deletes sessions by ID.
Deletes sessions of a chat assistant by ID.


### Request ### Request




--- ---


## Converse
## Converse with chat assistant


**POST** `/api/v1/chats/{chat_id}/completions` **POST** `/api/v1/chats/{chat_id}/completions`


Asks a question to start an AI-powered conversation.
Asks a specified chat assistant a question to start an AI-powered conversation.

:::tip NOTE

- In streaming mode, not all responses include a reference, as this depends on the system's judgement.
- In streaming mode, the last message is an empty message:

```text
data:
{
"code": 0,
"data": true
}
```

:::


### Request ### Request




- `chat_id`: (*Path parameter*) - `chat_id`: (*Path parameter*)
The ID of the associated chat assistant. The ID of the associated chat assistant.
- `"question"`: (*Body Parameter*), `string` *Required*
- `"question"`: (*Body Parameter*), `string`, *Required*
The question to start an AI-powered conversation. The question to start an AI-powered conversation.
- `"stream"`: (*Body Parameter*), `boolean` - `"stream"`: (*Body Parameter*), `boolean`
Indicates whether to output responses in a streaming way: Indicates whether to output responses in a streaming way:


Success: Success:


```text
```json
data:{ data:{
"code": 0, "code": 0,
"data": { "data": {
} }
``` ```


## Create agent session
---

## Create session with an agent


**POST** `/api/v1/agents/{agent_id}/sessions` **POST** `/api/v1/agents/{agent_id}/sessions`


Creates an agent session.
Creates a session with an agent.


### Request ### Request




#### Request parameters #### Request parameters


- `agent_id`: (*Path parameter*)
- `agent_id`: (*Path parameter*)
The ID of the associated agent assistant. The ID of the associated agent assistant.


### Response ### Response
"id": "7869e9e49c1711ef92840242ac120006", "id": "7869e9e49c1711ef92840242ac120006",
"message": [ "message": [
{ {
"content": "Hello! I am the HR responsible for recruitment at Infineon. I learned that you are an expert in this field, and I took the liberty of reaching out to you. There is an opportunity I would like to share with you. RAGFlow is currently looking for a senior engineer for your position. I was wondering if you might be interested?",
"content": "Hello! I am a recruiter at InfiniFlow. I learned that you are an expert in the field, and took the liberty of reaching out to you. There is an opportunity I would like to share with you. RAGFlow is currently looking for a senior engineer for your position. I was wondering if you might be interested?",
"role": "assistant" "role": "assistant"
} }
], ],
} }
``` ```


---



## Converse through agent
## Converse with agent


**POST** `/api/v1/agents/{agent_id}/completions` **POST** `/api/v1/agents/{agent_id}/completions`
#######
Asks a question to start an AI-powered conversation.

Asks a specified agent a question to start an AI-powered conversation.

:::tip NOTE

- In streaming mode, not all responses include a reference, as this depends on the system's judgement.
- In streaming mode, the last message is an empty message:

```text
data:
{
"code": 0,
"data": true
}
```

:::


### Request ### Request




#### Request Parameters #### Request Parameters


- `agent_id`: (*Path parameter*)
- `agent_id`: (*Path parameter*), `string`
The ID of the associated agent assistant. The ID of the associated agent assistant.
- `"question"`: (*Body Parameter*), `string` *Required*
- `"question"`: (*Body Parameter*), `string`, *Required*
The question to start an AI-powered conversation. The question to start an AI-powered conversation.
- `"stream"`: (*Body Parameter*), `boolean` - `"stream"`: (*Body Parameter*), `boolean`
Indicates whether to output responses in a streaming way:
Indicates whether to output responses in a streaming way:
- `true`: Enable streaming. - `true`: Enable streaming.
- `false`: Disable streaming (default). - `false`: Disable streaming (default).
- `"session_id"`: (*Body Parameter*) - `"session_id"`: (*Body Parameter*)
The ID of session. If it is not provided, a new session will be generated.
The ID of the session. If it is not provided, a new session will be generated.


### Response ### Response


} }
data:{ data:{
"code": 0, "code": 0,
"message": "",
"data": { "data": {
"answer": "Hello", "answer": "Hello",
"reference": [], "reference": [],
} }
data:{ data:{
"code": 0, "code": 0,
"message": "",
"data": { "data": {
"answer": "Hello!", "answer": "Hello!",
"reference": [], "reference": [],
} }
data:{ data:{
"code": 0, "code": 0,
"message": "",
"data": { "data": {
"answer": "Hello! How", "answer": "Hello! How",
"reference": [], "reference": [],
} }
data:{ data:{
"code": 0, "code": 0,
"message": "",
"data": { "data": {
"answer": "Hello! How can", "answer": "Hello! How can",
"reference": [], "reference": [],
} }
data:{ data:{
"code": 0, "code": 0,
"message": "",
"data": { "data": {
"answer": "Hello! How can I", "answer": "Hello! How can I",
"reference": [], "reference": [],
} }
data:{ data:{
"code": 0, "code": 0,
"message": "",
"data": { "data": {
"answer": "Hello! How can I assist", "answer": "Hello! How can I assist",
"reference": [], "reference": [],
} }
data:{ data:{
"code": 0, "code": 0,
"message": "",
"data": { "data": {
"answer": "Hello! How can I assist you", "answer": "Hello! How can I assist you",
"reference": [], "reference": [],
} }
data:{ data:{
"code": 0, "code": 0,
"message": "",
"data": { "data": {
"answer": "Hello! How can I assist you today", "answer": "Hello! How can I assist you today",
"reference": [], "reference": [],
} }
data:{ data:{
"code": 0, "code": 0,
"message": "",
"data": { "data": {
"answer": "Hello! How can I assist you today?", "answer": "Hello! How can I assist you today?",
"reference": [], "reference": [],
} }
data:{ data:{
"code": 0, "code": 0,
"message": "",
"data": { "data": {
"answer": "Hello! How can I assist you today?", "answer": "Hello! How can I assist you today?",
"reference": [], "reference": [],
} }
data:{ data:{
"code": 0, "code": 0,
"message": "",
"data": true "data": true
} }
``` ```
"code": 102, "code": 102,
"message": "`question` is required." "message": "`question` is required."
} }
```
```

---

+ 34
- 21
docs/references/python_api_reference.md View File



#### permission #### permission


Specifies who can access the dataset to create. You can set it only to `"me"` for now.
Specifies who can access the dataset to create. Available options:

- `"me"`: (Default) Only you can manage the dataset.
- `"team"`: All team members can manage the dataset.


#### chunk_method, `str` #### chunk_method, `str`




### Parameters ### Parameters


#### question: `str` *Required*
#### question: `str`, *Required*


The user query or query keywords. Defaults to `""`. The user query or query keywords. Defaults to `""`.




--- ---


## Create session
## Create session with chat assistant


```python ```python
Chat.create_session(name: str = "New session") -> Session Chat.create_session(name: str = "New session") -> Session
``` ```


Creates a chat session.
Creates a session with the current chat assistant.


### Parameters ### Parameters




--- ---


## Update session
## Update chat assistant's session


```python ```python
Session.update(update_message: dict) Session.update(update_message: dict)
``` ```


Updates the current session.
Updates the current session of the current chat assistant.


### Parameters ### Parameters




--- ---


## List sessions
## List chat assistant's sessions


```python ```python
Chat.list_sessions( Chat.list_sessions(


--- ---


## Delete sessions
## Delete chat assistant's sessions


```python ```python
Chat.delete_sessions(ids:list[str] = None) Chat.delete_sessions(ids:list[str] = None)
``` ```


Deletes sessions by ID.
Deletes sessions of the current chat assistant by ID.


### Parameters ### Parameters




--- ---


## Converse
## Converse with chat assistant


```python ```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 question to start an AI-powered conversation.
Asks a specified chat assistant a question to start an AI-powered conversation.

:::tip NOTE
In streaming mode, not all responses include a reference, as this depends on the system's judgement.
:::


### Parameters ### Parameters


#### question: `str` *Required*
#### question: `str`, *Required*


The question to start an AI-powered conversation. The question to start an AI-powered conversation.


print(ans.content[len(cont):], end='', flush=True) print(ans.content[len(cont):], end='', flush=True)
cont = ans.content cont = ans.content
``` ```

--- ---


## Create agent session
## Create session with agent


```python ```python
Agent.create_session(id,rag) -> Session Agent.create_session(id,rag) -> Session
``` ```


Creates a agemt session.
Creates a session with the current agent.


### Returns ### Returns


- Success: A `Session` object containing the following attributes: - Success: A `Session` object containing the following attributes:
- `id`: `str` The auto-generated unique identifier of the created session. - `id`: `str` The auto-generated unique identifier of the created session.
- `message`: `list[Message]` The messages of the created session assistant. Default: `[{"role": "assistant", "content": "Hi! I am your assistant,can I help you?"}]` - `message`: `list[Message]` The messages of the created session assistant. Default: `[{"role": "assistant", "content": "Hi! I am your assistant,can I help you?"}]`
- `agnet_id`: `str` The ID of the associated agent assistant.
- `agent_id`: `str` The ID of the associated agent assistant.
- Failure: `Exception` - Failure: `Exception`


### Examples ### Examples
AGENT_ID = "AGENT_ID" AGENT_ID = "AGENT_ID"
session = create_session(AGENT_ID,rag_object) session = create_session(AGENT_ID,rag_object)
``` ```

--- ---


## Converse through agent
## Converse with agent


```python ```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 question to start an AI-powered conversation.
Asks a specified agent a question to start an AI-powered conversation.

:::tip NOTE
In streaming mode, not all responses include a reference, as this depends on the system's judgement.
:::


### Parameters ### Parameters


#### question: `str` *Required*
#### question: `str`, *Required*


The question to start an AI-powered conversation. The question to start an AI-powered conversation.


AGENT_id = "AGENT_ID" AGENT_id = "AGENT_ID"
session = Agent.create_session(AGENT_id,rag_object) session = Agent.create_session(AGENT_id,rag_object)


print("\n==================== Miss R =====================\n")
print("\n===== Miss R ====\n")
print("Hello. What can I do for you?") print("Hello. What can I do for you?")


while True: while True:
question = input("\n==================== User =====================\n> ")
print("\n==================== Miss R =====================\n")
question = input("\n===== User ====\n> ")
print("\n==== Miss R ====\n")
cont = "" cont = ""
for ans in session.ask(question, stream=True): for ans in session.ask(question, stream=True):

Loading…
Cancel
Save