[关闭]
@superpigy 2025-09-09T09:15:32.000000Z 字数 67548 阅读 18

Hamuna RAG API

HTTP API


ERROR CODES


Code Message Description
400 Bad Request Invalid request parameters
401 Unauthorized Unauthorized access
403 Forbidden Access denied
404 Not Found Resource not found
500 Internal Server Error Server internal error
1001 Invalid Chunk ID Invalid Chunk ID
1002 Chunk Update Failed Chunk update failed

OpenAI-Compatible API


Create chat completion

POST /api/v1/chats_openai/{chat_id}/chat/completions

Creates a model response for a given chat conversation.

This API follows the same request and response format as OpenAI's API. It allows you to interact with the model in a manner similar to how you would with OpenAI's API.

Request

Request example
  1. curl --request POST \
  2. --url http://{address}/api/v1/chats_openai/{chat_id}/chat/completions \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '{
  6. "model": "model",
  7. "messages": [{"role": "user", "content": "Say this is a test!"}],
  8. "stream": true
  9. }'
Request Parameters

Response

Stream:

  1. {
  2. "id": "chatcmpl-3a9c3572f29311efa69751e139332ced",
  3. "choices": [
  4. {
  5. "delta": {
  6. "content": "This is a test. If you have any specific questions or need information, feel",
  7. "role": "assistant",
  8. "function_call": null,
  9. "tool_calls": null
  10. },
  11. "finish_reason": null,
  12. "index": 0,
  13. "logprobs": null
  14. }
  15. ],
  16. "created": 1740543996,
  17. "model": "model",
  18. "object": "chat.completion.chunk",
  19. "system_fingerprint": "",
  20. "usage": null
  21. }
  22. // omit duplicated information
  23. {"choices":[{"delta":{"content":" free to ask, and I will do my best to provide an answer based on","role":"assistant"}}]}
  24. {"choices":[{"delta":{"content":" the knowledge I have. If your question is unrelated to the provided knowledge base,","role":"assistant"}}]}
  25. {"choices":[{"delta":{"content":" I will let you know.","role":"assistant"}}]}
  26. // the last chunk
  27. {
  28. "id": "chatcmpl-3a9c3572f29311efa69751e139332ced",
  29. "choices": [
  30. {
  31. "delta": {
  32. "content": null,
  33. "role": "assistant",
  34. "function_call": null,
  35. "tool_calls": null
  36. },
  37. "finish_reason": "stop",
  38. "index": 0,
  39. "logprobs": null
  40. }
  41. ],
  42. "created": 1740543996,
  43. "model": "model",
  44. "object": "chat.completion.chunk",
  45. "system_fingerprint": "",
  46. "usage": {
  47. "prompt_tokens": 18,
  48. "completion_tokens": 225,
  49. "total_tokens": 243
  50. }
  51. }

Non-stream:

  1. {
  2. "choices":[
  3. {
  4. "finish_reason":"stop",
  5. "index":0,
  6. "logprobs":null,
  7. "message":{
  8. "content":"This is a test. If you have any specific questions or need information, feel free to ask, and I will do my best to provide an answer based on the knowledge I have. If your question is unrelated to the provided knowledge base, I will let you know.",
  9. "role":"assistant"
  10. }
  11. }
  12. ],
  13. "created":1740543499,
  14. "id":"chatcmpl-3a9c3572f29311efa69751e139332ced",
  15. "model":"model",
  16. "object":"chat.completion",
  17. "usage":{
  18. "completion_tokens":246,
  19. "completion_tokens_details":{
  20. "accepted_prediction_tokens":246,
  21. "reasoning_tokens":18,
  22. "rejected_prediction_tokens":0
  23. },
  24. "prompt_tokens":18,
  25. "total_tokens":264
  26. }
  27. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "The last content of this conversation is not from user."
  4. }

Create agent completion

POST /api/v1/agents_openai/{agent_id}/chat/completions

Creates a model response for a given chat conversation.

This API follows the same request and response format as OpenAI's API. It allows you to interact with the model in a manner similar to how you would with OpenAI's API.

Request

Request example
  1. curl --request POST \
  2. --url http://{address}/api/v1/agents_openai/{agent_id}/chat/completions \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '{
  6. "model": "model",
  7. "messages": [{"role": "user", "content": "Say this is a test!"}],
  8. "stream": true
  9. }'
Request Parameters

Response

Stream:

  1. {
  2. "id": "chatcmpl-3a9c3572f29311efa69751e139332ced",
  3. "choices": [
  4. {
  5. "delta": {
  6. "content": "This is a test. If you have any specific questions or need information, feel",
  7. "role": "assistant",
  8. "function_call": null,
  9. "tool_calls": null
  10. },
  11. "finish_reason": null,
  12. "index": 0,
  13. "logprobs": null
  14. }
  15. ],
  16. "created": 1740543996,
  17. "model": "model",
  18. "object": "chat.completion.chunk",
  19. "system_fingerprint": "",
  20. "usage": null
  21. }
  22. // omit duplicated information
  23. {"choices":[{"delta":{"content":" free to ask, and I will do my best to provide an answer based on","role":"assistant"}}]}
  24. {"choices":[{"delta":{"content":" the knowledge I have. If your question is unrelated to the provided knowledge base,","role":"assistant"}}]}
  25. {"choices":[{"delta":{"content":" I will let you know.","role":"assistant"}}]}
  26. // the last chunk
  27. {
  28. "id": "chatcmpl-3a9c3572f29311efa69751e139332ced",
  29. "choices": [
  30. {
  31. "delta": {
  32. "content": null,
  33. "role": "assistant",
  34. "function_call": null,
  35. "tool_calls": null
  36. },
  37. "finish_reason": "stop",
  38. "index": 0,
  39. "logprobs": null
  40. }
  41. ],
  42. "created": 1740543996,
  43. "model": "model",
  44. "object": "chat.completion.chunk",
  45. "system_fingerprint": "",
  46. "usage": {
  47. "prompt_tokens": 18,
  48. "completion_tokens": 225,
  49. "total_tokens": 243
  50. }
  51. }

Non-stream:

  1. {
  2. "choices":[
  3. {
  4. "finish_reason":"stop",
  5. "index":0,
  6. "logprobs":null,
  7. "message":{
  8. "content":"This is a test. If you have any specific questions or need information, feel free to ask, and I will do my best to provide an answer based on the knowledge I have. If your question is unrelated to the provided knowledge base, I will let you know.",
  9. "role":"assistant"
  10. }
  11. }
  12. ],
  13. "created":1740543499,
  14. "id":"chatcmpl-3a9c3572f29311efa69751e139332ced",
  15. "model":"model",
  16. "object":"chat.completion",
  17. "usage":{
  18. "completion_tokens":246,
  19. "completion_tokens_details":{
  20. "accepted_prediction_tokens":246,
  21. "reasoning_tokens":18,
  22. "rejected_prediction_tokens":0
  23. },
  24. "prompt_tokens":18,
  25. "total_tokens":264
  26. }
  27. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "The last content of this conversation is not from user."
  4. }

DATASET MANAGEMENT


Create dataset

POST /api/v1/datasets

Creates a dataset.

Request

Request example
  1. curl --request POST \
  2. --url http://{address}/api/v1/datasets \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '{
  6. "name": "test_1"
  7. }'
Request parameters

Response

Success:

  1. {
  2. "code": 0,
  3. "data": {
  4. "avatar": null,
  5. "chunk_count": 0,
  6. "chunk_method": "naive",
  7. "create_date": "Mon, 28 Apr 2025 18:40:41 GMT",
  8. "create_time": 1745836841611,
  9. "created_by": "3af81804241d11f0a6a79f24fc270c7f",
  10. "description": null,
  11. "document_count": 0,
  12. "embedding_model": "BAAI/bge-large-zh-v1.5@BAAI",
  13. "id": "3b4de7d4241d11f0a6a79f24fc270c7f",
  14. "language": "English",
  15. "name": "RAGFlow example",
  16. "pagerank": 0,
  17. "parser_config": {
  18. "chunk_token_num": 128,
  19. "delimiter": "\\n!?;。;!?",
  20. "html4excel": false,
  21. "layout_recognize": "DeepDOC",
  22. "raptor": {
  23. "use_raptor": false
  24. }
  25. },
  26. "permission": "me",
  27. "similarity_threshold": 0.2,
  28. "status": "1",
  29. "tenant_id": "3af81804241d11f0a6a79f24fc270c7f",
  30. "token_num": 0,
  31. "update_date": "Mon, 28 Apr 2025 18:40:41 GMT",
  32. "update_time": 1745836841611,
  33. "vector_similarity_weight": 0.3,
  34. },
  35. }

Failure:

  1. {
  2. "code": 101,
  3. "message": "Dataset name 'RAGFlow example' already exists"
  4. }

Delete datasets

DELETE /api/v1/datasets

Deletes datasets by ID.

Request

Request example
  1. curl --request DELETE \
  2. --url http://{address}/api/v1/datasets \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '{
  6. "ids": ["d94a8dc02c9711f0930f7fbc369eab6d", "e94a8dc02c9711f0930f7fbc369eab6e"]
  7. }'
Request parameters

Response

Success:

  1. {
  2. "code": 0
  3. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "You don't own the dataset."
  4. }

Update dataset

PUT /api/v1/datasets/{dataset_id}

Updates configurations for a specified dataset.

Request

Request example
  1. curl --request PUT \
  2. --url http://{address}/api/v1/datasets/{dataset_id} \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '
  6. {
  7. "name": "updated_dataset"
  8. }'
Request parameters

Response

Success:

  1. {
  2. "code": 0
  3. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "Can't change tenant_id."
  4. }

List datasets

GET /api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}

Lists datasets.

Request

Request example
  1. curl --request GET \
  2. --url http://{address}/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
  3. --header 'Authorization: Bearer <YOUR_API_KEY>'
Request parameters

Response

Success:

  1. {
  2. "code": 0,
  3. "data": [
  4. {
  5. "avatar": "",
  6. "chunk_count": 59,
  7. "create_date": "Sat, 14 Sep 2024 01:12:37 GMT",
  8. "create_time": 1726276357324,
  9. "created_by": "69736c5e723611efb51b0242ac120007",
  10. "description": null,
  11. "document_count": 1,
  12. "embedding_model": "BAAI/bge-large-zh-v1.5",
  13. "id": "6e211ee0723611efa10a0242ac120007",
  14. "language": "English",
  15. "name": "mysql",
  16. "chunk_method": "naive",
  17. "parser_config": {
  18. "chunk_token_num": 8192,
  19. "delimiter": "\\n",
  20. "entity_types": [
  21. "organization",
  22. "person",
  23. "location",
  24. "event",
  25. "time"
  26. ]
  27. },
  28. "permission": "me",
  29. "similarity_threshold": 0.2,
  30. "status": "1",
  31. "tenant_id": "69736c5e723611efb51b0242ac120007",
  32. "token_num": 12744,
  33. "update_date": "Thu, 10 Oct 2024 04:07:23 GMT",
  34. "update_time": 1728533243536,
  35. "vector_similarity_weight": 0.3
  36. }
  37. ]
  38. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "The dataset doesn't exist"
  4. }

FILE MANAGEMENT WITHIN DATASET


Upload documents

POST /api/v1/datasets/{dataset_id}/documents

Uploads documents to a specified dataset.

Request

Request example
  1. curl --request POST \
  2. --url http://{address}/api/v1/datasets/{dataset_id}/documents \
  3. --header 'Content-Type: multipart/form-data' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --form 'file=@./test1.txt' \
  6. --form 'file=@./test2.pdf'
Request parameters

Response

Success:

  1. {
  2. "code": 0,
  3. "data": [
  4. {
  5. "chunk_method": "naive",
  6. "created_by": "69736c5e723611efb51b0242ac120007",
  7. "dataset_id": "527fa74891e811ef9c650242ac120006",
  8. "id": "b330ec2e91ec11efbc510242ac120004",
  9. "location": "1.txt",
  10. "name": "1.txt",
  11. "parser_config": {
  12. "chunk_token_num": 128,
  13. "delimiter": "\\n",
  14. "html4excel": false,
  15. "layout_recognize": true,
  16. "raptor": {
  17. "use_raptor": false
  18. }
  19. },
  20. "run": "UNSTART",
  21. "size": 17966,
  22. "thumbnail": "",
  23. "type": "doc"
  24. }
  25. ]
  26. }

Failure:

  1. {
  2. "code": 101,
  3. "message": "No file part!"
  4. }

Update document

PUT /api/v1/datasets/{dataset_id}/documents/{document_id}

Updates configurations for a specified document.

Request

Request example
  1. curl --request PUT \
  2. --url http://{address}/api/v1/datasets/{dataset_id}/info/{document_id} \
  3. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  4. --header 'Content-Type: application/json' \
  5. --data '
  6. {
  7. "name": "manual.txt",
  8. "chunk_method": "manual",
  9. "parser_config": {"chunk_token_count": 128}
  10. }'
Request parameters

Response

Success:

  1. {
  2. "code": 0
  3. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "The dataset does not have the document."
  4. }

Download document

GET /api/v1/datasets/{dataset_id}/documents/{document_id}

Downloads a document from a specified dataset.

Request

Request example
  1. curl --request GET \
  2. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id} \
  3. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  4. --output ./ragflow.txt
Request parameters

Response

Success:

  1. This is a test to verify the file download feature.

Failure:

  1. {
  2. "code": 102,
  3. "message": "You do not own the dataset 7898da028a0511efbf750242ac1220005."
  4. }

List documents

GET /api/v1/datasets/{dataset_id}/documents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name}

Lists documents in a specified dataset.

Request

Request example
  1. curl --request GET \
  2. --url http://{address}/api/v1/datasets/{dataset_id}/documents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name} \
  3. --header 'Authorization: Bearer <YOUR_API_KEY>'
Request parameters

Response

Success:

  1. {
  2. "code": 0,
  3. "data": {
  4. "docs": [
  5. {
  6. "chunk_count": 0,
  7. "create_date": "Mon, 14 Oct 2024 09:11:01 GMT",
  8. "create_time": 1728897061948,
  9. "created_by": "69736c5e723611efb51b0242ac120007",
  10. "id": "3bcfbf8a8a0c11ef8aba0242ac120006",
  11. "knowledgebase_id": "7898da028a0511efbf750242ac120005",
  12. "location": "Test_2.txt",
  13. "name": "Test_2.txt",
  14. "parser_config": {
  15. "chunk_token_count": 128,
  16. "delimiter": "\n",
  17. "layout_recognize": true,
  18. "task_page_size": 12
  19. },
  20. "chunk_method": "naive",
  21. "process_begin_at": null,
  22. "process_duation": 0.0,
  23. "progress": 0.0,
  24. "progress_msg": "",
  25. "run": "0",
  26. "size": 7,
  27. "source_type": "local",
  28. "status": "1",
  29. "thumbnail": null,
  30. "token_count": 0,
  31. "type": "doc",
  32. "update_date": "Mon, 14 Oct 2024 09:11:01 GMT",
  33. "update_time": 1728897061948
  34. }
  35. ],
  36. "total": 1
  37. }
  38. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "You don't own the dataset 7898da028a0511efbf750242ac1220005. "
  4. }

Delete documents

DELETE /api/v1/datasets/{dataset_id}/documents

Deletes documents by ID.

Request

Request example
  1. curl --request DELETE \
  2. --url http://{address}/api/v1/datasets/{dataset_id}/documents \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '
  6. {
  7. "ids": ["id_1","id_2"]
  8. }'
Request parameters

Response

Success:

  1. {
  2. "code": 0
  3. }.

Failure:

  1. {
  2. "code": 102,
  3. "message": "You do not own the dataset 7898da028a0511efbf750242ac1220005."
  4. }

Parse documents

POST /api/v1/datasets/{dataset_id}/chunks

Parses documents in a specified dataset.

Request

Request example
  1. curl --request POST \
  2. --url http://{address}/api/v1/datasets/{dataset_id}/chunks \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '
  6. {
  7. "document_ids": ["97a5f1c2759811efaa500242ac120004","97ad64b6759811ef9fc30242ac120004"]
  8. }'
Request parameters

Response

Success:

  1. {
  2. "code": 0
  3. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "`document_ids` is required"
  4. }

Stop parsing documents

DELETE /api/v1/datasets/{dataset_id}/chunks

Stops parsing specified documents.

Request

Request example
  1. curl --request DELETE \
  2. --url http://{address}/api/v1/datasets/{dataset_id}/chunks \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '
  6. {
  7. "document_ids": ["97a5f1c2759811efaa500242ac120004","97ad64b6759811ef9fc30242ac120004"]
  8. }'
Request parameters

Response

Success:

  1. {
  2. "code": 0
  3. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "`document_ids` is required"
  4. }

CHUNK MANAGEMENT WITHIN DATASET


Add chunk

POST /api/v1/datasets/{dataset_id}/documents/{document_id}/chunks

Adds a chunk to a specified document in a specified dataset.

Request

Request example
  1. curl --request POST \
  2. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '
  6. {
  7. "content": "<CHUNK_CONTENT_HERE>"
  8. }'
Request parameters

Response

Success:

  1. {
  2. "code": 0,
  3. "data": {
  4. "chunk": {
  5. "content": "who are you",
  6. "create_time": "2024-12-30 16:59:55",
  7. "create_timestamp": 1735549195.969164,
  8. "dataset_id": "72f36e1ebdf411efb7250242ac120006",
  9. "document_id": "61d68474be0111ef98dd0242ac120006",
  10. "id": "12ccdc56e59837e5",
  11. "important_keywords": [],
  12. "questions": []
  13. }
  14. }
  15. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "`content` is required"
  4. }

List chunks

GET /api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&page={page}&page_size={page_size}&id={id}

Lists chunks in a specified document.

Request

Request example
  1. curl --request GET \
  2. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&page={page}&page_size={page_size}&id={chunk_id} \
  3. --header 'Authorization: Bearer <YOUR_API_KEY>'
Request parameters

Response

Success:

  1. {
  2. "code": 0,
  3. "data": {
  4. "chunks": [
  5. {
  6. "available": true,
  7. "content": "This is a test content.",
  8. "docnm_kwd": "1.txt",
  9. "document_id": "b330ec2e91ec11efbc510242ac120004",
  10. "id": "b48c170e90f70af998485c1065490726",
  11. "image_id": "",
  12. "important_keywords": "",
  13. "positions": [
  14. ""
  15. ]
  16. }
  17. ],
  18. "doc": {
  19. "chunk_count": 1,
  20. "chunk_method": "naive",
  21. "create_date": "Thu, 24 Oct 2024 09:45:27 GMT",
  22. "create_time": 1729763127646,
  23. "created_by": "69736c5e723611efb51b0242ac120007",
  24. "dataset_id": "527fa74891e811ef9c650242ac120006",
  25. "id": "b330ec2e91ec11efbc510242ac120004",
  26. "location": "1.txt",
  27. "name": "1.txt",
  28. "parser_config": {
  29. "chunk_token_num": 128,
  30. "delimiter": "\\n",
  31. "html4excel": false,
  32. "layout_recognize": true,
  33. "raptor": {
  34. "use_raptor": false
  35. }
  36. },
  37. "process_begin_at": "Thu, 24 Oct 2024 09:56:44 GMT",
  38. "process_duation": 0.54213,
  39. "progress": 0.0,
  40. "progress_msg": "Task dispatched...",
  41. "run": "2",
  42. "size": 17966,
  43. "source_type": "local",
  44. "status": "1",
  45. "thumbnail": "",
  46. "token_count": 8,
  47. "type": "doc",
  48. "update_date": "Thu, 24 Oct 2024 11:03:15 GMT",
  49. "update_time": 1729767795721
  50. },
  51. "total": 1
  52. }
  53. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "You don't own the document 5c5999ec7be811ef9cab0242ac12000e5."
  4. }

Delete chunks

DELETE /api/v1/datasets/{dataset_id}/documents/{document_id}/chunks

Deletes chunks by ID.

Request

Request example
  1. curl --request DELETE \
  2. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '
  6. {
  7. "chunk_ids": ["test_1", "test_2"]
  8. }'
Request parameters

Response

Success:

  1. {
  2. "code": 0
  3. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "`chunk_ids` is required"
  4. }

Update chunk

PUT /api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}

Updates content or configurations for a specified chunk.

Request

Request example
  1. curl --request PUT \
  2. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id} \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '
  6. {
  7. "content": "ragflow123",
  8. "important_keywords": []
  9. }'
Request parameters

Response

Success:

  1. {
  2. "code": 0
  3. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "Can't find this chunk 29a2d9987e16ba331fb4d7d30d99b71d2"
  4. }

Retrieve chunks

POST /api/v1/retrieval

Retrieves chunks from specified datasets.

Request

Request example
  1. curl --request POST \
  2. --url http://{address}/api/v1/retrieval \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '
  6. {
  7. "question": "What is advantage of ragflow?",
  8. "dataset_ids": ["b2a62730759d11ef987d0242ac120004"],
  9. "document_ids": ["77df9ef4759a11ef8bdd0242ac120004"]
  10. }'
Request parameter

Response

Success:

  1. {
  2. "code": 0,
  3. "data": {
  4. "chunks": [
  5. {
  6. "content": "ragflow content",
  7. "content_ltks": "ragflow content",
  8. "document_id": "5c5999ec7be811ef9cab0242ac120005",
  9. "document_keyword": "1.txt",
  10. "highlight": "<em>ragflow</em> content",
  11. "id": "d78435d142bd5cf6704da62c778795c5",
  12. "image_id": "",
  13. "important_keywords": [
  14. ""
  15. ],
  16. "kb_id": "c7ee74067a2c11efb21c0242ac120006",
  17. "positions": [
  18. ""
  19. ],
  20. "similarity": 0.9669436601210759,
  21. "term_similarity": 1.0,
  22. "vector_similarity": 0.8898122004035864
  23. }
  24. ],
  25. "doc_aggs": [
  26. {
  27. "count": 1,
  28. "doc_id": "5c5999ec7be811ef9cab0242ac120005",
  29. "doc_name": "1.txt"
  30. }
  31. ],
  32. "total": 1
  33. }
  34. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "`datasets` is required."
  4. }

CHAT ASSISTANT MANAGEMENT


Create chat assistant

POST /api/v1/chats

Creates a chat assistant.

Request

Request example
  1. curl --request POST \
  2. --url http://{address}/api/v1/chats \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '{
  6. "dataset_ids": ["0b2cbc8c877f11ef89070242ac120005"],
  7. "name":"new_chat_1"
  8. }'
Request parameters

Response

Success:

  1. {
  2. "code": 0,
  3. "data": {
  4. "avatar": "",
  5. "create_date": "Thu, 24 Oct 2024 11:18:29 GMT",
  6. "create_time": 1729768709023,
  7. "dataset_ids": [
  8. "527fa74891e811ef9c650242ac120006"
  9. ],
  10. "description": "A helpful Assistant",
  11. "do_refer": "1",
  12. "id": "b1f2f15691f911ef81180242ac120003",
  13. "language": "English",
  14. "llm": {
  15. "frequency_penalty": 0.7,
  16. "model_name": "qwen-plus@Tongyi-Qianwen",
  17. "presence_penalty": 0.4,
  18. "temperature": 0.1,
  19. "top_p": 0.3
  20. },
  21. "name": "12234",
  22. "prompt": {
  23. "empty_response": "Sorry! No relevant content was found in the knowledge base!",
  24. "keywords_similarity_weight": 0.3,
  25. "opener": "Hi! I'm your assistant, what can I do for you?",
  26. "prompt": "You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence \"The answer you are looking for is not found in the knowledge base!\" Answers need to consider chat history.\n ",
  27. "rerank_model": "",
  28. "similarity_threshold": 0.2,
  29. "top_n": 6,
  30. "variables": [
  31. {
  32. "key": "knowledge",
  33. "optional": false
  34. }
  35. ]
  36. },
  37. "prompt_type": "simple",
  38. "status": "1",
  39. "tenant_id": "69736c5e723611efb51b0242ac120007",
  40. "top_k": 1024,
  41. "update_date": "Thu, 24 Oct 2024 11:18:29 GMT",
  42. "update_time": 1729768709023
  43. }
  44. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "Duplicated chat name in creating dataset."
  4. }

Update chat assistant

PUT /api/v1/chats/{chat_id}

Updates configurations for a specified chat assistant.

Request

Request example
  1. curl --request PUT \
  2. --url http://{address}/api/v1/chats/{chat_id} \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '
  6. {
  7. "name":"Test"
  8. }'

Parameters

Response

Success:

  1. {
  2. "code": 0
  3. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "Duplicated chat name in updating dataset."
  4. }

Delete chat assistants

DELETE /api/v1/chats

Deletes chat assistants by ID.

Request

Request example
  1. curl --request DELETE \
  2. --url http://{address}/api/v1/chats \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '
  6. {
  7. "ids": ["test_1", "test_2"]
  8. }'
Request parameters

Response

Success:

  1. {
  2. "code": 0
  3. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "ids are required"
  4. }

List chat assistants

GET /api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={chat_name}&id={chat_id}

Lists chat assistants.

Request

Request example
  1. curl --request GET \
  2. --url http://{address}/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={chat_name}&id={chat_id} \
  3. --header 'Authorization: Bearer <YOUR_API_KEY>'
Request parameters

Response

Success:

  1. {
  2. "code": 0,
  3. "data": [
  4. {
  5. "avatar": "",
  6. "create_date": "Fri, 18 Oct 2024 06:20:06 GMT",
  7. "create_time": 1729232406637,
  8. "description": "A helpful Assistant",
  9. "do_refer": "1",
  10. "id": "04d0d8e28d1911efa3630242ac120006",
  11. "dataset_ids": ["527fa74891e811ef9c650242ac120006"],
  12. "language": "English",
  13. "llm": {
  14. "frequency_penalty": 0.7,
  15. "model_name": "qwen-plus@Tongyi-Qianwen",
  16. "presence_penalty": 0.4,
  17. "temperature": 0.1,
  18. "top_p": 0.3
  19. },
  20. "name": "13243",
  21. "prompt": {
  22. "empty_response": "Sorry! No relevant content was found in the knowledge base!",
  23. "keywords_similarity_weight": 0.3,
  24. "opener": "Hi! I'm your assistant, what can I do for you?",
  25. "prompt": "You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence \"The answer you are looking for is not found in the knowledge base!\" Answers need to consider chat history.\n",
  26. "rerank_model": "",
  27. "similarity_threshold": 0.2,
  28. "top_n": 6,
  29. "variables": [
  30. {
  31. "key": "knowledge",
  32. "optional": false
  33. }
  34. ]
  35. },
  36. "prompt_type": "simple",
  37. "status": "1",
  38. "tenant_id": "69736c5e723611efb51b0242ac120007",
  39. "top_k": 1024,
  40. "update_date": "Fri, 18 Oct 2024 06:20:06 GMT",
  41. "update_time": 1729232406638
  42. }
  43. ]
  44. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "The chat doesn't exist"
  4. }

SESSION MANAGEMENT


Create session with chat assistant

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

Creates a session with a chat assistant.

Request

Request example
  1. curl --request POST \
  2. --url http://{address}/api/v1/chats/{chat_id}/sessions \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '
  6. {
  7. "name": "new session"
  8. }'
Request parameters

Response

Success:

  1. {
  2. "code": 0,
  3. "data": {
  4. "chat_id": "2ca4b22e878011ef88fe0242ac120005",
  5. "create_date": "Fri, 11 Oct 2024 08:46:14 GMT",
  6. "create_time": 1728636374571,
  7. "id": "4606b4ec87ad11efbc4f0242ac120006",
  8. "messages": [
  9. {
  10. "content": "Hi! I am your assistant,can I help you?",
  11. "role": "assistant"
  12. }
  13. ],
  14. "name": "new session",
  15. "update_date": "Fri, 11 Oct 2024 08:46:14 GMT",
  16. "update_time": 1728636374571
  17. }
  18. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "Name cannot be empty."
  4. }

Update chat assistant's session

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

Updates a session of a specified chat assistant.

Request

Request example
  1. curl --request PUT \
  2. --url http://{address}/api/v1/chats/{chat_id}/sessions/{session_id} \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '
  6. {
  7. "name": "<REVISED_SESSION_NAME_HERE>"
  8. }'
Request Parameter

Response

Success:

  1. {
  2. "code": 0
  3. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "Name cannot be empty."
  4. }

List chat assistant's sessions

GET /api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}

Lists sessions associated with a specified chat assistant.

Request

Request example
  1. curl --request GET \
  2. --url http://{address}/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id} \
  3. --header 'Authorization: Bearer <YOUR_API_KEY>'
Request Parameters

Response

Success:

  1. {
  2. "code": 0,
  3. "data": [
  4. {
  5. "chat": "2ca4b22e878011ef88fe0242ac120005",
  6. "create_date": "Fri, 11 Oct 2024 08:46:43 GMT",
  7. "create_time": 1728636403974,
  8. "id": "578d541e87ad11ef96b90242ac120006",
  9. "messages": [
  10. {
  11. "content": "Hi! I am your assistant,can I help you?",
  12. "role": "assistant"
  13. }
  14. ],
  15. "name": "new session",
  16. "update_date": "Fri, 11 Oct 2024 08:46:43 GMT",
  17. "update_time": 1728636403974
  18. }
  19. ]
  20. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "The session doesn't exist"
  4. }

Delete chat assistant's sessions

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

Deletes sessions of a chat assistant by ID.

Request

Request example
  1. curl --request DELETE \
  2. --url http://{address}/api/v1/chats/{chat_id}/sessions \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '
  6. {
  7. "ids": ["test_1", "test_2"]
  8. }'
Request Parameters

Response

Success:

  1. {
  2. "code": 0
  3. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "The chat doesn't own the session"
  4. }

Converse with chat assistant

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

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

:::tip NOTE

:::

Request

Request example
  1. curl --request POST \
  2. --url http://{address}/api/v1/chats/{chat_id}/completions \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data-binary '
  6. {
  7. }'
  1. curl --request POST \
  2. --url http://{address}/api/v1/chats/{chat_id}/completions \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data-binary '
  6. {
  7. "question": "Who are you",
  8. "stream": true,
  9. "session_id":"9fa7691cb85c11ef9c5f0242ac120005"
  10. }'
Request Parameters

Response

Success without session_id:

  1. data:{
  2. "code": 0,
  3. "message": "",
  4. "data": {
  5. "answer": "Hi! I'm your assistant, what can I do for you?",
  6. "reference": {},
  7. "audio_binary": null,
  8. "id": null,
  9. "session_id": "b01eed84b85611efa0e90242ac120005"
  10. }
  11. }
  12. data:{
  13. "code": 0,
  14. "message": "",
  15. "data": true
  16. }

Success with session_id:

  1. data:{
  2. "code": 0,
  3. "data": {
  4. "answer": "I am an intelligent assistant designed to help answer questions by summarizing content from a",
  5. "reference": {},
  6. "audio_binary": null,
  7. "id": "a84c5dd4-97b4-4624-8c3b-974012c8000d",
  8. "session_id": "82b0ab2a9c1911ef9d870242ac120006"
  9. }
  10. }
  11. data:{
  12. "code": 0,
  13. "data": {
  14. "answer": "I am an intelligent assistant designed to help answer questions by summarizing content from a knowledge base. My responses are based on the information available in the knowledge base and",
  15. "reference": {},
  16. "audio_binary": null,
  17. "id": "a84c5dd4-97b4-4624-8c3b-974012c8000d",
  18. "session_id": "82b0ab2a9c1911ef9d870242ac120006"
  19. }
  20. }
  21. data:{
  22. "code": 0,
  23. "data": {
  24. "answer": "I am an intelligent assistant designed to help answer questions by summarizing content from a knowledge base. My responses are based on the information available in the knowledge base and any relevant chat history.",
  25. "reference": {},
  26. "audio_binary": null,
  27. "id": "a84c5dd4-97b4-4624-8c3b-974012c8000d",
  28. "session_id": "82b0ab2a9c1911ef9d870242ac120006"
  29. }
  30. }
  31. data:{
  32. "code": 0,
  33. "data": {
  34. "answer": "I am an intelligent assistant designed to help answer questions by summarizing content from a knowledge base ##0$$. My responses are based on the information available in the knowledge base and any relevant chat history.",
  35. "reference": {
  36. "total": 1,
  37. "chunks": [
  38. {
  39. "id": "faf26c791128f2d5e821f822671063bd",
  40. "content": "xxxxxxxx",
  41. "document_id": "dd58f58e888511ef89c90242ac120006",
  42. "document_name": "1.txt",
  43. "dataset_id": "8e83e57a884611ef9d760242ac120006",
  44. "image_id": "",
  45. "similarity": 0.7,
  46. "vector_similarity": 0.0,
  47. "term_similarity": 1.0,
  48. "positions": [
  49. ""
  50. ]
  51. }
  52. ],
  53. "doc_aggs": [
  54. {
  55. "doc_name": "1.txt",
  56. "doc_id": "dd58f58e888511ef89c90242ac120006",
  57. "count": 1
  58. }
  59. ]
  60. },
  61. "prompt": "xxxxxxxxxxx",
  62. "id": "a84c5dd4-97b4-4624-8c3b-974012c8000d",
  63. "session_id": "82b0ab2a9c1911ef9d870242ac120006"
  64. }
  65. }
  66. data:{
  67. "code": 0,
  68. "data": true
  69. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "Please input your question."
  4. }

Create session with agent

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

Creates a session with an agent.

Request

Request example

If the Begin component in your agent does not take required parameters:

  1. curl --request POST \
  2. --url http://{address}/api/v1/agents/{agent_id}/sessions \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '{
  6. }'

If the Begin component in your agent takes required parameters:

  1. curl --request POST \
  2. --url http://{address}/api/v1/agents/{agent_id}/sessions \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '{
  6. "lang":"Japanese",
  7. "file":"Who are you"
  8. }'

If the Begin component in your agent takes required file parameters:

  1. curl --request POST \
  2. --url http://{address}/api/v1/agents/{agent_id}/sessions?user_id={user_id} \
  3. --header 'Content-Type: multipart/form-data' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --form '<FILE_KEY>=@./test1.png'
Request parameters

Response

Success:

  1. {
  2. "code": 0,
  3. "data": {
  4. "agent_id": "b4a39922b76611efaa1a0242ac120006",
  5. "dsl": {
  6. "answer": [],
  7. "components": {
  8. "Answer:GreenReadersDrum": {
  9. "downstream": [],
  10. "obj": {
  11. "component_name": "Answer",
  12. "inputs": [],
  13. "output": null,
  14. "params": {}
  15. },
  16. "upstream": []
  17. },
  18. "begin": {
  19. "downstream": [],
  20. "obj": {
  21. "component_name": "Begin",
  22. "inputs": [],
  23. "output": {},
  24. "params": {}
  25. },
  26. "upstream": []
  27. }
  28. },
  29. "embed_id": "",
  30. "graph": {
  31. "edges": [],
  32. "nodes": [
  33. {
  34. "data": {
  35. "label": "Begin",
  36. "name": "begin"
  37. },
  38. "dragging": false,
  39. "height": 44,
  40. "id": "begin",
  41. "position": {
  42. "x": 53.25688640427177,
  43. "y": 198.37155679786412
  44. },
  45. "positionAbsolute": {
  46. "x": 53.25688640427177,
  47. "y": 198.37155679786412
  48. },
  49. "selected": false,
  50. "sourcePosition": "left",
  51. "targetPosition": "right",
  52. "type": "beginNode",
  53. "width": 200
  54. },
  55. {
  56. "data": {
  57. "form": {},
  58. "label": "Answer",
  59. "name": "dialog_0"
  60. },
  61. "dragging": false,
  62. "height": 44,
  63. "id": "Answer:GreenReadersDrum",
  64. "position": {
  65. "x": 360.43473114516974,
  66. "y": 207.29298425089348
  67. },
  68. "positionAbsolute": {
  69. "x": 360.43473114516974,
  70. "y": 207.29298425089348
  71. },
  72. "selected": false,
  73. "sourcePosition": "right",
  74. "targetPosition": "left",
  75. "type": "logicNode",
  76. "width": 200
  77. }
  78. ]
  79. },
  80. "history": [],
  81. "messages": [],
  82. "path": [
  83. [
  84. "begin"
  85. ],
  86. []
  87. ],
  88. "reference": []
  89. },
  90. "id": "2581031eb7a311efb5200242ac120005",
  91. "message": [
  92. {
  93. "content": "Hi! I'm your smart assistant. What can I do for you?",
  94. "role": "assistant"
  95. }
  96. ],
  97. "source": "agent",
  98. "user_id": "69736c5e723611efb51b0242ac120007"
  99. }
  100. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "Agent not found."
  4. }

Converse with agent

POST /api/v1/agents/{agent_id}/completions

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

:::tip NOTE

:::

Request

:::info IMPORTANT
You can include custom parameters in the request body, but first ensure they are defined in the Begin agent component.
:::

Request example
  1. curl --request POST \
  2. --url http://{address}/api/v1/agents/{agent_id}/completions \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data-binary '
  6. {
  7. }'
  1. curl --request POST \
  2. --url http://{address}/api/v1/agents/{agent_id}/completions \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data-binary '
  6. {
  7. "lang":"English",
  8. "file":"How is the weather tomorrow?"
  9. }'

The following code will execute the completion process

  1. curl --request POST \
  2. --url http://{address}/api/v1/agents/{agent_id}/completions \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data-binary '
  6. {
  7. "question": "Hello",
  8. "stream": true,
  9. "session_id": "cb2f385cb86211efa36e0242ac120005"
  10. }'
Request Parameters

Response

success without session_id provided and with no parameters specified in the Begin component:

  1. data:{
  2. "code": 0,
  3. "message": "",
  4. "data": {
  5. "answer": "Hi! I'm your smart assistant. What can I do for you?",
  6. "reference": {},
  7. "id": "31e6091d-88d4-441b-ac65-eae1c055be7b",
  8. "session_id": "2987ad3eb85f11efb2a70242ac120005"
  9. }
  10. }
  11. data:{
  12. "code": 0,
  13. "message": "",
  14. "data": true
  15. }

Success without session_id provided and with parameters specified in the Begin component:

  1. data:{
  2. "code": 0,
  3. "message": "",
  4. "data": {
  5. "session_id": "eacb36a0bdff11ef97120242ac120006",
  6. "answer": "",
  7. "reference": [],
  8. "param": [
  9. {
  10. "key": "lang",
  11. "name": "Target Language",
  12. "optional": false,
  13. "type": "line",
  14. "value": "English"
  15. },
  16. {
  17. "key": "file",
  18. "name": "Files",
  19. "optional": false,
  20. "type": "file",
  21. "value": "How is the weather tomorrow?"
  22. },
  23. {
  24. "key": "hhyt",
  25. "name": "hhty",
  26. "optional": true,
  27. "type": "line"
  28. }
  29. ]
  30. }
  31. }
  32. data:

Success with parameters specified in the Begin component:

  1. data:{
  2. "code": 0,
  3. "message": "",
  4. "data": {
  5. "answer": "How",
  6. "reference": {},
  7. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  8. "session_id": "4399c7d0b86311efac5b0242ac120005"
  9. }
  10. }
  11. data:{
  12. "code": 0,
  13. "message": "",
  14. "data": {
  15. "answer": "How is",
  16. "reference": {},
  17. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  18. "session_id": "4399c7d0b86311efac5b0242ac120005"
  19. }
  20. }
  21. data:{
  22. "code": 0,
  23. "message": "",
  24. "data": {
  25. "answer": "How is the",
  26. "reference": {},
  27. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  28. "session_id": "4399c7d0b86311efac5b0242ac120005"
  29. }
  30. }
  31. data:{
  32. "code": 0,
  33. "message": "",
  34. "data": {
  35. "answer": "How is the weather",
  36. "reference": {},
  37. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  38. "session_id": "4399c7d0b86311efac5b0242ac120005"
  39. }
  40. }
  41. data:{
  42. "code": 0,
  43. "message": "",
  44. "data": {
  45. "answer": "How is the weather tomorrow",
  46. "reference": {},
  47. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  48. "session_id": "4399c7d0b86311efac5b0242ac120005"
  49. }
  50. }
  51. data:{
  52. "code": 0,
  53. "message": "",
  54. "data": {
  55. "answer": "How is the weather tomorrow?",
  56. "reference": {},
  57. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  58. "session_id": "4399c7d0b86311efac5b0242ac120005"
  59. }
  60. }
  61. data:{
  62. "code": 0,
  63. "message": "",
  64. "data": {
  65. "answer": "How is the weather tomorrow?",
  66. "reference": {},
  67. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  68. "session_id": "4399c7d0b86311efac5b0242ac120005"
  69. }
  70. }
  71. data:{
  72. "code": 0,
  73. "message": "",
  74. "data": true
  75. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "`question` is required."
  4. }

List agent sessions

GET /api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id}&user_id={user_id}&dsl={dsl}

Lists sessions associated with a specified agent.

Request

Request example
  1. curl --request GET \
  2. --url http://{address}/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id}&user_id={user_id} \
  3. --header 'Authorization: Bearer <YOUR_API_KEY>'
Request Parameters

Response

Success:

  1. {
  2. "code": 0,
  3. "data": [{
  4. "agent_id": "e9e2b9c2b2f911ef801d0242ac120006",
  5. "dsl": {
  6. "answer": [],
  7. "components": {
  8. "Answer:OrangeTermsBurn": {
  9. "downstream": [],
  10. "obj": {
  11. "component_name": "Answer",
  12. "params": {}
  13. },
  14. "upstream": []
  15. },
  16. "Generate:SocialYearsRemain": {
  17. "downstream": [],
  18. "obj": {
  19. "component_name": "Generate",
  20. "params": {
  21. "cite": true,
  22. "frequency_penalty": 0.7,
  23. "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible",
  24. "message_history_window_size": 12,
  25. "parameters": [],
  26. "presence_penalty": 0.4,
  27. "prompt": "Please summarize the following paragraph. Pay attention to the numbers and do not make things up. The paragraph is as follows:\n{input}\nThis is what you need to summarize.",
  28. "temperature": 0.1,
  29. "top_p": 0.3
  30. }
  31. },
  32. "upstream": []
  33. },
  34. "begin": {
  35. "downstream": [],
  36. "obj": {
  37. "component_name": "Begin",
  38. "params": {}
  39. },
  40. "upstream": []
  41. }
  42. },
  43. "graph": {
  44. "edges": [],
  45. "nodes": [
  46. {
  47. "data": {
  48. "label": "Begin",
  49. "name": "begin"
  50. },
  51. "height": 44,
  52. "id": "begin",
  53. "position": {
  54. "x": 50,
  55. "y": 200
  56. },
  57. "sourcePosition": "left",
  58. "targetPosition": "right",
  59. "type": "beginNode",
  60. "width": 200
  61. },
  62. {
  63. "data": {
  64. "form": {
  65. "cite": true,
  66. "frequencyPenaltyEnabled": true,
  67. "frequency_penalty": 0.7,
  68. "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible",
  69. "maxTokensEnabled": true,
  70. "message_history_window_size": 12,
  71. "parameters": [],
  72. "presencePenaltyEnabled": true,
  73. "presence_penalty": 0.4,
  74. "prompt": "Please summarize the following paragraph. Pay attention to the numbers and do not make things up. The paragraph is as follows:\n{input}\nThis is what you need to summarize.",
  75. "temperature": 0.1,
  76. "temperatureEnabled": true,
  77. "topPEnabled": true,
  78. "top_p": 0.3
  79. },
  80. "label": "Generate",
  81. "name": "Generate Answer_0"
  82. },
  83. "dragging": false,
  84. "height": 105,
  85. "id": "Generate:SocialYearsRemain",
  86. "position": {
  87. "x": 561.3457829707513,
  88. "y": 178.7211182312641
  89. },
  90. "positionAbsolute": {
  91. "x": 561.3457829707513,
  92. "y": 178.7211182312641
  93. },
  94. "selected": true,
  95. "sourcePosition": "right",
  96. "targetPosition": "left",
  97. "type": "generateNode",
  98. "width": 200
  99. },
  100. {
  101. "data": {
  102. "form": {},
  103. "label": "Answer",
  104. "name": "Dialogue_0"
  105. },
  106. "height": 44,
  107. "id": "Answer:OrangeTermsBurn",
  108. "position": {
  109. "x": 317.2368194777658,
  110. "y": 218.30635555445093
  111. },
  112. "sourcePosition": "right",
  113. "targetPosition": "left",
  114. "type": "logicNode",
  115. "width": 200
  116. }
  117. ]
  118. },
  119. "history": [],
  120. "messages": [],
  121. "path": [],
  122. "reference": []
  123. },
  124. "id": "792dde22b2fa11ef97550242ac120006",
  125. "message": [
  126. {
  127. "content": "Hi! I'm your smart assistant. What can I do for you?",
  128. "role": "assistant"
  129. }
  130. ],
  131. "source": "agent",
  132. "user_id": ""
  133. }]
  134. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "You don't own the agent ccd2f856b12311ef94ca0242ac1200052."
  4. }

Delete agent's sessions

DELETE /api/v1/agents/{agent_id}/sessions

Deletes sessions of a agent by ID.

Request

Request example
  1. curl --request DELETE \
  2. --url http://{address}/api/v1/agents/{agent_id}/sessions \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '
  6. {
  7. "ids": ["test_1", "test_2"]
  8. }'
Request Parameters

Response

Success:

  1. {
  2. "code": 0
  3. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "The agent doesn't own the session cbd31e52f73911ef93b232903b842af6"
  4. }

POST /v1/conversation/related_questions

Generates five to ten alternative question strings from the user's original query to retrieve more relevant search results.

This operation requires a Bearer Login Token, typically expires with in 24 hours. You can find the it in the browser request easily.

:::tip NOTE
The chat model dynamically determines the number of questions to generate based on the instruction, typically between five and ten.
:::

Request

Request example
  1. curl --request POST \
  2. --url http://{address}/v1/conversation/related_questions \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_LOGIN_TOKEN>' \
  5. --data '
  6. {
  7. "question": "What are the key advantages of Neovim over Vim?"
  8. }'
Request Parameters

Response

Success:

  1. {
  2. "code": 0,
  3. "data": [
  4. "What makes Neovim superior to Vim in terms of features?",
  5. "How do the benefits of Neovim compare to those of Vim?",
  6. "What advantages does Neovim offer that are not present in Vim?",
  7. "In what ways does Neovim outperform Vim in functionality?",
  8. "What are the most significant improvements in Neovim compared to Vim?",
  9. "What unique advantages does Neovim bring to the table over Vim?",
  10. "How does the user experience in Neovim differ from Vim in terms of benefits?",
  11. "What are the top reasons to switch from Vim to Neovim?",
  12. "What features of Neovim are considered more advanced than those in Vim?"
  13. ],
  14. "message": "success"
  15. }

Failure:

  1. {
  2. "code": 401,
  3. "data": null,
  4. "message": "<Unauthorized '401: Unauthorized'>"
  5. }

AGENT MANAGEMENT


List agents

GET /api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id}

Lists agents.

Request

Request example
  1. curl --request GET \
  2. --url http://{address}/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id} \
  3. --header 'Authorization: Bearer <YOUR_API_KEY>'
Request parameters

Response

Success:

  1. {
  2. "code": 0,
  3. "data": [
  4. {
  5. "avatar": null,
  6. "canvas_type": null,
  7. "create_date": "Thu, 05 Dec 2024 19:10:36 GMT",
  8. "create_time": 1733397036424,
  9. "description": null,
  10. "dsl": {
  11. "answer": [],
  12. "components": {
  13. "begin": {
  14. "downstream": [],
  15. "obj": {
  16. "component_name": "Begin",
  17. "params": {}
  18. },
  19. "upstream": []
  20. }
  21. },
  22. "graph": {
  23. "edges": [],
  24. "nodes": [
  25. {
  26. "data": {
  27. "label": "Begin",
  28. "name": "begin"
  29. },
  30. "height": 44,
  31. "id": "begin",
  32. "position": {
  33. "x": 50,
  34. "y": 200
  35. },
  36. "sourcePosition": "left",
  37. "targetPosition": "right",
  38. "type": "beginNode",
  39. "width": 200
  40. }
  41. ]
  42. },
  43. "history": [],
  44. "messages": [],
  45. "path": [],
  46. "reference": []
  47. },
  48. "id": "8d9ca0e2b2f911ef9ca20242ac120006",
  49. "title": "123465",
  50. "update_date": "Thu, 05 Dec 2024 19:10:56 GMT",
  51. "update_time": 1733397056801,
  52. "user_id": "69736c5e723611efb51b0242ac120007"
  53. }
  54. ]
  55. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "The agent doesn't exist."
  4. }

Create agent

POST /api/v1/agents

Create an agent.

Request

Request example
  1. curl --request POST \
  2. --url http://{address}/api/v1/agents \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '{
  6. "title": "Test Agent",
  7. "description": "A test agent",
  8. "dsl": {
  9. // ... Canvas DSL here ...
  10. }
  11. }'
Request parameters

Response

Success:

  1. {
  2. "code": 0,
  3. "data": true,
  4. "message": "success"
  5. }

Failure:

  1. {
  2. "code": 102,
  3. "message": "Agent with title test already exists."
  4. }

Update agent

PUT /api/v1/agents/{agent_id}

Update an agent by id.

Request

Request example
  1. curl --request PUT \
  2. --url http://{address}/api/v1/agents/58af890a2a8911f0a71a11b922ed82d6 \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '{
  6. "title": "Test Agent",
  7. "description": "A test agent",
  8. "dsl": {
  9. // ... Canvas DSL here ...
  10. }
  11. }'
Request parameters

Only specify the parameter you want to change in the request body. If a parameter does not exist or is None, it won't be updated.

Response

Success:

  1. {
  2. "code": 0,
  3. "data": true,
  4. "message": "success"
  5. }

Failure:

  1. {
  2. "code": 103,
  3. "message": "Only owner of canvas authorized for this operation."
  4. }

Delete agent

DELETE /api/v1/agents/{agent_id}

Delete an agent by id.

Request

Request example
  1. curl --request DELETE \
  2. --url http://{address}/api/v1/agents/58af890a2a8911f0a71a11b922ed82d6 \
  3. --header 'Content-Type: application/json' \
  4. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  5. --data '{}'
Request parameters

Response

Success:

  1. {
  2. "code": 0,
  3. "data": true,
  4. "message": "success"
  5. }

Failure:

  1. {
  2. "code": 103,
  3. "message": "Only owner of canvas authorized for this operation."
  4. }

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注