Prompt Optimizer
This example demonstrates how to use the prompt optimization features of the gollm package for individual prompt optimization.
Key Components
LLM Setup: Initializes an LLM client using the Groq provider.
PromptExamples: Defines prompts to be optimized with associated metrics and thresholds.
Optimization Process: Iterates through examples, optimizing each prompt.
Response Generation: Generates content using optimized prompts.
Result Display: Shows original prompts, optimized versions, and generated content.
Code Structure
Key Code Snippets
LLM Setup
Defining a PromptExample
Optimization Process
Usage
Install and configure the gollm package.
Set the
GROQ_API_KEY
environment variable.Run:
go run prompt_optimizer_example.go
Customization
Modify
PromptExample
structs in theexamples
slice.Adjust optimization parameters (threshold, metrics, rating system).
Change LLM configuration (provider, model).
Last updated