

# 도구 결과 반환
<a name="tool-use-results"></a>

애플리케이션에서 도구를 간접적으로 호출한 후 마지막 단계는 모델에 도구 결과를 제공하는 것입니다. 이는 도구 직접 호출의 ID와 응답 콘텐츠가 포함된 도구 결과를 반환하는 방식으로 이루어집니다. 이 콘텐츠는 [ToolResultBlock](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ToolResultBlock.html) 스키마를 따릅니다.

```
{
    "toolResult": {
        "toolUseId": tool['toolUseId'],
        "content": [{"json": {"song": song, "artist": artist}}],
        "status": "success"
    }
}
```

`ToolResultBlock`의 콘텐츠는 단일 JSON이거나 텍스트와 이미지를 혼합한 것이어야 합니다.

상태 필드는 모델에 도구 실행 상태를 표시하는 데 사용할 수 있습니다. 도구 실행이 실패한 경우 실패를 표시하면 Amazon Nova가 원래 도구 직접 호출을 수정하려고 시도합니다.

스키마에 대한 자세한 내용은 [ToolResultContentBlock](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ToolResultContentBlock.html) 설명서를 참조하세요.

다음은 Converse API를 사용하여 도구 결과를 반환하는 방법의 예제입니다.

```
messages.append({
    "role": "user",
    "content": [
        {
            "toolResult": {
                "toolUseId": tool['toolUseId'],
                "content": [{"json": {"song": song, "artist": artist}}],
                "status": "success"
            }
        }
    ]
})

inf_params = {"maxTokens": 1000, "temperature": 0}

# Send the tool result to the model.
response = client.converse(
    modelId="us.amazon.nova-lite-v1:0",
    messages=messages,
    toolConfig=tool_config,
    inferenceConfig=inf_params
)

print(response['output']['message'])
```

도구를 활용하는 방법에 대한 자세한 내용은 [Amazon Bedrock Tool Use](https://docs.aws.amazon.com/bedrock/latest/userguide/tool-use.html) 설명서나 Amazon Nova 샘플 리포지토리의 [도구 사용 샘플](https://github.com/aws-samples/amazon-nova-samples/blob/main/multimodal-understanding/repeatable-patterns/10-tool-calling-with-converse/10_tool_calling_with_converse.ipynb)을 참조하세요.