Iragent
This project is about using agents as simple as possible with small and large language models
Loading...
Searching...
No Matches
iragent.models.SmartPrompt Class Reference

Public Member Functions

None __init__ (self, AgentFactory agent_factory)
 
str generate (self, str input, str output)
 

Public Attributes

 writer
 
 reader
 
 manager
 

Detailed Description

A utility class for generating optimized system prompts based on example 
inputs and desired outputs using a two-agent collaborative workflow.

This class leverages:
    1. `writer` – An agent that crafts an initial prompt tailored to produce 
       the desired output from a given input.
    2. `reader` – An agent that reviews and refines the generated prompt for 
       clarity, accuracy, and adherence to the intended task.

Both agents are orchestrated by an `AutoAgentManager` to enable iterative 
collaboration until the prompt meets the defined termination condition.

Attributes:
    writer (Agent): The prompt creation agent.
    reader (Agent): The prompt review and refinement agent.
    manager (AutoAgentManager): Coordinates the interaction between 
        `writer` and `reader` agents.

Args:
    agent_factory (AgentFactory): The factory used to create new agents.

Methods:
    generate(input: str, output: str) -> str:
        Generates a refined prompt based on an example input and its 
        expected output. The process:
            - Passes the input and output examples to the manager.
            - Iteratively runs writer and reader agents.
            - Returns the final crafted system prompt.

Constructor & Destructor Documentation

◆ __init__()

None iragent.models.SmartPrompt.__init__ ( self,
AgentFactory agent_factory )

Member Function Documentation

◆ generate()

str iragent.models.SmartPrompt.generate ( self,
str input,
str output )

Member Data Documentation

◆ manager

iragent.models.SmartPrompt.manager
Initial value:
= AutoAgentManager(
init_message="",
agents= [self.writer,self.reader],
first_agent=self.writer,
max_round=5,
termination_fn=simple_termination,
termination_word="[#finish#]"
)

◆ reader

iragent.models.SmartPrompt.reader
Initial value:
= agent_factory.create_agent(
name="prompt_reader",
temprature=0.1,
system_prompt=SMART_PROMPT_READER,
max_token = 512
)

◆ writer

iragent.models.SmartPrompt.writer
Initial value:
= agent_factory.create_agent(
name="prompt_maker",
temprature=0.1,
system_prompt=SMART_PROMPT_WRITER,
max_token = 512
)

The documentation for this class was generated from the following file: