agent-opt
Python library. We will use the RandomSearchOptimizer
to demonstrate the core workflow of generating prompt variations and selecting the best one based on performance.
1. Installation and Setup
First, install the library and set up your environment variables. You can get your API keys from the Future AGI dashboard.2. Prepare Your Dataset
Optimization requires a dataset to evaluate prompt performance. A dataset is a simple list of Python dictionaries. For this example, we’ll create a small dataset for a summarization task.3. Configure and Run the Optimization
Next, we’ll set up the necessary components:Evaluator
: To score our prompts based on a metric.DataMapper
: To map our dataset fields to the optimizer’s expected inputs.RandomSearchOptimizer
: To generate and test prompt variations.
4. Analyze the Results
Theresult
object contains the best prompt found and its final score. You can also inspect the history of all variations that were tried.