Prompts Module¶
Overview¶
The prompts
module in the AgenticAI Framework provides utilities for creating, managing, and optimizing prompts for Large Language Models (LLMs). It supports dynamic prompt construction, templating, and context injection to improve AI output quality.
Key Classes and Functions¶
- PromptTemplate — Defines a reusable prompt with placeholders for dynamic values.
- PromptManager — Manages a collection of prompt templates.
- render_prompt(template_name, kwargs)** — Renders a prompt by filling in placeholders with provided values.
- optimize_prompt(prompt, kwargs)** — Adjusts prompt wording for better LLM performance.
- load_prompts_from_file(file_path) — Loads prompt templates from a file.
Example Usage¶
from agenticaiframework.prompts import PromptTemplate, PromptManager
# Create a prompt template
template = PromptTemplate(
name="greeting",
template="Hello {name}, welcome to {platform}!"
)
# Render the prompt
prompt_text = template.render(name="Alice", platform="AgenticAI")
print(prompt_text)
# Manage multiple prompts
manager = PromptManager()
manager.add_template(template)
Use Cases¶
- Creating consistent prompts for chatbots and virtual assistants.
- Dynamically generating prompts based on user input or context.
- Optimizing prompts for specific LLM providers.
- Managing large prompt libraries for enterprise applications.
Best Practices¶
- Keep prompts concise and clear to avoid ambiguity.
- Use placeholders for dynamic values to improve reusability.
- Test prompts with different LLMs to ensure compatibility.
- Store prompts in version-controlled files for maintainability.