Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
QueryRewriterAgent
QueryRewriterAgent rewrites and optimizes queries for better search results.
Quick Start
import { createQueryRewriterAgent } from 'praisonai';
const agent = createQueryRewriterAgent({
llm: 'openai/gpt-4o-mini'
});
const result = await agent.rewrite('best programming language');
console.log(result.rewritten);
Configuration
interface QueryRewriterConfig {
name?: string;
llm?: string;
defaultStrategy?: RewriteStrategy;
verbose?: boolean;
}
type RewriteStrategy = 'expand' | 'simplify' | 'decompose' | 'rephrase' | 'auto';
Strategies
| Strategy | Description |
|---|
expand | Add more context and detail |
simplify | Make query simpler |
decompose | Break into sub-queries |
rephrase | Rephrase for clarity |
auto | Automatically detect best strategy |
interface RewriteResult {
original: string;
rewritten: string[];
strategy: RewriteStrategy;
confidence: number;
}
Example
import { createQueryRewriterAgent } from 'praisonai';
const agent = createQueryRewriterAgent({
llm: 'openai/gpt-4o-mini',
defaultStrategy: 'auto'
});
const result = await agent.rewrite('best programming language');
// Result:
// {
// original: 'best programming language',
// rewritten: [
// 'What is the top programming language?',
// 'Which programming language is considered the best?',
// 'What is the most highly regarded programming language?'
// ],
// strategy: 'rephrase',
// confidence: 0.85
// }
CLI Usage
praisonai-ts query-rewrite "best programming language"
praisonai-ts query-rewrite "how to learn coding" --strategy expand --json