2.9-Knowledge Retrieval

1. Overview

  • Interface Name: Knowledge Retrieval Interface

  • Version number: v1.0.0

2. Information

  • Request method: POST

  • Request URL: https://DOMAIN/openapi/v1/knowledge/search/

  • Domain: Refer to "Service address description"

3. Request parameters

Request header http header field:

Parameter name
Type
Required
Description

Content-Type

string

Yes

Fixedapplication/json

cybertron-robot-key

string

Yes

Robot key

cybertron-robot-token

string

Yes

Robot token

Request body field:

Parameter name
Type
Required
Description

username

string

Yes

User account

question

string

Yes

Knowledge question

knowledge_base_id

int

Yes

Knowledge Base id

is_selected

bool

No

Whether to return only the recall result (not required), default false, returns all the query results, and only the recall result that meets the conditions when true is passed

4. Response field description

HTTP status code: 200 OK

Response field description:

Field Name
Type
Description

code

string

"000000" is normal, other exceptions

message

string

Status description

data

object

message body

knowledge_content

array

RAG retrieves knowledge related to questions asked by users

function_call

array

plugin function call information related to user question question retrieved by RAG

5. Example

Request Example:

curl 'https://_DOMAIN_/openapi/v1/knowledge/search/' \
-H 'Content-Type: application/json' \
-H 'cybertron-robot-key: l8ia2IOc************Z724%2BU%3D' \
-H 'cybertron-robot-token: MTc0Mzk5************************************************cGRCUTg9' \
-X POST -d '{
    "username": "me@host.com",
    "question": "Doudou Money",
    "knowledge_base_id": 544,
    "is_selected": true
}'

Response example:

{
    "code": "000000",
    "message": "query knowledge base success.",
    "data": {
        "knowledge_content": [
            {
                "Answer": "You will know if you look up at the sky",
                "combine_query": "What weather is today",
                "from": "milvus",
                "id": "9682",
                "prob": 0.8948,
                "question": "What weather is today",
                "type": "qa"
            }
        ],
        "function_call": [
            {
                "combine_query": "Query the weather forecast information of a certain location",
                "description": "Query weather forecast information in a certain location",
                "from": "es",
                "id": "200",
                "name": "query_weather",
                "prob": 0.5758
            }
        ]
    }
}