diff --git a/docs/changelog.mdx b/docs/changelog.mdx index 3f17934bc..e88d1f632 100644 --- a/docs/changelog.mdx +++ b/docs/changelog.mdx @@ -4,7 +4,7 @@ description: View the latest updates and changes to CrewAI icon: timeline --- - + **Features** - Converted tabs to spaces in `crew.py` template - Enhanced LLM Streaming Response Handling and Event System @@ -24,7 +24,7 @@ icon: timeline - Added documentation for `ApifyActorsTool` - + **Core Improvements & Fixes** - Fixed issues with missing template variables and user memory configuration - Improved async flow support and addressed agent response formatting @@ -45,7 +45,7 @@ icon: timeline - Fixed typos in prompts and updated Amazon Bedrock model listings - + **Core Improvements & Fixes** - Enhanced LLM Support: Improved structured LLM output, parameter handling, and formatting for Anthropic models - Crew & Agent Stability: Fixed issues with cloning agents/crews using knowledge sources, multiple task outputs in conditional tasks, and ignored Crew task callbacks @@ -65,7 +65,7 @@ icon: timeline - Fixed Various Typos & Formatting Issues - + **Features** - Add Composio docs - Add SageMaker as a LLM provider @@ -80,7 +80,7 @@ icon: timeline - Improve formatting and clarity in CLI and Composio Tool docs - + **Features** - Conversation crew v1 - Add unique ID to flow states @@ -101,7 +101,7 @@ icon: timeline - Fixed typos, nested pydantic model issue, and docling issues - + **New Features** - Adding Multimodal Abilities to Crew - Programatic Guardrails @@ -131,7 +131,7 @@ icon: timeline - Suppressed userWarnings from litellm pydantic issues - + **Changes** - Remove all references to pipeline and pipeline router - Add Nvidia NIM as provider in Custom LLM @@ -141,7 +141,7 @@ icon: timeline - Simplify template crew - + **Features** - Added knowledge to agent level - Feat/remove langchain @@ -161,7 +161,7 @@ icon: timeline - Improvements to LLM Configuration and Usage - + **New Features** - New before_kickoff and after_kickoff crew callbacks - Support to pre-seed agents with Knowledge @@ -178,7 +178,7 @@ icon: timeline - Update Docs - + **Fixes** - Fixing Tokens callback replacement bug - Fixing Step callback issue diff --git a/docs/docs.json b/docs/docs.json index d2c7e55b0..7991e5953 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -111,6 +111,8 @@ "pages": [ "tools/aimindtool", "tools/apifyactorstool", + "tools/bedrockinvokeagenttool", + "tools/bedrockkbretriever", "tools/bravesearchtool", "tools/browserbaseloadtool", "tools/codedocssearchtool", diff --git a/docs/how-to/kickoff-for-each.mdx b/docs/how-to/kickoff-for-each.mdx index 4a83f7a5f..68e7ecd15 100644 --- a/docs/how-to/kickoff-for-each.mdx +++ b/docs/how-to/kickoff-for-each.mdx @@ -39,8 +39,7 @@ analysis_crew = Crew( agents=[coding_agent], tasks=[data_analysis_task], verbose=True, - memory=False, - respect_context_window=True # enable by default + memory=False ) datasets = [ diff --git a/docs/tools/bedrockinvokeagenttool.mdx b/docs/tools/bedrockinvokeagenttool.mdx new file mode 100644 index 000000000..c9b2c6aac --- /dev/null +++ b/docs/tools/bedrockinvokeagenttool.mdx @@ -0,0 +1,187 @@ +--- +title: Bedrock Invoke Agent Tool +description: Enables CrewAI agents to invoke Amazon Bedrock Agents and leverage their capabilities within your workflows +icon: aws +--- + +# `BedrockInvokeAgentTool` + +The `BedrockInvokeAgentTool` enables CrewAI agents to invoke Amazon Bedrock Agents and leverage their capabilities within your workflows. + +## Installation + +```bash +uv pip install 'crewai[tools]' +``` + +## Requirements + +- AWS credentials configured (either through environment variables or AWS CLI) +- `boto3` and `python-dotenv` packages +- Access to Amazon Bedrock Agents + +## Usage + +Here's how to use the tool with a CrewAI agent: + +```python {2, 4-8} +from crewai import Agent, Task, Crew +from crewai_tools.aws.bedrock.agents.invoke_agent_tool import BedrockInvokeAgentTool + +# Initialize the tool +agent_tool = BedrockInvokeAgentTool( + agent_id="your-agent-id", + agent_alias_id="your-agent-alias-id" +) + +# Create a CrewAI agent that uses the tool +aws_expert = Agent( + role='AWS Service Expert', + goal='Help users understand AWS services and quotas', + backstory='I am an expert in AWS services and can provide detailed information about them.', + tools=[agent_tool], + verbose=True +) + +# Create a task for the agent +quota_task = Task( + description="Find out the current service quotas for EC2 in us-west-2 and explain any recent changes.", + agent=aws_expert +) + +# Create a crew with the agent +crew = Crew( + agents=[aws_expert], + tasks=[quota_task], + verbose=2 +) + +# Run the crew +result = crew.kickoff() +print(result) +``` + +## Tool Arguments + +| Argument | Type | Required | Default | Description | +|:---------|:-----|:---------|:--------|:------------| +| **agent_id** | `str` | Yes | None | The unique identifier of the Bedrock agent | +| **agent_alias_id** | `str` | Yes | None | The unique identifier of the agent alias | +| **session_id** | `str` | No | timestamp | The unique identifier of the session | +| **enable_trace** | `bool` | No | False | Whether to enable trace for debugging | +| **end_session** | `bool` | No | False | Whether to end the session after invocation | +| **description** | `str` | No | None | Custom description for the tool | + +## Environment Variables + +```bash +BEDROCK_AGENT_ID=your-agent-id # Alternative to passing agent_id +BEDROCK_AGENT_ALIAS_ID=your-agent-alias-id # Alternative to passing agent_alias_id +AWS_REGION=your-aws-region # Defaults to us-west-2 +AWS_ACCESS_KEY_ID=your-access-key # Required for AWS authentication +AWS_SECRET_ACCESS_KEY=your-secret-key # Required for AWS authentication +``` + +## Advanced Usage + +### Multi-Agent Workflow with Session Management + +```python {2, 4-22} +from crewai import Agent, Task, Crew, Process +from crewai_tools.aws.bedrock.agents.invoke_agent_tool import BedrockInvokeAgentTool + +# Initialize tools with session management +initial_tool = BedrockInvokeAgentTool( + agent_id="your-agent-id", + agent_alias_id="your-agent-alias-id", + session_id="custom-session-id" +) + +followup_tool = BedrockInvokeAgentTool( + agent_id="your-agent-id", + agent_alias_id="your-agent-alias-id", + session_id="custom-session-id" +) + +final_tool = BedrockInvokeAgentTool( + agent_id="your-agent-id", + agent_alias_id="your-agent-alias-id", + session_id="custom-session-id", + end_session=True +) + +# Create agents for different stages +researcher = Agent( + role='AWS Service Researcher', + goal='Gather information about AWS services', + backstory='I am specialized in finding detailed AWS service information.', + tools=[initial_tool] +) + +analyst = Agent( + role='Service Compatibility Analyst', + goal='Analyze service compatibility and requirements', + backstory='I analyze AWS services for compatibility and integration possibilities.', + tools=[followup_tool] +) + +summarizer = Agent( + role='Technical Documentation Writer', + goal='Create clear technical summaries', + backstory='I specialize in creating clear, concise technical documentation.', + tools=[final_tool] +) + +# Create tasks +research_task = Task( + description="Find all available AWS services in us-west-2 region.", + agent=researcher +) + +analysis_task = Task( + description="Analyze which services support IPv6 and their implementation requirements.", + agent=analyst +) + +summary_task = Task( + description="Create a summary of IPv6-compatible services and their key features.", + agent=summarizer +) + +# Create a crew with the agents and tasks +crew = Crew( + agents=[researcher, analyst, summarizer], + tasks=[research_task, analysis_task, summary_task], + process=Process.sequential, + verbose=2 +) + +# Run the crew +result = crew.kickoff() +``` + +## Use Cases + +### Hybrid Multi-Agent Collaborations +- Create workflows where CrewAI agents collaborate with managed Bedrock agents running as services in AWS +- Enable scenarios where sensitive data processing happens within your AWS environment while other agents operate externally +- Bridge on-premises CrewAI agents with cloud-based Bedrock agents for distributed intelligence workflows + +### Data Sovereignty and Compliance +- Keep data-sensitive agentic workflows within your AWS environment while allowing external CrewAI agents to orchestrate tasks +- Maintain compliance with data residency requirements by processing sensitive information only within your AWS account +- Enable secure multi-agent collaborations where some agents cannot access your organization's private data + +### Seamless AWS Service Integration +- Access any AWS service through Amazon Bedrock Actions without writing complex integration code +- Enable CrewAI agents to interact with AWS services through natural language requests +- Leverage pre-built Bedrock agent capabilities to interact with AWS services like Bedrock Knowledge Bases, Lambda, and more + +### Scalable Hybrid Agent Architectures +- Offload computationally intensive tasks to managed Bedrock agents while lightweight tasks run in CrewAI +- Scale agent processing by distributing workloads between local CrewAI agents and cloud-based Bedrock agents + +### Cross-Organizational Agent Collaboration +- Enable secure collaboration between your organization's CrewAI agents and partner organizations' Bedrock agents +- Create workflows where external expertise from Bedrock agents can be incorporated without exposing sensitive data +- Build agent ecosystems that span organizational boundaries while maintaining security and data control \ No newline at end of file diff --git a/docs/tools/bedrockkbretriever.mdx b/docs/tools/bedrockkbretriever.mdx new file mode 100644 index 000000000..3868f636a --- /dev/null +++ b/docs/tools/bedrockkbretriever.mdx @@ -0,0 +1,165 @@ +--- +title: 'Bedrock Knowledge Base Retriever' +description: 'Retrieve information from Amazon Bedrock Knowledge Bases using natural language queries' +icon: aws +--- + +# `BedrockKBRetrieverTool` + +The `BedrockKBRetrieverTool` enables CrewAI agents to retrieve information from Amazon Bedrock Knowledge Bases using natural language queries. + +## Installation + +```bash +uv pip install 'crewai[tools]' +``` + +## Requirements + +- AWS credentials configured (either through environment variables or AWS CLI) +- `boto3` and `python-dotenv` packages +- Access to Amazon Bedrock Knowledge Base + +## Usage + +Here's how to use the tool with a CrewAI agent: + +```python {2, 4-17} +from crewai import Agent, Task, Crew +from crewai_tools.aws.bedrock.knowledge_base.retriever_tool import BedrockKBRetrieverTool + +# Initialize the tool +kb_tool = BedrockKBRetrieverTool( + knowledge_base_id="your-kb-id", + number_of_results=5 +) + +# Create a CrewAI agent that uses the tool +researcher = Agent( + role='Knowledge Base Researcher', + goal='Find information about company policies', + backstory='I am a researcher specialized in retrieving and analyzing company documentation.', + tools=[kb_tool], + verbose=True +) + +# Create a task for the agent +research_task = Task( + description="Find our company's remote work policy and summarize the key points.", + agent=researcher +) + +# Create a crew with the agent +crew = Crew( + agents=[researcher], + tasks=[research_task], + verbose=2 +) + +# Run the crew +result = crew.kickoff() +print(result) +``` + +## Tool Arguments + +| Argument | Type | Required | Default | Description | +|:---------|:-----|:---------|:---------|:-------------| +| **knowledge_base_id** | `str` | Yes | None | The unique identifier of the knowledge base (0-10 alphanumeric characters) | +| **number_of_results** | `int` | No | 5 | Maximum number of results to return | +| **retrieval_configuration** | `dict` | No | None | Custom configurations for the knowledge base query | +| **guardrail_configuration** | `dict` | No | None | Content filtering settings | +| **next_token** | `str` | No | None | Token for pagination | + +## Environment Variables + +```bash +BEDROCK_KB_ID=your-knowledge-base-id # Alternative to passing knowledge_base_id +AWS_REGION=your-aws-region # Defaults to us-east-1 +AWS_ACCESS_KEY_ID=your-access-key # Required for AWS authentication +AWS_SECRET_ACCESS_KEY=your-secret-key # Required for AWS authentication +``` + +## Response Format + +The tool returns results in JSON format: + +```json +{ + "results": [ + { + "content": "Retrieved text content", + "content_type": "text", + "source_type": "S3", + "source_uri": "s3://bucket/document.pdf", + "score": 0.95, + "metadata": { + "additional": "metadata" + } + } + ], + "nextToken": "pagination-token", + "guardrailAction": "NONE" +} +``` + +## Advanced Usage + +### Custom Retrieval Configuration + +```python +kb_tool = BedrockKBRetrieverTool( + knowledge_base_id="your-kb-id", + retrieval_configuration={ + "vectorSearchConfiguration": { + "numberOfResults": 10, + "overrideSearchType": "HYBRID" + } + } +) + +policy_expert = Agent( + role='Policy Expert', + goal='Analyze company policies in detail', + backstory='I am an expert in corporate policy analysis with deep knowledge of regulatory requirements.', + tools=[kb_tool] +) +``` + +## Supported Data Sources + +- Amazon S3 +- Confluence +- Salesforce +- SharePoint +- Web pages +- Custom document locations +- Amazon Kendra +- SQL databases + +## Use Cases + +### Enterprise Knowledge Integration +- Enable CrewAI agents to access your organization's proprietary knowledge without exposing sensitive data +- Allow agents to make decisions based on your company's specific policies, procedures, and documentation +- Create agents that can answer questions based on your internal documentation while maintaining data security + +### Specialized Domain Knowledge +- Connect CrewAI agents to domain-specific knowledge bases (legal, medical, technical) without retraining models +- Leverage existing knowledge repositories that are already maintained in your AWS environment +- Combine CrewAI's reasoning with domain-specific information from your knowledge bases + +### Data-Driven Decision Making +- Ground CrewAI agent responses in your actual company data rather than general knowledge +- Ensure agents provide recommendations based on your specific business context and documentation +- Reduce hallucinations by retrieving factual information from your knowledge bases + +### Scalable Information Access +- Access terabytes of organizational knowledge without embedding it all into your models +- Dynamically query only the relevant information needed for specific tasks +- Leverage AWS's scalable infrastructure to handle large knowledge bases efficiently + +### Compliance and Governance +- Ensure CrewAI agents provide responses that align with your company's approved documentation +- Create auditable trails of information sources used by your agents +- Maintain control over what information sources your agents can access