Wednesday, April 30, 2025
banner
Top Selling Multipurpose WP Theme

Many era AI functions use large-scale language fashions (LLMs) like Amazon Nova to answer consumer queries primarily based on the mannequin’s personal data or context. Nevertheless, as use instances matured, the flexibility to permit fashions to entry instruments or constructions basically exterior the mannequin’s reference body turned paramount. That is the schema and construction required by an API, code perform, or the ultimate software. This function has developed into what is named Utilizing the Software or Operate name.

So as to add finer management to how you utilize the software, now we have launched the software choice function for Amazon Nova fashions. As an alternative of counting on speedy engineering, the selection of instruments forces the mannequin to set the settings.

This put up explains easy methods to use instruments with examples of use instances and new software choice capabilities.

Utilizing instruments in Amazon Nova

As an instance the idea of utilizing instruments, you’ll be able to think about conditions that present Amazon Nova entry to a number of totally different instruments, akin to calculators and climate APIs. Primarily based on the consumer’s queries, Amazon Nova selects the fitting software and explains easy methods to use it. For instance, if a consumer asks, “What’s the climate in Seattle?” Amazon Nova makes use of climate instruments.

The next diagram reveals an instance workflow between the Amazon Nova mannequin, obtainable instruments, and related exterior assets.

Utilizing instruments within the core is the collection of instruments and their parameters. The accountability for performing exterior features is left to the appliance or developer. After the software is run by the appliance, it might generate a last response to return the outcomes to the mannequin.

Let’s look into some examples in additional element. The next diagram illustrates the workflow for the Amazon Nova mannequin utilizing perform calls to entry the Climate API and return a response to the consumer.

The next diagram illustrates the workflow for the Amazon Nova mannequin utilizing perform calls to entry the calculator software.

Choosing Instruments in Amazon Nova

toolChoice API parameters help you management it when the software is named. This parameter has three supported choices:

  • Any – There’s a software choice Anythe mannequin selects a minimum of one of many instruments obtainable every time.
    {
       "toolChoice": {
            "any": {}
        }
    }

  • software – There’s a software choice Softwarethe mannequin at all times makes use of the requested software.
    {
       "toolChoice": {
            "software": {
                "title": "name_of_tool"
            }
        }
    }

  • Automated – Choose Instruments Auto It is the default conduct, leaving the collection of instruments completely to the mannequin.
    {
       "toolChoice": {
            "auto": {}
        }
    }

A standard tactic to enhance a mannequin’s reasoning capacity is to make use of a set of ideas. When you use software choice for autoAmazon Nova makes use of a set of ideas, and the mannequin response consists of each the chosen inference and instruments.

This conduct varies relying on the use case. when software or any Chosen as a software choice, Amazon Nova solely outputs the software and doesn’t output the thought chain.

Use Instances

On this part, we are going to look at varied use instances for software choice.

Structured Output/JSON Mode

In a selected state of affairs, you might assume that Amazon Nova can present solutions with out utilizing instruments, however you might have considered trying Amazon Nova to make use of sure instruments to reply consumer questions. A standard use case for this method is to implement a structured output/JSON mode. It’s typically essential that LLMS returns structured output. This permits downstream use instances to extra successfully eat and course of the generated output. In these examples, the instruments employed don’t essentially should be client-side features. These can be utilized when the mannequin is required to return JSON output that the mannequin adheres to a predefined schema.

When utilizing instruments to implement structured output, present a single software utilizing descriptive JSON inputSchema. Specify the software {"software" : {"title" : "Your software title"}}. The mannequin passes enter to the software, so the title of the software and its description have to be from a mannequin’s perspective.

For instance, think about a meals web site. If a cooking description is supplied, the web site can extract recipe particulars akin to cooking time, substances, dish title, and problem to facilitate consumer search and filtering capabilities. See the next instance code:

import boto3
import json

tool_config = {
    "toolChoice": {
        "title": { "software" : "extract_recipe"}
    },
    "instruments": [
        {
            "toolSpec": {
                "name": "extract_recipe",
                "description": "Extract recipe for cooking instructions",
                "inputSchema": {
                    "json": {
                        "type": "object",
                        "properties": {
                            "recipe": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "description": "Name of the recipe"
                                    },
                                    "description": {
                                        "type": "string",
                                        "description": "Brief description of the dish"
                                    },
                                    "prep_time": {
                                        "type": "integer",
                                        "description": "Preparation time in minutes"
                                    },
                                    "cook_time": {
                                        "type": "integer",
                                        "description": "Cooking time in minutes"
                                    },
                                    "servings": {
                                        "type": "integer",
                                        "description": "Number of servings"
                                    },
                                    "difficulty": {
                                        "type": "string",
                                        "enum": ["easy", "medium", "hard"],
                                        "description": "Issue degree of the recipe"
                                    },
                                    "substances": {
                                        "kind": "array",
                                        "objects": {
                                            "kind": "object",
                                            "properties": {
                                                "merchandise": {
                                                    "kind": "string",
                                                    "description": "Title of ingredient"
                                                },
                                                "quantity": {
                                                    "kind": "quantity",
                                                    "description": "Amount of ingredient"
                                                },
                                                "unit": {
                                                    "kind": "string",
                                                    "description": "Unit of measurement"
                                                }
                                            },
                                            "required": ["item", "amount", "unit"]
                                        }
                                    },
                                    "directions": {
                                        "kind": "array",
                                        "objects": {
                                            "kind": "string",
                                            "description": "Step-by-step cooking directions"
                                        }
                                    },
                                    "tags": {
                                        "kind": "array",
                                        "objects": {
                                            "kind": "string",
                                            "description": "Classes or labels for the recipe"
                                        }
                                    }
                                },
                                "required": ["name", "ingredients", "instructions"]
                            }
                        },
                        "required": ["recipe"]
                    }
                }
            }
        }
    ]
}

messages = [{
    "role": "user",
    "content": [
        {"text": input_text},
    ]
}]

inf_params = {"topP": 1, "temperature": 1}

consumer = boto3.consumer("bedrock-runtime", region_name="us-east-1")

response = consumer.converse(
    modelId="us.amazon.nova-micro-v1:0",
    messages=messages,
    toolConfig=tool_config,
    inferenceConfig=inf_params,
    additionalModelRequestFields= {"inferenceConfig": { "topK": 1 } }
)
print(json.dumps(response['output']['message']['content'][0][], indent=2))

An in depth description of the dish will be supplied as textual content enter.

Legend has it that this decadent chocolate lava cake was born out of a baking mistake in New York's Any Kitchen again in 1987, when chef John Doe pulled a chocolate sponge cake out of the oven too early, solely to find that the dessert world would by no means be the identical. Right this moment I am sharing my foolproof model, refined over numerous dinner events. Image a fragile chocolate cake that, when pierced with a fork, releases a stream of heat, velvety chocolate sauce – it is pure theater on the desk. Whereas it seems to be like a restaurant-worthy masterpiece, the sweetness lies in its simplicity: simply six substances (good high quality darkish chocolate, unsalted butter, eggs, sugar, flour, and a pinch of salt) rework into particular person desserts in below quarter-hour. The key? Exact timing is every part. Pull them from the oven a minute too late, and you may miss that magical molten middle; too early, they usually'll be uncooked. However hit that candy spot at precisely 12 minutes, when the perimeters are set however the middle nonetheless wobbles barely, and you've got achieved dessert perfection. I like serving these straight from the oven, dusted with powdered sugar and topped with a small scoop of vanilla bean ice cream that slowly melts into the nice and cozy cake. The distinction of temperatures and textures – heat and chilly, crisp and gooey – makes this easy dessert completely unforgettable.

You’ll be able to pressure Amazon Nova to make use of the software extract_recipegenerates structured JSON output that adheres to the predefined schema supplied because the software enter schema.

 {
  "toolUseId": "tooluse_4YT_DYwGQlicsNYMbWFGPA",
  "title": "extract_recipe",
  "enter": {
    "recipe": {
      "title": "Decadent Chocolate Lava Cake",
      "description": "A fragile chocolate cake that releases a stream of heat, velvety chocolate sauce when pierced with a fork. It is pure theater on the desk.",
      "problem": "medium",
      "substances": [
        {
          "item": "good quality dark chocolate",
          "amount": 125,
          "unit": "g"
        },
        {
          "item": "unsalted butter",
          "amount": 125,
          "unit": "g"
        },
        {
          "item": "eggs",
          "amount": 4,
          "unit": ""
        },
        {
          "item": "sugar",
          "amount": 100,
          "unit": "g"
        },
        {
          "item": "flour",
          "amount": 50,
          "unit": "g"
        },
        {
          "item": "salt",
          "amount": 0.5,
          "unit": "pinch"
        }
      ],
      "directions": [
        "Preheat the oven to 200u00b0C (400u00b0F).",
        "Melt the chocolate and butter together in a heatproof bowl over a saucepan of simmering water.",
        "In a separate bowl, whisk the eggs and sugar until pale and creamy.",
        "Fold the melted chocolate mixture into the egg and sugar mixture.",
        "Sift the flour and salt into the mixture and gently fold until just combined.",
        "Divide the mixture among six ramekins and bake for 12 minutes.",
        "Serve straight from the oven, dusted with powdered sugar and topped with a small scoop of vanilla bean ice cream."
      ],
      "prep_time": 10,
      "cook_time": 12,
      "servings": 6,
      "tags": [
        "dessert",
        "chocolate",
        "cake"
      ]
    }
  }
}

API era

One other widespread state of affairs is to ask Amazon Nova to pick out a software from the choices obtainable, whatever the context of the consumer question. An instance of that is the collection of an API endpoint. On this state of affairs, you do not know what particular software to make use of. Permits the mannequin to pick out the obtainable instruments.

There’s a collection of instruments for anyyou’ll be able to make sure that your mannequin at all times makes use of a minimum of one of many obtainable instruments. This supplies instruments that can be utilized when the API is just not related. One other instance is to offer instruments that enable for clear questions.

This instance supplies two totally different APIs for the mannequin, in addition to unsupported API instruments to pick out primarily based on consumer queries.

import boto3
import json

tool_config = {
    "toolChoice": {
        "any": {}
    },
    "instruments": [
         {
            "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": {
                "title": "get_products_by_id",
                "description": "API to retrieve retail merchandise primarily based on search standards",
                "inputSchema": {
                    "json": {
                        "kind": "object",
                        "properties": {
                            "product_id": {
                                "kind": "string",
                                "description": "Distinctive identifier of the product"
                            },
                        },
                        "required": ["product_id"]
                    }
                }
            }
        },
        {
            "toolSpec": {
                "title": "unsupported_api",
                "description": "API to make use of when the consumer question doesn't relate to the opposite obtainable APIs",
                "inputSchema": {
                    "json": {
                        "kind": "object",
                        "properties": {
                            "reasoning": {
                                "kind": "string",
                                "description": "The reasoning for why the consumer question didn't have a legitimate API obtainable"
                            },
                        },
                        "required": ["reasoning"]
                    }
                }
            }
        }
    ]
}


messages = [{
    "role": "user",
    "content": [
        {"text": input_text},
    ]
}]

inf_params = {"topP": 1, "temperature": 1}

consumer = boto3.consumer("bedrock-runtime", region_name="us-east-1")

response = consumer.converse(
    modelId="us.amazon.nova-micro-v1:0",
    messages=messages,
    toolConfig=tool_config,
    inferenceConfig=inf_params,
    additionalModelRequestFields= {"inferenceConfig": { "topK": 1 } }
)

print(json.dumps(response['output']['message']['content'][0], indent=2))

Consumer enter: “Can you get all obtainable merchandise?” The next is output:

{
  "toolUse": {
    "toolUseId": "tooluse_YCNbT0GwSAyjIYOuWnDhkw",
    "title": "get_all_products",
    "enter": {}
  }
}

In the meantime, it outputs the next: “Can I get my newest order?”

{
  "toolUse": {
    "toolUseId": "tooluse_jpiZnrVcQDS1sAa-qPwIQw",
    "title": "unsupported_api",
    "enter": {
      "reasoning": "The obtainable instruments don't assist retrieving consumer orders. The consumer's request is for private order info, which isn't coated by the supplied APIs."
    }
  }
}

Search and chat

The ultimate choices for choosing instruments are: auto. That is the default conduct, and is according to not offering any software choice in any respect.

This software choice permits solely software utilization choices or textual content output. When the mannequin selects a software, there are software blocks and textual content blocks. If the mannequin responds with out instruments, solely textual content blocks are returned. The next instance permits the mannequin to answer the consumer or name the software if obligatory.

import boto3
import json

tool_config = {
    "toolChoice": {
        "auto": {}
    },
    "instruments": [
         {
            "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"]
                    }
                }
            }
        }
    ]
}

messages = [{
    "role": "user",
    "content": [
        {"text": input_text},
    ]
}]

system = [{
    "text": "ou are a helpful chatbot. You can use a tool if necessary or respond to the user query"
}]

inf_params = {"topP": 1, "temperature": 1}

consumer = boto3.consumer("bedrock-runtime", region_name="us-east-1")

response = consumer.converse(
    modelId="us.amazon.nova-micro-v1:0",
    messages=messages,
    toolConfig=tool_config,
    inferenceConfig=inf_params,
    additionalModelRequestFields= {"inferenceConfig": { "topK": 1 } }
)


if (response["stopReason"] == "tool_use"):
    tool_use = subsequent(
        block["toolUse"]
        for block in response["output"]["message"]["content"]
            if "toolUse" in block
    )
   print(json.dumps(tool_use, indent=2))
 else:
    sample = r'<pondering>.*?</pondering>nn|<pondering>.*?</pondering>'
    text_response = response["output"]["message"]["content"][0]["text"]
    stripped_text = re.sub(sample, '', text_response, flags=re.DOTALL)
    
    print(stripped_text)

Consumer enter: “What’s the climate in San Francisco?” A software name happens.

{
  "toolUseId": "tooluse_IwtBnbuuSoynn1qFiGtmHA",
  "title": "search",
  "enter": {
    "question": "what's the climate in san francisco"
  }
}

Alternatively, reply to a consumer with textual content responses to direct questions akin to “What number of months is it in a 12 months?”

There are 12 months in a 12 months.

Issues

There are some finest practices wanted to invoke instruments within the NOVA mannequin. The primary is to make use of it Grasping decoding parameter. With Amazon Nova fashions, you must set temperature, high P, and high Ok. You’ll be able to confer with the earlier code examples for directions on easy methods to set these up. Utilizing grasping decoding parameters will trigger the mannequin to generate deterministic responses, growing the success charge of software calls.

The second consideration is the JSON schema that you’re utilizing to think about the software. On the time of writing, the Amazon Nova mannequin helps a restricted subset of JSON schemas, so it’s attainable that the mannequin is not going to be featured as anticipated. That is most likely the standard area $def and $ref area. Be sure that the next top-level fields are set within the schema: kind (have to be object),, propertiesand required.

Lastly, you must optimize your software configuration to most affect the success of your software calls. The outline and title have to be very clear. If there’s a nuance when you must name one software to a different, ensure that it’s included within the software description in a concise method.

Conclusion

Utilizing software choice in software name workflows is a scalable approach to management how a mannequin calls a software. As an alternative of counting on speedy engineering, the selection of instruments forces the mannequin to set the settings. Nevertheless, software invocations are advanced. For extra info, see Utilizing Instruments (Operate Calls), Software Calling Methods, and Troubleshooting Software Calls in Amazon Nova.

Learn how Amazon Nova fashions can improve right this moment’s era AI use instances.


Concerning the Creator

Jan Farmer He’s the Generic AI Options Architect for the Amazon Synthetic Basic Data (AGI) workforce and makes a speciality of agent functions. Primarily based in Seattle, Washington, she works on the intersection of autonomous AI methods and sensible enterprise options, serving to to form the way forward for AGI on Amazon.

Sharon Lee I’m AI/ML Specialist Options Architect at Amazon Internet Companies (AWS) primarily based in Boston, Massachusetts. Enthusiastic about leveraging cutting-edge expertise, Sharon is on the forefront of creating and deploying revolutionary era AI options on the AWS Cloud Platform.

Lulu Wong I’m an AI UX designer for the Amazon Synthetic Basic Data (AGI) workforce. A background in pc science, studying design, and consumer expertise bridges the expertise and consumer expertise domains by refinement of mannequin enter and output behaviors and creating assets that make AI merchandise extra accessible to customers.

banner
Top Selling Multipurpose WP Theme

Converter

Top Selling Multipurpose WP Theme

Newsletter

Subscribe my Newsletter for new blog posts, tips & new photos. Let's stay updated!

banner
Top Selling Multipurpose WP Theme

Leave a Comment

banner
Top Selling Multipurpose WP Theme

Latest

Best selling

22000,00 $
16000,00 $
6500,00 $

Top rated

6500,00 $
22000,00 $
900000,00 $

Products

Knowledge Unleashed
Knowledge Unleashed

Welcome to Ivugangingo!

At Ivugangingo, we're passionate about delivering insightful content that empowers and informs our readers across a spectrum of crucial topics. Whether you're delving into the world of insurance, navigating the complexities of cryptocurrency, or seeking wellness tips in health and fitness, we've got you covered.