- Print
- PDF
Generating skill set answers
- Print
- PDF
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:
Method | URI |
---|---|
POST | /v1/skillsets/{skillset-id}/versions/{version}/final-answer |
Header
The following describes the header.
Header | Required | Description |
---|---|---|
X-NCP-CLOVASTUDIO-API-KEY | Y | API key issued when creating a test app or service app |
X-NCP-APIGW-API-KEY | Y | API Gateway key issued when creating a test app or service app |
X-NCP-CLOVASTUDIO-REQUEST-ID | N | Request ID for each request |
Content-Type | Y | application/json |
Path parameters
The following describes the parameters.
Field | Type | Required | Description |
---|---|---|---|
skillset-id | string | Y | Skill set ID to generate answers for |
version | integer | Y | The version of the skill set to generate answers for (integer: >= 1) |
Body
The following describes each field in the request body.
Field | Type | Required | Description |
---|---|---|---|
query | string | Y | Query content |
tokenStream | boolean | N | Whether to use token streaming for generating responses |
chatHistory | array | N | Response generation history |
chatHistory.role | enum | Y | Role of the conversation message |
chatHistory.content | string | Y | Content 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.
Header | Required | Description |
---|---|---|
Content-Type | - | application/json |
Body
The following describes each field in the body.
Field | Type | Required | Description |
---|---|---|---|
result | - | - | Response result |
result.finalAnswer | string | Y | The last run result of the model (if not run to the end, returns an empty string) |
result.tokenCount | integer | Y | The number of tokens measured when generating the answer |
result.apiResult | array | - | The result of the called API |
result.apiResult.url | string | - | API URL called during the response process |
result.apiResult.requestBody | string | - | API request body called during the response process |
result.apiResult.responseBody | string | - | API response bodies called during the response process |
result.apiResult.apiOrder | string | - | 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.operationId | string | - | The Operation Id of the API Spec called during the response process |
result.apiResult.nameForHuman | string | - | 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.
Header | Required | Description |
---|---|---|
accept | - | text/event-stream |
Body
The following describes each field in the body.
Field | Type | Required | Description |
---|---|---|---|
selectedSkill | array | - | The name of the selected skill (name for model). Displayed only in the planning event |
finalAnswer | string | - | Last run result of the model. An empty string if it was not executed until the end. Displayed only in the finalAnswer event |
tokenCount | integer | - | The number of tokens used in the event |
useTask | boolean | - | Whether the called model is trained |
apiResult | array | - | The result of the called API |
apiResult.url | string | - | API URL called during the response process |
apiResult.requestBody | string | - | API request body called during the response process |
apiResult.responseBody | string | - | API response bodies called during the response process |
apiResult.apiOrder | string | - | 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.operationId | string | - | The Operation Id of the API Spec called during the response process |
apiResult.nameForHuman | string | - | 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:
Field | Type | Required | Description |
---|---|---|---|
id | integer | - | Identifier for the request |
index | integer | - | Batch index to which the generated token belongs |
probs | float | - | Probability value for each generated token |
stop_reason | string | - | Reason for token generation being stopped |
text | string | - | 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
}
}
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.