도구 선택 - Amazon Nova

도구 선택

Amazon Nova 모델은 도구 선택 기능을 지원합니다. 도구 선택을 통해 개발자는 도구가 직접적으로 호출되는 방식을 제어할 수 있습니다. 도구 선택에 지원되는 파라미터 옵션은 tool, any, auto의 세 가지입니다.

  • 도구 - 지정된 도구가 한 번 직접적으로 호출됩니다.

  • 모두 - 제공된 도구 중 하나가 한 번 이상 직접적으로 호출됩니다.

  • 자동 - 모델이 도구를 직접적으로 호출할지 결정하고 필요한 경우 여러 도구가 직접적으로 호출됩니다.

Tool

도구 선택으로 tool을 사용하면 모델이 직접적으로 호출하는 특정 도구를 제어할 수 있습니다. 아래 예제에서는 응답의 형식을 일관된 방식으로 지정해야 하는 구조화된 출력 사용 사례를 통해 이를 보여줍니다.

tool_config = { "toolChoice": { "tool": { "name" : "extract_recipe"} }, "tools": [ { "toolSpec": { "name": "extract_recipe", "description": "Extract recipe for cooking instructions", "inputSchema": { "json": { "type": "object", "properties": { "name": { "type": "string", "description": "Name of the recipe" }, "description": { "type": "string", "description": "Brief description of the dish" }, "ingredients": { "type": "array", "items": { "type": "string", "description": "Name of ingredient" } } }, "required": ["name", "description", "ingredients"] } } } } ] }
Any

도구 선택으로 any를 사용하면 매번 최소 하나의 도구가 직접적으로 호출되도록 할 수 있습니다. 어떤 도구를 직접적으로 호출할지 결정하는 것은 모델에 달려 있지만, 항상 반환되는 도구가 있습니다. 아래 예제에서는 API 선택 엔드포인트 사용 사례에 도구 선택으로 any를 사용하는 것을 보여줍니다. 이는 모델이 특정 도구를 반환하도록 요구하는 것이 유용한 한 가지 예제입니다.

tool_config = { "toolChoice": { "any": {} }, "tools": [ { "toolSpec": { "name": "get_all_products", "description": "API to retrieve multiple products with filtering and pagination options", "inputSchema": { "json": { "type": "object", "properties": { "sort_by": { "type": "string", "description": "Field to sort results by. One of: price, name, created_date, popularity", "default": "created_date" }, "sort_order": { "type": "string", "description": "Order of sorting (ascending or descending). One of: asc, desc", "default": "desc" }, }, "required": [] } } } }, { "toolSpec": { "name": "get_products_by_id", "description": "API to retrieve retail products based on search criteria", "inputSchema": { "json": { "type": "object", "properties": { "product_id": { "type": "string", "description": "Unique identifier of the product" }, }, "required": ["product_id"] } } } } ] }
Auto

도구 선택으로 auto를 사용하는 것은 도구 지원의 기본 기능으로, 모델이 도구를 직접적으로 호출할 시기와 직접적으로 호출할 도구의 수를 결정할 수 있습니다. 이는 요청에 도구 선택을 포함하지 않는 경우의 동작입니다.

참고

Amazon Nova 도구 직접 호출의 기본 동작은 도구 선택에 생각의 사슬을 사용하는 것입니다. 기본 동작이나 도구 선택 auto를 사용하는 경우 <thinking> 태그에 생각 프로세스 출력도 표시됩니다.

다음 예제에서는 모델이 인터넷에서 최신 정보를 검색하거나 사용자에게 직접 응답하도록 허용하려는 챗봇 사용 사례를 강조합니다. 이 도구 선택은 유연성을 제공하며 추론은 모델에 맡깁니다.

tool_config = { "toolChoice": { "auto": {} }, "tools": [ { "toolSpec": { "name": "search", "description": "API that provides access to the internet", "inputSchema": { "json": { "type": "object", "properties": { "query": { "type": "string", "description": "Query to search by", }, }, "required": ["query"] } } } } ] }
참고

도구 선택 파라미터를 설정할 때 모델 출력 텍스트가 계속 표시되거나 원래 도구 선택 후에 순차적 도구 호출을 수행할 수 있습니다. 여기에서 중지 시퀀스를 설정하여 출력을 도구로만 제한하는 것이 좋습니다.

“stopSequences”: [“</tool>”]

자세한 내용은 Amazon Bedrock API 가이드의 InferenceConfiguration을 참조하세요.