|
| 1 | +<!-- |
| 2 | +SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 3 | +SPDX-License-Identifier: Apache-2.0 |
| 4 | +
|
| 5 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +you may not use this file except in compliance with the License. |
| 7 | +You may obtain a copy of the License at |
| 8 | +
|
| 9 | +http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +
|
| 11 | +Unless required by applicable law or agreed to in writing, software |
| 12 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +See the License for the specific language governing permissions and |
| 15 | +limitations under the License. |
| 16 | +--> |
| 17 | + |
| 18 | +# EXAMPLE_TITLE |
| 19 | + |
| 20 | +<!-- Replace with a brief description of what your example demonstrates --> |
| 21 | +This example demonstrates [DESCRIPTION_OF_WHAT_YOUR_EXAMPLE_DOES] using the NVIDIA NeMo Agent toolkit, fully configured through a YAML file. It showcases [SPECIFIC_FEATURES_YOUR_EXAMPLE_HIGHLIGHTS]. |
| 22 | + |
| 23 | +## Table of Contents |
| 24 | + |
| 25 | +- [EXAMPLE\_TITLE](#example_title) |
| 26 | + - [Table of Contents](#table-of-contents) |
| 27 | + - [Key Features](#key-features) |
| 28 | + - [Installation and Setup](#installation-and-setup) |
| 29 | + - [Install this Workflow:](#install-this-workflow) |
| 30 | + - [Set Up API Keys](#set-up-api-keys) |
| 31 | + - [Run the Workflow](#run-the-workflow) |
| 32 | + - [Deployment-Oriented Setup](#deployment-oriented-setup) |
| 33 | + - [Build the Docker Image](#build-the-docker-image) |
| 34 | + - [Run the Docker Container](#run-the-docker-container) |
| 35 | + - [Test the API](#test-the-api) |
| 36 | + - [Expected API Output](#expected-api-output) |
| 37 | + - [Customization Guide](#customization-guide) |
| 38 | + - [Adding New Functions](#adding-new-functions) |
| 39 | + - [Modifying the Agent](#modifying-the-agent) |
| 40 | + - [Using Different Models](#using-different-models) |
| 41 | + |
| 42 | +--- |
| 43 | + |
| 44 | +## Key Features |
| 45 | + |
| 46 | +<!-- Replace with your specific features --> |
| 47 | +- **Custom Functions:** Demonstrates [DESCRIBE_YOUR_CUSTOM_FUNCTIONS] |
| 48 | +- **Agent Integration:** Uses a [AGENT_TYPE] that [DESCRIBE_WHAT_THE_AGENT_DOES] |
| 49 | +- **Multi-step Problem Solving:** Shows how an agent can [DESCRIBE_COMPLEX_WORKFLOWS] |
| 50 | +- **Custom Function Registration:** Demonstrates the NeMo Agent toolkit plugin system for [DESCRIBE_PLUGIN_FUNCTIONALITY] |
| 51 | +- **YAML-based Configuration:** Fully configurable workflow that showcases [DESCRIBE_CONFIGURATION_BENEFITS] |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## Installation and Setup |
| 56 | + |
| 57 | +### Install this Workflow: |
| 58 | + |
| 59 | +From the root directory of the NeMo Agent toolkit library, run the following commands: |
| 60 | + |
| 61 | +```bash |
| 62 | +uv pip install -e examples/EXAMPLE_CATEGORY/EXAMPLE_NAME |
| 63 | +``` |
| 64 | + |
| 65 | +### Set Up API Keys |
| 66 | +Depending on which workflows you are running, you may need to obtain API keys from the respective services. Most NeMo Agent toolkit workflows require an NVIDIA API key defined with the `NVIDIA_API_KEY` environment variable. An API key can be obtained by visiting [`build.nvidia.com`](https://build.nvidia.com/) and creating an account. |
| 67 | + |
| 68 | +Some workflows may also require an OpenAI API key. Visit [OpenAI](https://openai.com/) and create an account. Navigate to your account settings to obtain your OpenAI API key. |
| 69 | + |
| 70 | +```bash |
| 71 | +export NVIDIA_API_KEY=<YOUR_API_KEY> |
| 72 | +export OPENAI_API_KEY=<YOUR_API_KEY> # OPTIONAL |
| 73 | +``` |
| 74 | + |
| 75 | +### Run the Workflow |
| 76 | + |
| 77 | +Return to your original terminal, and run the following command from the root of the NeMo Agent toolkit repo to execute this workflow with the specified input: |
| 78 | + |
| 79 | +```bash |
| 80 | +nat run --config_file examples/EXAMPLE_CATEGORY/EXAMPLE_NAME/configs/config.yml --input "YOUR_EXAMPLE_INPUT_PROMPT" |
| 81 | +``` |
| 82 | + |
| 83 | +**Expected Workflow Output** |
| 84 | +<!-- Replace with your expected output --> |
| 85 | +``` |
| 86 | +YOUR_EXPECTED_OUTPUT_HERE |
| 87 | +``` |
| 88 | + |
| 89 | +## Deployment-Oriented Setup |
| 90 | + |
| 91 | +For a production deployment, use Docker: |
| 92 | + |
| 93 | +### Build the Docker Image |
| 94 | + |
| 95 | +Prior to building the Docker image ensure that you have followed the steps in the [Installation and Setup](#installation-and-setup) section, and you are currently in the NeMo Agent toolkit virtual environment. |
| 96 | + |
| 97 | +From the root directory of the NeMo Agent toolkit repository, build the Docker image: |
| 98 | + |
| 99 | +```bash |
| 100 | +docker build --build-arg NAT_VERSION=$(python -m setuptools_scm) -t EXAMPLE_NAME -f examples/EXAMPLE_CATEGORY/EXAMPLE_NAME/Dockerfile . |
| 101 | +``` |
| 102 | + |
| 103 | +### Run the Docker Container |
| 104 | +Deploy the container: |
| 105 | + |
| 106 | +```bash |
| 107 | +docker run -p 8000:8000 -p 6006:6006 -e NVIDIA_API_KEY -e OPENAI_API_KEY EXAMPLE_NAME |
| 108 | +``` |
| 109 | + |
| 110 | +Note, a phoenix telemetry service will be exposed at port 6006. |
| 111 | + |
| 112 | +### Test the API |
| 113 | +Use the following curl command to test the deployed API: |
| 114 | + |
| 115 | +```bash |
| 116 | +curl -X 'POST' \ |
| 117 | + 'http://localhost:8000/generate' \ |
| 118 | + -H 'accept: application/json' \ |
| 119 | + -H 'Content-Type: application/json' \ |
| 120 | + -d '{"input_message": "YOUR_EXAMPLE_INPUT_PROMPT"}' |
| 121 | +``` |
| 122 | + |
| 123 | +### Expected API Output |
| 124 | +The API response should be similar to the following: |
| 125 | + |
| 126 | +```bash |
| 127 | +{ |
| 128 | + "input": "YOUR_EXAMPLE_INPUT_PROMPT", |
| 129 | + "value": "YOUR_EXPECTED_OUTPUT_HERE" |
| 130 | +} |
| 131 | +``` |
| 132 | + |
| 133 | +## Customization Guide |
| 134 | + |
| 135 | +<!-- Add any specific customization instructions for your example --> |
| 136 | + |
| 137 | +### Adding New Functions |
| 138 | +1. Define a new config class in `register.py` that inherits from `FunctionBaseConfig` |
| 139 | +2. Create a function decorated with `@register_function` |
| 140 | +3. Add the function to your `config.yml` file |
| 141 | +4. Update the workflow's `tool_names` list |
| 142 | + |
| 143 | +### Modifying the Agent |
| 144 | +- Change the `_type` in the workflow section to use different agent types |
| 145 | +- Adjust `max_iterations`, `temperature`, or other parameters as needed |
| 146 | +- Add custom system prompts or modify the agent behavior |
| 147 | + |
| 148 | +### Using Different Models |
| 149 | +- Update the `model_name` in the LLM configuration |
| 150 | +- Adjust parameters such as `temperature` and `max_tokens` |
| 151 | +- Switch between different LLM providers (OpenAI, NIM, and so on) |
0 commit comments