writinwaters commited on
Commit
0c0ac14
·
1 Parent(s): 06bd4d8

Updated descriptions of agent APIs (#3407)

Browse files

### What problem does this PR solve?


### Type of change


- [x] Documentation Update

docs/references/http_api_reference.md CHANGED
@@ -77,7 +77,9 @@ curl --request POST \
77
  The name of the embedding model to use. For example: `"BAAI/bge-zh-v1.5"`
78
 
79
  - `"permission"`: (*Body parameter*), `string`
80
- Specifies who can access the dataset to create. You can set it only to `"me"` for now.
 
 
81
 
82
  - `"chunk_method"`: (*Body parameter*), `enum<string>`
83
  The chunking method of the dataset to create. Available options:
@@ -1704,11 +1706,11 @@ Failure:
1704
  }
1705
  ```
1706
 
1707
- ## Create session
1708
 
1709
  **POST** `/api/v1/chats/{chat_id}/sessions`
1710
 
1711
- Creates a chat session.
1712
 
1713
  ### Request
1714
 
@@ -1780,7 +1782,7 @@ Failure:
1780
 
1781
  **PUT** `/api/v1/chats/{chat_id}/sessions/{session_id}`
1782
 
1783
- Updates a chat session.
1784
 
1785
  ### Request
1786
 
@@ -1917,7 +1919,7 @@ Failure:
1917
 
1918
  **DELETE** `/api/v1/chats/{chat_id}/sessions`
1919
 
1920
- Deletes sessions by ID.
1921
 
1922
  ### Request
1923
 
@@ -1971,11 +1973,26 @@ Failure:
1971
 
1972
  ---
1973
 
1974
- ## Converse
1975
 
1976
  **POST** `/api/v1/chats/{chat_id}/completions`
1977
 
1978
- Asks a question to start an AI-powered conversation.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1979
 
1980
  ### Request
1981
 
@@ -2007,7 +2024,7 @@ curl --request POST \
2007
 
2008
  - `chat_id`: (*Path parameter*)
2009
  The ID of the associated chat assistant.
2010
- - `"question"`: (*Body Parameter*), `string` *Required*
2011
  The question to start an AI-powered conversation.
2012
  - `"stream"`: (*Body Parameter*), `boolean`
2013
  Indicates whether to output responses in a streaming way:
@@ -2020,7 +2037,7 @@ curl --request POST \
2020
 
2021
  Success:
2022
 
2023
- ```text
2024
  data:{
2025
  "code": 0,
2026
  "data": {
@@ -2101,11 +2118,13 @@ Failure:
2101
  }
2102
  ```
2103
 
2104
- ## Create agent session
 
 
2105
 
2106
  **POST** `/api/v1/agents/{agent_id}/sessions`
2107
 
2108
- Creates an agent session.
2109
 
2110
  ### Request
2111
 
@@ -2129,7 +2148,7 @@ curl --request POST \
2129
 
2130
  #### Request parameters
2131
 
2132
- - `agent_id`: (*Path parameter*)
2133
  The ID of the associated agent assistant.
2134
 
2135
  ### Response
@@ -2144,7 +2163,7 @@ Success:
2144
  "id": "7869e9e49c1711ef92840242ac120006",
2145
  "message": [
2146
  {
2147
- "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?",
2148
  "role": "assistant"
2149
  }
2150
  ],
@@ -2163,13 +2182,28 @@ Failure:
2163
  }
2164
  ```
2165
 
 
2166
 
2167
-
2168
- ## Converse through agent
2169
 
2170
  **POST** `/api/v1/agents/{agent_id}/completions`
2171
- #######
2172
- Asks a question to start an AI-powered conversation.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2173
 
2174
  ### Request
2175
 
@@ -2199,16 +2233,16 @@ curl --request POST \
2199
 
2200
  #### Request Parameters
2201
 
2202
- - `agent_id`: (*Path parameter*)
2203
  The ID of the associated agent assistant.
2204
- - `"question"`: (*Body Parameter*), `string` *Required*
2205
  The question to start an AI-powered conversation.
2206
  - `"stream"`: (*Body Parameter*), `boolean`
2207
- Indicates whether to output responses in a streaming way:
2208
  - `true`: Enable streaming.
2209
  - `false`: Disable streaming (default).
2210
  - `"session_id"`: (*Body Parameter*)
2211
- The ID of session. If it is not provided, a new session will be generated.
2212
 
2213
  ### Response
2214
 
@@ -2227,7 +2261,6 @@ data:{
2227
  }
2228
  data:{
2229
  "code": 0,
2230
- "message": "",
2231
  "data": {
2232
  "answer": "Hello",
2233
  "reference": [],
@@ -2237,7 +2270,6 @@ data:{
2237
  }
2238
  data:{
2239
  "code": 0,
2240
- "message": "",
2241
  "data": {
2242
  "answer": "Hello!",
2243
  "reference": [],
@@ -2247,7 +2279,6 @@ data:{
2247
  }
2248
  data:{
2249
  "code": 0,
2250
- "message": "",
2251
  "data": {
2252
  "answer": "Hello! How",
2253
  "reference": [],
@@ -2257,7 +2288,6 @@ data:{
2257
  }
2258
  data:{
2259
  "code": 0,
2260
- "message": "",
2261
  "data": {
2262
  "answer": "Hello! How can",
2263
  "reference": [],
@@ -2267,7 +2297,6 @@ data:{
2267
  }
2268
  data:{
2269
  "code": 0,
2270
- "message": "",
2271
  "data": {
2272
  "answer": "Hello! How can I",
2273
  "reference": [],
@@ -2277,7 +2306,6 @@ data:{
2277
  }
2278
  data:{
2279
  "code": 0,
2280
- "message": "",
2281
  "data": {
2282
  "answer": "Hello! How can I assist",
2283
  "reference": [],
@@ -2287,7 +2315,6 @@ data:{
2287
  }
2288
  data:{
2289
  "code": 0,
2290
- "message": "",
2291
  "data": {
2292
  "answer": "Hello! How can I assist you",
2293
  "reference": [],
@@ -2297,7 +2324,6 @@ data:{
2297
  }
2298
  data:{
2299
  "code": 0,
2300
- "message": "",
2301
  "data": {
2302
  "answer": "Hello! How can I assist you today",
2303
  "reference": [],
@@ -2307,7 +2333,6 @@ data:{
2307
  }
2308
  data:{
2309
  "code": 0,
2310
- "message": "",
2311
  "data": {
2312
  "answer": "Hello! How can I assist you today?",
2313
  "reference": [],
@@ -2317,7 +2342,6 @@ data:{
2317
  }
2318
  data:{
2319
  "code": 0,
2320
- "message": "",
2321
  "data": {
2322
  "answer": "Hello! How can I assist you today?",
2323
  "reference": [],
@@ -2327,7 +2351,6 @@ data:{
2327
  }
2328
  data:{
2329
  "code": 0,
2330
- "message": "",
2331
  "data": true
2332
  }
2333
  ```
@@ -2339,4 +2362,6 @@ Failure:
2339
  "code": 102,
2340
  "message": "`question` is required."
2341
  }
2342
- ```
 
 
 
77
  The name of the embedding model to use. For example: `"BAAI/bge-zh-v1.5"`
78
 
79
  - `"permission"`: (*Body parameter*), `string`
80
+ Specifies who can access the dataset to create. Available options:
81
+ - `"me"`: (Default) Only you can manage the dataset.
82
+ - `"team"`: All team members can manage the dataset.
83
 
84
  - `"chunk_method"`: (*Body parameter*), `enum<string>`
85
  The chunking method of the dataset to create. Available options:
 
1706
  }
1707
  ```
1708
 
1709
+ ## Create session with chat assistant
1710
 
1711
  **POST** `/api/v1/chats/{chat_id}/sessions`
1712
 
1713
+ Creates a session with a chat assistant.
1714
 
1715
  ### Request
1716
 
 
1782
 
1783
  **PUT** `/api/v1/chats/{chat_id}/sessions/{session_id}`
1784
 
1785
+ Updates a session of a specified chat assistant.
1786
 
1787
  ### Request
1788
 
 
1919
 
1920
  **DELETE** `/api/v1/chats/{chat_id}/sessions`
1921
 
1922
+ Deletes sessions of a chat assistant by ID.
1923
 
1924
  ### Request
1925
 
 
1973
 
1974
  ---
1975
 
1976
+ ## Converse with chat assistant
1977
 
1978
  **POST** `/api/v1/chats/{chat_id}/completions`
1979
 
1980
+ Asks a specified chat assistant a question to start an AI-powered conversation.
1981
+
1982
+ :::tip NOTE
1983
+
1984
+ - In streaming mode, not all responses include a reference, as this depends on the system's judgement.
1985
+ - In streaming mode, the last message is an empty message:
1986
+
1987
+ ```text
1988
+ data:
1989
+ {
1990
+ "code": 0,
1991
+ "data": true
1992
+ }
1993
+ ```
1994
+
1995
+ :::
1996
 
1997
  ### Request
1998
 
 
2024
 
2025
  - `chat_id`: (*Path parameter*)
2026
  The ID of the associated chat assistant.
2027
+ - `"question"`: (*Body Parameter*), `string`, *Required*
2028
  The question to start an AI-powered conversation.
2029
  - `"stream"`: (*Body Parameter*), `boolean`
2030
  Indicates whether to output responses in a streaming way:
 
2037
 
2038
  Success:
2039
 
2040
+ ```json
2041
  data:{
2042
  "code": 0,
2043
  "data": {
 
2118
  }
2119
  ```
2120
 
2121
+ ---
2122
+
2123
+ ## Create session with an agent
2124
 
2125
  **POST** `/api/v1/agents/{agent_id}/sessions`
2126
 
2127
+ Creates a session with an agent.
2128
 
2129
  ### Request
2130
 
 
2148
 
2149
  #### Request parameters
2150
 
2151
+ - `agent_id`: (*Path parameter*)
2152
  The ID of the associated agent assistant.
2153
 
2154
  ### Response
 
2163
  "id": "7869e9e49c1711ef92840242ac120006",
2164
  "message": [
2165
  {
2166
+ "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?",
2167
  "role": "assistant"
2168
  }
2169
  ],
 
2182
  }
2183
  ```
2184
 
2185
+ ---
2186
 
2187
+ ## Converse with agent
 
2188
 
2189
  **POST** `/api/v1/agents/{agent_id}/completions`
2190
+
2191
+ Asks a specified agent a question to start an AI-powered conversation.
2192
+
2193
+ :::tip NOTE
2194
+
2195
+ - In streaming mode, not all responses include a reference, as this depends on the system's judgement.
2196
+ - In streaming mode, the last message is an empty message:
2197
+
2198
+ ```text
2199
+ data:
2200
+ {
2201
+ "code": 0,
2202
+ "data": true
2203
+ }
2204
+ ```
2205
+
2206
+ :::
2207
 
2208
  ### Request
2209
 
 
2233
 
2234
  #### Request Parameters
2235
 
2236
+ - `agent_id`: (*Path parameter*), `string`
2237
  The ID of the associated agent assistant.
2238
+ - `"question"`: (*Body Parameter*), `string`, *Required*
2239
  The question to start an AI-powered conversation.
2240
  - `"stream"`: (*Body Parameter*), `boolean`
2241
+ Indicates whether to output responses in a streaming way:
2242
  - `true`: Enable streaming.
2243
  - `false`: Disable streaming (default).
2244
  - `"session_id"`: (*Body Parameter*)
2245
+ The ID of the session. If it is not provided, a new session will be generated.
2246
 
2247
  ### Response
2248
 
 
2261
  }
2262
  data:{
2263
  "code": 0,
 
2264
  "data": {
2265
  "answer": "Hello",
2266
  "reference": [],
 
2270
  }
2271
  data:{
2272
  "code": 0,
 
2273
  "data": {
2274
  "answer": "Hello!",
2275
  "reference": [],
 
2279
  }
2280
  data:{
2281
  "code": 0,
 
2282
  "data": {
2283
  "answer": "Hello! How",
2284
  "reference": [],
 
2288
  }
2289
  data:{
2290
  "code": 0,
 
2291
  "data": {
2292
  "answer": "Hello! How can",
2293
  "reference": [],
 
2297
  }
2298
  data:{
2299
  "code": 0,
 
2300
  "data": {
2301
  "answer": "Hello! How can I",
2302
  "reference": [],
 
2306
  }
2307
  data:{
2308
  "code": 0,
 
2309
  "data": {
2310
  "answer": "Hello! How can I assist",
2311
  "reference": [],
 
2315
  }
2316
  data:{
2317
  "code": 0,
 
2318
  "data": {
2319
  "answer": "Hello! How can I assist you",
2320
  "reference": [],
 
2324
  }
2325
  data:{
2326
  "code": 0,
 
2327
  "data": {
2328
  "answer": "Hello! How can I assist you today",
2329
  "reference": [],
 
2333
  }
2334
  data:{
2335
  "code": 0,
 
2336
  "data": {
2337
  "answer": "Hello! How can I assist you today?",
2338
  "reference": [],
 
2342
  }
2343
  data:{
2344
  "code": 0,
 
2345
  "data": {
2346
  "answer": "Hello! How can I assist you today?",
2347
  "reference": [],
 
2351
  }
2352
  data:{
2353
  "code": 0,
 
2354
  "data": true
2355
  }
2356
  ```
 
2362
  "code": 102,
2363
  "message": "`question` is required."
2364
  }
2365
+ ```
2366
+
2367
+ ---
docs/references/python_api_reference.md CHANGED
@@ -63,7 +63,10 @@ The language setting of the dataset to create. Available options:
63
 
64
  #### permission
65
 
66
- Specifies who can access the dataset to create. You can set it only to `"me"` for now.
 
 
 
67
 
68
  #### chunk_method, `str`
69
 
@@ -819,7 +822,7 @@ Retrieves chunks from specified datasets.
819
 
820
  ### Parameters
821
 
822
- #### question: `str` *Required*
823
 
824
  The user query or query keywords. Defaults to `""`.
825
 
@@ -1141,13 +1144,13 @@ Chat Session APIs
1141
 
1142
  ---
1143
 
1144
- ## Create session
1145
 
1146
  ```python
1147
  Chat.create_session(name: str = "New session") -> Session
1148
  ```
1149
 
1150
- Creates a chat session.
1151
 
1152
  ### Parameters
1153
 
@@ -1177,13 +1180,13 @@ session = assistant.create_session()
1177
 
1178
  ---
1179
 
1180
- ## Update session
1181
 
1182
  ```python
1183
  Session.update(update_message: dict)
1184
  ```
1185
 
1186
- Updates the current session.
1187
 
1188
  ### Parameters
1189
 
@@ -1212,7 +1215,7 @@ session.update({"name": "updated_name"})
1212
 
1213
  ---
1214
 
1215
- ## List sessions
1216
 
1217
  ```python
1218
  Chat.list_sessions(
@@ -1275,13 +1278,13 @@ for session in assistant.list_sessions():
1275
 
1276
  ---
1277
 
1278
- ## Delete sessions
1279
 
1280
  ```python
1281
  Chat.delete_sessions(ids:list[str] = None)
1282
  ```
1283
 
1284
- Deletes sessions by ID.
1285
 
1286
  ### Parameters
1287
 
@@ -1307,17 +1310,21 @@ assistant.delete_sessions(ids=["id_1","id_2"])
1307
 
1308
  ---
1309
 
1310
- ## Converse
1311
 
1312
  ```python
1313
  Session.ask(question: str, stream: bool = False) -> Optional[Message, iter[Message]]
1314
  ```
1315
 
1316
- Asks a question to start an AI-powered conversation.
 
 
 
 
1317
 
1318
  ### Parameters
1319
 
1320
- #### question: `str` *Required*
1321
 
1322
  The question to start an AI-powered conversation.
1323
 
@@ -1390,22 +1397,23 @@ while True:
1390
  print(ans.content[len(cont):], end='', flush=True)
1391
  cont = ans.content
1392
  ```
 
1393
  ---
1394
 
1395
- ## Create agent session
1396
 
1397
  ```python
1398
  Agent.create_session(id,rag) -> Session
1399
  ```
1400
 
1401
- Creates a agemt session.
1402
 
1403
  ### Returns
1404
 
1405
  - Success: A `Session` object containing the following attributes:
1406
  - `id`: `str` The auto-generated unique identifier of the created session.
1407
  - `message`: `list[Message]` The messages of the created session assistant. Default: `[{"role": "assistant", "content": "Hi! I am your assistant,can I help you?"}]`
1408
- - `agnet_id`: `str` The ID of the associated agent assistant.
1409
  - Failure: `Exception`
1410
 
1411
  ### Examples
@@ -1417,19 +1425,24 @@ rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:
1417
  AGENT_ID = "AGENT_ID"
1418
  session = create_session(AGENT_ID,rag_object)
1419
  ```
 
1420
  ---
1421
 
1422
- ## Converse through agent
1423
 
1424
  ```python
1425
  Session.ask(question: str, stream: bool = False) -> Optional[Message, iter[Message]]
1426
  ```
1427
 
1428
- Asks a question to start an AI-powered conversation.
 
 
 
 
1429
 
1430
  ### Parameters
1431
 
1432
- #### question: `str` *Required*
1433
 
1434
  The question to start an AI-powered conversation.
1435
 
@@ -1489,12 +1502,12 @@ rag_object = RAGFlow(api_key="<YOUR_API_KEY>", base_url="http://<YOUR_BASE_URL>:
1489
  AGENT_id = "AGENT_ID"
1490
  session = Agent.create_session(AGENT_id,rag_object)
1491
 
1492
- print("\n==================== Miss R =====================\n")
1493
  print("Hello. What can I do for you?")
1494
 
1495
  while True:
1496
- question = input("\n==================== User =====================\n> ")
1497
- print("\n==================== Miss R =====================\n")
1498
 
1499
  cont = ""
1500
  for ans in session.ask(question, stream=True):
 
63
 
64
  #### permission
65
 
66
+ Specifies who can access the dataset to create. Available options:
67
+
68
+ - `"me"`: (Default) Only you can manage the dataset.
69
+ - `"team"`: All team members can manage the dataset.
70
 
71
  #### chunk_method, `str`
72
 
 
822
 
823
  ### Parameters
824
 
825
+ #### question: `str`, *Required*
826
 
827
  The user query or query keywords. Defaults to `""`.
828
 
 
1144
 
1145
  ---
1146
 
1147
+ ## Create session with chat assistant
1148
 
1149
  ```python
1150
  Chat.create_session(name: str = "New session") -> Session
1151
  ```
1152
 
1153
+ Creates a session with the current chat assistant.
1154
 
1155
  ### Parameters
1156
 
 
1180
 
1181
  ---
1182
 
1183
+ ## Update chat assistant's session
1184
 
1185
  ```python
1186
  Session.update(update_message: dict)
1187
  ```
1188
 
1189
+ Updates the current session of the current chat assistant.
1190
 
1191
  ### Parameters
1192
 
 
1215
 
1216
  ---
1217
 
1218
+ ## List chat assistant's sessions
1219
 
1220
  ```python
1221
  Chat.list_sessions(
 
1278
 
1279
  ---
1280
 
1281
+ ## Delete chat assistant's sessions
1282
 
1283
  ```python
1284
  Chat.delete_sessions(ids:list[str] = None)
1285
  ```
1286
 
1287
+ Deletes sessions of the current chat assistant by ID.
1288
 
1289
  ### Parameters
1290
 
 
1310
 
1311
  ---
1312
 
1313
+ ## Converse with chat assistant
1314
 
1315
  ```python
1316
  Session.ask(question: str, stream: bool = False) -> Optional[Message, iter[Message]]
1317
  ```
1318
 
1319
+ Asks a specified chat assistant a question to start an AI-powered conversation.
1320
+
1321
+ :::tip NOTE
1322
+ In streaming mode, not all responses include a reference, as this depends on the system's judgement.
1323
+ :::
1324
 
1325
  ### Parameters
1326
 
1327
+ #### question: `str`, *Required*
1328
 
1329
  The question to start an AI-powered conversation.
1330
 
 
1397
  print(ans.content[len(cont):], end='', flush=True)
1398
  cont = ans.content
1399
  ```
1400
+
1401
  ---
1402
 
1403
+ ## Create session with agent
1404
 
1405
  ```python
1406
  Agent.create_session(id,rag) -> Session
1407
  ```
1408
 
1409
+ Creates a session with the current agent.
1410
 
1411
  ### Returns
1412
 
1413
  - Success: A `Session` object containing the following attributes:
1414
  - `id`: `str` The auto-generated unique identifier of the created session.
1415
  - `message`: `list[Message]` The messages of the created session assistant. Default: `[{"role": "assistant", "content": "Hi! I am your assistant,can I help you?"}]`
1416
+ - `agent_id`: `str` The ID of the associated agent assistant.
1417
  - Failure: `Exception`
1418
 
1419
  ### Examples
 
1425
  AGENT_ID = "AGENT_ID"
1426
  session = create_session(AGENT_ID,rag_object)
1427
  ```
1428
+
1429
  ---
1430
 
1431
+ ## Converse with agent
1432
 
1433
  ```python
1434
  Session.ask(question: str, stream: bool = False) -> Optional[Message, iter[Message]]
1435
  ```
1436
 
1437
+ Asks a specified agent a question to start an AI-powered conversation.
1438
+
1439
+ :::tip NOTE
1440
+ In streaming mode, not all responses include a reference, as this depends on the system's judgement.
1441
+ :::
1442
 
1443
  ### Parameters
1444
 
1445
+ #### question: `str`, *Required*
1446
 
1447
  The question to start an AI-powered conversation.
1448
 
 
1502
  AGENT_id = "AGENT_ID"
1503
  session = Agent.create_session(AGENT_id,rag_object)
1504
 
1505
+ print("\n===== Miss R ====\n")
1506
  print("Hello. What can I do for you?")
1507
 
1508
  while True:
1509
+ question = input("\n===== User ====\n> ")
1510
+ print("\n==== Miss R ====\n")
1511
 
1512
  cont = ""
1513
  for ans in session.ask(question, stream=True):