Generating skill set answers
    • PDF

    Generating skill set answers

    • PDF

    Article Summary

    Available in Classic and VPC

    API for a specific skill set is called to generate the appropriate answer.

    Requests

    Describes the request format. The request format is as follows:

    MethodURI
    POST/v1/skillsets/{skillset-id}/versions/{version}/final-answer

    Header

    The following describes the header.

    HeaderRequiredDescription
    X-NCP-CLOVASTUDIO-API-KEYYAPI key issued when creating a test app or service app
    X-NCP-APIGW-API-KEYYAPI Gateway key issued when creating a test app or service app
    X-NCP-CLOVASTUDIO-REQUEST-IDNRequest ID for each request
    Content-TypeYapplication/json

    Path parameters

    The following describes the parameters.

    FieldTypeRequiredDescription
    skillset-idstringYSkill set ID to generate answers for
    versionintegerYThe version of the skill set to generate answers for (integer: >= 1)

    Body

    The following describes each field in the request body.

    FieldTypeRequiredDescription
    querystringYQuery content
    tokenStreambooleanNWhether to use token streaming for generating responses
    chatHistoryarrayNResponse generation history
    chatHistory.roleenumYRole of the conversation message
  • user: user's speech/question
  • assistant: response to the user's speech/question
  • chatHistory.contentstringYContent of the conversation message

    Syntax

    Examples of syntax are as follows:

    curl --location --request POST 'https://clovastudio.stream.ntruss.com/testapp/v1/skillsets/{skillset-id}/versions/{version}/final-answer' \
    --header 'X-NCP-CLOVASTUDIO-API-KEY: <X-NCP-CLOVASTUDIO-API-KEY>' \
    --header 'X-NCP-APIGW-API-KEY: <X-NCP-APIGW-API-KEY>' \
    --header 'X-NCP-CLOVASTUDIO-REQUEST-ID: <X-NCP-CLOVASTUDIO-REQUEST-ID>' \
    --header 'Content-Type: application/json'
    --data '{  
        "query": "What will the weather be like in Seoul tomorrow?",
        "tokenStream": true
        "chatHistory": [
                                    {
                                        "role": "user",
                                        "content": "How's the weather today?"
                                     },
                                    {
                                        "role": "assistant",
                                        "content": "It's the calm before the storm."
                                     }
                                 ]
        }'
    

    Responses

    Describes the responses format.

    Header

    The following describes the header.

    HeaderRequiredDescription
    Content-Type-application/json

    Body

    The following describes each field in the body.

    FieldTypeRequiredDescription
    result--Response result
    result.finalAnswerstringYThe last run result of the model (if not run to the end, returns an empty string)
    result.tokenCountintegerYThe number of tokens measured when generating the answer
    result.apiResultarray-The result of the called API
    result.apiResult.urlstring-API URL called during the response process
    result.apiResult.requestBodystring-API request body called during the response process
    result.apiResult.responseBodystring-API response bodies called during the response process
    result.apiResult.apiOrderstring-A sorting criterion value to fix the response order, regardless of the API call results. When registering a skill in the skill trainer, defining x-api-order: {number value} in the Operation Id of the API Spec ensures the results are delivered as defined by apiOrder: {number value}. This is used when a fixed order value is desired on the UI.
    result.apiResult.operationIdstring-The Operation Id of the API Spec called during the response process
    result.apiResult.nameForHumanstring-nameForHuman of the skill for which the API called during the response process is registered

    Syntax

    Examples of syntax are as follows:

    {
      "status": {
        "code": "20000",
        "message": "OK"
      },
      "result": {
        "finalAnswer": "The weather in Seoul tomorrow is expected to be clear, with temperatures around 27 degrees Celsius.",
        "tokenCount": 1032,
        "apiResult": [
          {
            "url": "http://api.kcisa.kr/openapi/service/rest/convergence/conver8?serviceKey=247c5de7-556d-41bf-af3e-875e039e4f5c&numOfRows=1&keyword=Pangyo",
            "requestBody": "string",
            "responseBody": "string",
            "apiOrder": 1,
            "operationId": "searchHotel",
            "nameForHuman": "V1ReviewSearch"
          }
        ]
      }
    }
    

    Response stream

    You can use response streaming to display each event one by one. It describes the response streaming format.

    Header

    The following describes the header.

    HeaderRequiredDescription
    accept-text/event-stream

    Body

    The following describes each field in the body.

    FieldTypeRequiredDescription
    selectedSkillarray-The name of the selected skill (name for model). Displayed only in the planning event
    finalAnswerstring-Last run result of the model. An empty string if it was not executed until the end. Displayed only in the finalAnswer event
    tokenCountinteger-The number of tokens used in the event
    useTaskboolean-Whether the called model is trained
    apiResultarray-The result of the called API
    apiResult.urlstring-API URL called during the response process
    apiResult.requestBodystring-API request body called during the response process
    apiResult.responseBodystring-API response bodies called during the response process
    apiResult.apiOrderstring-A sorting criterion value to fix the response order, regardless of the API call results. When registering a skill in the skill trainer, defining x-api-order: {number value} in the Operation Id of the API Spec ensures the results are delivered as defined by apiOrder: {number value}. This is used when a fixed order value is desired on the UI.
    apiResult.operationIdstring-The Operation Id of the API Spec called during the response process
    apiResult.nameForHumanstring-nameForHuman of the skill for which the API called during the response process is registered

    Token Event

    When using token streaming, the description for Token Data is as follows:

    FieldTypeRequiredDescription
    idinteger-Identifier for the request
    indexinteger-Batch index to which the generated token belongs
    probsfloat-Probability value for each generated token
    stop_reasonstring-Reason for token generation being stopped
    textstring-Complete text pair

    Syntax

    Examples of syntax are as follows:

    {
        "status": {
            "code": "20000",
            "message": "OK"
        },
        "result": {
            "finalAnswer": "I will recommend hotels in Seoul.\n\n1. Luxury Hotel(4.0) - 13-1, Jeil-dong, Jungnang-gu, Seoul\n2. Grand Resort(5.0) - 12-1, Munan-dong, Jung-gu, Seoul\n3. Movenpick Hotel(4.0) - 120, Walkerhill-ro, Gwangjin-gu, Seoul",
            "apiResult": [
                {
                    "url": "https://free-api-0601.herokuapp.com/search_reviews_get?address=Seoul",
                    "requestBody": "address=Seoul",
                    "responseBody": "{\"hotels\": [{\"review_id\": 1, \"review_date\": \"20230811\", \"reviewer\": \"JohnDoe\", \"rating\": 4.0, \"content\": \"The hotel was good but had a strange smell.\", \"hotel_name\": \"Luxury Hotel\", \"address\": \"13-1, Jeil-dong, Jungnang-gu, Seoul\", \"room_name\": \"Deluxe Suite\", \"good_cnt\": 10, \"bad_cnt\": 2, \"rating_service\": 5.0, \"rating_clean\": 4.0, \"rating_room\": 4.0}, {\"review_id\": 2, \"review_date\": \"20230810\", \"reviewer\": \"JaneSmith\", \"rating\": 5.0, \"content\": \"There was no coffee pot in the room, and no place nearby to buy coffee. Other than that, everything was satisfactory.\", \"hotel_name\": \"Grand Resort\", \"address\": \"12-1, Munan-dong, Jung-gu, Seoul\", \"room_name\": \"Ocean View Room\", \"good_cnt\": 15, \"bad_cnt\": 0, \"rating_service\": 5.0, \"rating_clean\": 5.0, \"rating_room\": 5.0}, {\"review_id\": 5, \"review_date\": \"20230809\", \"reviewer\": \"ClaudeCalder\", \"rating\": 4.0, \"content\": \"It was disappointing that there were no facilities like a sauna or pool, but the affordable price was good. There is a subway station and a convenience store nearby, so accessibility is good. It's perfect for a short stay.\", \"hotel_name\": \"Movenpick Hotel\", \"address\": \"120 Walkerhill-ro, Gwangjin-gu, Seoul\", \"room_name\": \"City View\", \"good_cnt\": 9, \"bad_cnt\": 0, \"rating_service\": 3.0, \"rating_clean\": 4.0, \"rating_room\": 4.0}], \"test\": \"test\"}",
                    "operationId": "searchHotel",
                    "nameForHuman": "V1ReviewSearch",
                    "apiOrder": 1
                }
            ],
            "useTask": false,
            "tokenCount": 3524
        }
    }
    
    
    Note

    Before the addition of the version control feature, the URI for the skill set answer generation API was /v1/skillsets/{skillset-id}/final-answer. If you intend to use this API, please refer to the above text for the necessary headers, path parameters, and body for the request.


    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.