Skip to content

Commit c19216e

Browse files
committed
add agent constructor params description
1 parent 70043cb commit c19216e

File tree

1 file changed

+85
-0
lines changed
  • src/praisonai-agents/praisonaiagents/agent

1 file changed

+85
-0
lines changed

src/praisonai-agents/praisonaiagents/agent/agent.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,91 @@ def __init__(
374374
guardrail: Optional[Union[Callable[['TaskOutput'], Tuple[bool, Any]], str]] = None,
375375
max_guardrail_retries: int = 3
376376
):
377+
"""Initialize an Agent instance.
378+
379+
Args:
380+
name (Optional[str], optional): Name of the agent used for identification and logging.
381+
If None, defaults to "Agent". Defaults to None.
382+
role (Optional[str], optional): Role or job title that defines the agent's expertise
383+
and behavior patterns. Examples: "Data Analyst", "Content Writer". Defaults to None.
384+
goal (Optional[str], optional): Primary objective or goal the agent aims to achieve.
385+
Defines the agent's purpose and success criteria. Defaults to None.
386+
backstory (Optional[str], optional): Background story or context that shapes the agent's
387+
personality and decision-making approach. Defaults to None.
388+
instructions (Optional[str], optional): Direct instructions that override role, goal,
389+
and backstory when provided. Used for simple, task-specific agents. Defaults to None.
390+
llm (Optional[Union[str, Any]], optional): Language model configuration. Can be a model
391+
name string (e.g., "gpt-4o", "anthropic/claude-3-sonnet") or a configured LLM object.
392+
Defaults to environment variable OPENAI_MODEL_NAME or "gpt-4o".
393+
tools (Optional[List[Any]], optional): List of tools, functions, or capabilities
394+
available to the agent for task execution. Can include callables, tool objects,
395+
or MCP instances. Defaults to None.
396+
function_calling_llm (Optional[Any], optional): Dedicated language model for function
397+
calling operations. If None, uses the main llm parameter. Defaults to None.
398+
max_iter (int, optional): Maximum number of iterations the agent can perform during
399+
task execution to prevent infinite loops. Defaults to 20.
400+
max_rpm (Optional[int], optional): Maximum requests per minute to rate limit API calls
401+
and prevent quota exhaustion. If None, no rate limiting is applied. Defaults to None.
402+
max_execution_time (Optional[int], optional): Maximum execution time in seconds for
403+
agent operations before timeout. If None, no time limit is enforced. Defaults to None.
404+
memory (Optional[Any], optional): Memory system for storing and retrieving information
405+
across conversations. Requires memory dependencies to be installed. Defaults to None.
406+
verbose (bool, optional): Enable detailed logging and status updates during agent
407+
execution for debugging and monitoring. Defaults to True.
408+
allow_delegation (bool, optional): Allow the agent to delegate tasks to other agents
409+
or sub-processes when appropriate. Defaults to False.
410+
step_callback (Optional[Any], optional): Callback function called after each step
411+
of agent execution for custom monitoring or intervention. Defaults to None.
412+
cache (bool, optional): Enable caching of responses and computations to improve
413+
performance and reduce API costs. Defaults to True.
414+
system_template (Optional[str], optional): Custom template for system prompts that
415+
overrides the default system prompt generation. Defaults to None.
416+
prompt_template (Optional[str], optional): Template for formatting user prompts
417+
before sending to the language model. Defaults to None.
418+
response_template (Optional[str], optional): Template for formatting agent responses
419+
before returning to the user. Defaults to None.
420+
allow_code_execution (Optional[bool], optional): Enable the agent to execute code
421+
snippets during task completion. Use with caution for security. Defaults to False.
422+
max_retry_limit (int, optional): Maximum number of retry attempts for failed operations
423+
before giving up. Helps handle transient errors. Defaults to 2.
424+
respect_context_window (bool, optional): Automatically manage context window size
425+
to prevent token limit errors with large conversations. Defaults to True.
426+
code_execution_mode (Literal["safe", "unsafe"], optional): Safety mode for code execution.
427+
"safe" restricts dangerous operations, "unsafe" allows full code execution. Defaults to "safe".
428+
embedder_config (Optional[Dict[str, Any]], optional): Configuration dictionary for
429+
text embedding models used in knowledge retrieval and similarity search. Defaults to None.
430+
knowledge (Optional[List[str]], optional): List of knowledge sources (file paths, URLs,
431+
or text content) to be processed and made available to the agent. Defaults to None.
432+
knowledge_config (Optional[Dict[str, Any]], optional): Configuration for knowledge
433+
processing and retrieval system including chunking and indexing parameters. Defaults to None.
434+
use_system_prompt (Optional[bool], optional): Whether to include system prompts in
435+
conversations to establish agent behavior and context. Defaults to True.
436+
markdown (bool, optional): Enable markdown formatting in agent responses for better
437+
readability and structure. Defaults to True.
438+
self_reflect (bool, optional): Enable self-reflection capabilities where the agent
439+
evaluates and improves its own responses. Defaults to False.
440+
max_reflect (int, optional): Maximum number of self-reflection iterations to prevent
441+
excessive reflection loops. Defaults to 3.
442+
min_reflect (int, optional): Minimum number of self-reflection iterations required
443+
before accepting a response as satisfactory. Defaults to 1.
444+
reflect_llm (Optional[str], optional): Dedicated language model for self-reflection
445+
operations. If None, uses the main llm parameter. Defaults to None.
446+
reflect_prompt (Optional[str], optional): Custom prompt template for self-reflection
447+
that guides the agent's self-evaluation process. Defaults to None.
448+
user_id (Optional[str], optional): Unique identifier for the user or session to
449+
enable personalized responses and memory isolation. Defaults to "praison".
450+
reasoning_steps (bool, optional): Enable step-by-step reasoning output to show the
451+
agent's thought process during problem solving. Defaults to False.
452+
guardrail (Optional[Union[Callable[['TaskOutput'], Tuple[bool, Any]], str]], optional):
453+
Safety mechanism to validate agent outputs. Can be a validation function or
454+
description string for LLM-based validation. Defaults to None.
455+
max_guardrail_retries (int, optional): Maximum number of retry attempts when guardrail
456+
validation fails before giving up. Defaults to 3.
457+
458+
Raises:
459+
ValueError: If all of name, role, goal, backstory, and instructions are None.
460+
ImportError: If memory or LLM features are requested but dependencies are not installed.
461+
"""
377462
# Add check at start if memory is requested
378463
if memory is not None:
379464
try:

0 commit comments

Comments
 (0)