From c3726092fdf5331bd7d7683f9444768af983d876 Mon Sep 17 00:00:00 2001 From: Vidit Ostwal <110953813+Vidit-Ostwal@users.noreply.github.com> Date: Tue, 6 May 2025 18:37:52 +0530 Subject: [PATCH 1/5] Added Advance Configuration Docs for Rag Tool (#2713) * Added Advance Configuration Docs for Rag Tool * Re-run test cases * Change doc * prepping new version (#2733) --------- Co-authored-by: Lucas Gomide Co-authored-by: Lorenze Jay <63378463+lorenzejay@users.noreply.github.com> --- docs/tools/ragtool.mdx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/tools/ragtool.mdx b/docs/tools/ragtool.mdx index b03059152..b4c074fca 100644 --- a/docs/tools/ragtool.mdx +++ b/docs/tools/ragtool.mdx @@ -143,12 +143,30 @@ config = { "config": { "model": "text-embedding-ada-002" } + }, + "vectordb": { + "provider": "elasticsearch", + "config": { + "collection_name": "my-collection", + "cloud_id": "deployment-name:xxxx", + "api_key": "your-key", + "verify_certs": False + } + }, + "chunker": { + "chunk_size": 400, + "chunk_overlap": 100, + "length_function": "len", + "min_chunk_size": 0 } } rag_tool = RagTool(config=config, summarize=True) ``` -## Conclusion +The internal RAG tool utilizes the Embedchain adapter, allowing you to pass any configuration options that are supported by Embedchain. +You can refer to the [Embedchain documentation](https://docs.embedchain.ai/components/introduction) for details. +Make sure to review the configuration options available in the .yaml file. +## Conclusion The `RagTool` provides a powerful way to create and query knowledge bases from various data sources. By leveraging Retrieval-Augmented Generation, it enables agents to access and retrieve relevant information efficiently, enhancing their ability to provide accurate and contextually appropriate responses. From 836e9fc5450d26eeb4d32ccbecc158da03d5d9b8 Mon Sep 17 00:00:00 2001 From: Mark McDonald Date: Tue, 6 May 2025 21:27:14 +0800 Subject: [PATCH 2/5] Removes model provider defaults from LLM Setup (#2766) This removes any specific model from the "Setting up your LLM" guide, but provides examples for the top-3 providers. This section also conflated "model selection" with "model configuration", where configuration is provider-specific, so I've focused this first section on just model selection, deferring the config to the "provider" section that follows. Co-authored-by: Tony Kipkemboi --- docs/concepts/llms.mdx | 65 +++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 35 deletions(-) diff --git a/docs/concepts/llms.mdx b/docs/concepts/llms.mdx index 560448f21..cefc2705a 100644 --- a/docs/concepts/llms.mdx +++ b/docs/concepts/llms.mdx @@ -27,23 +27,19 @@ Large Language Models (LLMs) are the core intelligence behind CrewAI agents. The -## Setting Up Your LLM +## Setting up your LLM -There are three ways to configure LLMs in CrewAI. Choose the method that best fits your workflow: +There are different places in CrewAI code where you can specify the model to use. Once you specify the model you are using, you will need to provide the configuration (like an API key) for each of the model providers you use. See the [provider configuration examples](#provider-configuration-examples) section for your provider. - The simplest way to get started. Set these variables in your environment: + The simplest way to get started. Set the model in your environment directly, through an `.env` file or in your app code. If you used `crewai create` to bootstrap your project, it will be set already. - ```bash - # Required: Your API key for authentication - OPENAI_API_KEY= + ```bash .env + MODEL=model-id # e.g. gpt-4o, gemini-2.0-flash, claude-3-sonnet-... - # Optional: Default model selection - OPENAI_MODEL_NAME=gpt-4o-mini # Default if not set - - # Optional: Organization ID (if applicable) - OPENAI_ORGANIZATION_ID= + # Be sure to set your API keys here too. See the Provider + # section below. ``` @@ -53,13 +49,13 @@ There are three ways to configure LLMs in CrewAI. Choose the method that best fi Create a YAML file to define your agent configurations. This method is great for version control and team collaboration: - ```yaml + ```yaml agents.yaml {6} researcher: role: Research Specialist goal: Conduct comprehensive research and analysis backstory: A dedicated research professional with years of experience verbose: true - llm: openai/gpt-4o-mini # your model here + llm: provider/model-id # e.g. openai/gpt-4o, google/gemini-2.0-flash, anthropic/claude... # (see provider configuration examples below for more) ``` @@ -74,23 +70,23 @@ There are three ways to configure LLMs in CrewAI. Choose the method that best fi For maximum flexibility, configure LLMs directly in your Python code: - ```python + ```python {4,8} from crewai import LLM # Basic configuration - llm = LLM(model="gpt-4") + llm = LLM(model="model-id-here") # gpt-4o, gemini-2.0-flash, anthropic/claude... # Advanced configuration with detailed parameters llm = LLM( - model="gpt-4o-mini", + model="model-id-here", # gpt-4o, gemini-2.0-flash, anthropic/claude... temperature=0.7, # Higher for more creative outputs - timeout=120, # Seconds to wait for response - max_tokens=4000, # Maximum length of response - top_p=0.9, # Nucleus sampling parameter - frequency_penalty=0.1, # Reduce repetition - presence_penalty=0.1, # Encourage topic diversity + timeout=120, # Seconds to wait for response + max_tokens=4000, # Maximum length of response + top_p=0.9, # Nucleus sampling parameter + frequency_penalty=0.1 , # Reduce repetition + presence_penalty=0.1, # Encourage topic diversity response_format={"type": "json"}, # For structured outputs - seed=42 # For reproducible results + seed=42 # For reproducible results ) ``` @@ -110,7 +106,6 @@ There are three ways to configure LLMs in CrewAI. Choose the method that best fi ## Provider Configuration Examples - CrewAI supports a multitude of LLM providers, each offering unique features, authentication methods, and model capabilities. In this section, you'll find detailed examples that help you select, configure, and optimize the LLM that best fits your project's needs. @@ -407,19 +402,19 @@ In this section, you'll find detailed examples that help you select, configure, - - NVIDIA NIM enables you to run powerful LLMs locally on your Windows machine using WSL2 (Windows Subsystem for Linux). - This approach allows you to leverage your NVIDIA GPU for private, secure, and cost-effective AI inference without relying on cloud services. + + NVIDIA NIM enables you to run powerful LLMs locally on your Windows machine using WSL2 (Windows Subsystem for Linux). + This approach allows you to leverage your NVIDIA GPU for private, secure, and cost-effective AI inference without relying on cloud services. Perfect for development, testing, or production scenarios where data privacy or offline capabilities are required. - + Here is a step-by-step guide to setting up a local NVIDIA NIM model: - + 1. Follow installation instructions from [NVIDIA Website](https://docs.nvidia.com/nim/wsl2/latest/getting-started.html) 2. Install the local model. For Llama 3.1-8b follow [instructions](https://build.nvidia.com/meta/llama-3_1-8b-instruct/deploy) 3. Configure your crewai local models: - + ```python Code from crewai.llm import LLM @@ -441,7 +436,7 @@ In this section, you'll find detailed examples that help you select, configure, config=self.agents_config['researcher'], # type: ignore[index] llm=local_nvidia_nim_llm ) - + # ... ``` @@ -637,19 +632,19 @@ CrewAI supports streaming responses from LLMs, allowing your application to rece When streaming is enabled, responses are delivered in chunks as they're generated, creating a more responsive user experience. - + CrewAI emits events for each chunk received during streaming: - + ```python from crewai import LLM from crewai.utilities.events import EventHandler, LLMStreamChunkEvent - + class MyEventHandler(EventHandler): def on_llm_stream_chunk(self, event: LLMStreamChunkEvent): # Process each chunk as it arrives print(f"Received chunk: {event.chunk}") - + # Register the event handler from crewai.utilities.events import crewai_event_bus crewai_event_bus.register_handler(MyEventHandler()) @@ -785,7 +780,7 @@ Learn how to get the most out of your LLM configuration: Use larger context models for extensive tasks - + ```python # Large context model llm = LLM(model="openai/gpt-4o") # 128K tokens From bfea85d22cae470a31c7ab73001d316192021133 Mon Sep 17 00:00:00 2001 From: Henrique Branco <54143210+HenriqueAJNB@users.noreply.github.com> Date: Tue, 6 May 2025 10:55:05 -0300 Subject: [PATCH 3/5] docs: added Windows bug solving to docs (#2764) Co-authored-by: Tony Kipkemboi --- docs/installation.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/installation.mdx b/docs/installation.mdx index 7c1e09a3b..7a0c8f20c 100644 --- a/docs/installation.mdx +++ b/docs/installation.mdx @@ -71,6 +71,10 @@ If you haven't installed `uv` yet, follow **step 1** to quickly get it set up on ``` + + If you encounter the `chroma-hnswlib==0.7.6` build error (`fatal error C1083: Cannot open include file: 'float.h'`) on Windows, install (Visual Studio Build Tools)[https://visualstudio.microsoft.com/downloads/] with *Desktop development with C++*. + + - To verify that `crewai` is installed, run: ```shell uv tool list From c8ec03424a30d5721aad6d75ac8cfe3c54314699 Mon Sep 17 00:00:00 2001 From: leopardracer <136604165+leopardracer@users.noreply.github.com> Date: Tue, 6 May 2025 22:07:57 +0300 Subject: [PATCH 4/5] Fix typos in documentation and configuration files (#2712) * Update test_lite_agent_structured_output.yaml * Update install_crew.py * Update llms.mdx --------- Co-authored-by: Lucas Gomide --- docs/concepts/llms.mdx | 2 +- src/crewai/cli/install_crew.py | 2 +- tests/cassettes/test_lite_agent_structured_output.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/concepts/llms.mdx b/docs/concepts/llms.mdx index cefc2705a..643ebfe16 100644 --- a/docs/concepts/llms.mdx +++ b/docs/concepts/llms.mdx @@ -378,7 +378,7 @@ In this section, you'll find detailed examples that help you select, configure, | microsoft/phi-3-medium-4k-instruct | 4,096 tokens | Lightweight, state-of-the-art open LLM with strong math and logical reasoning skills. | | microsoft/phi-3-medium-128k-instruct | 128K tokens | Lightweight, state-of-the-art open LLM with strong math and logical reasoning skills. | | microsoft/phi-3.5-mini-instruct | 128K tokens | Lightweight multilingual LLM powering AI applications in latency bound, memory/compute constrained environments | - | microsoft/phi-3.5-moe-instruct | 128K tokens | Advanced LLM based on Mixture of Experts architecure to deliver compute efficient content generation | + | microsoft/phi-3.5-moe-instruct | 128K tokens | Advanced LLM based on Mixture of Experts architecture to deliver compute efficient content generation | | microsoft/kosmos-2 | 1,024 tokens | Groundbreaking multimodal model designed to understand and reason about visual elements in images. | | microsoft/phi-3-vision-128k-instruct | 128k tokens | Cutting-edge open multimodal model exceling in high-quality reasoning from images. | | microsoft/phi-3.5-vision-instruct | 128k tokens | Cutting-edge open multimodal model exceling in high-quality reasoning from images. | diff --git a/src/crewai/cli/install_crew.py b/src/crewai/cli/install_crew.py index 9491932f1..bd0f35879 100644 --- a/src/crewai/cli/install_crew.py +++ b/src/crewai/cli/install_crew.py @@ -4,7 +4,7 @@ import click # Be mindful about changing this. -# on some enviorments we don't use this command but instead uv sync directly +# on some environments we don't use this command but instead uv sync directly # so if you expect this to support more things you will need to replicate it there # ask @joaomdmoura if you are unsure def install_crew(proxy_options: list[str]) -> None: diff --git a/tests/cassettes/test_lite_agent_structured_output.yaml b/tests/cassettes/test_lite_agent_structured_output.yaml index de3885cdd..86718712f 100644 --- a/tests/cassettes/test_lite_agent_structured_output.yaml +++ b/tests/cassettes/test_lite_agent_structured_output.yaml @@ -16,7 +16,7 @@ interactions: answer MUST contain all the information requested in the following format: {\n \"summary\": str,\n \"confidence\": int\n}\n\nIMPORTANT: Ensure the final output does not include any code block markers like ```json or ```python."}, {"role": "user", - "content": "What is the population of Tokyo? Return your strucutred output in + "content": "What is the population of Tokyo? Return your structured output in JSON format with the following fields: summary, confidence"}], "model": "gpt-4o-mini", "stop": []}' headers: From cac06adc6cbd20a2ac0d77a15c6daa106c817de4 Mon Sep 17 00:00:00 2001 From: Tony Kipkemboi Date: Tue, 6 May 2025 17:14:05 -0400 Subject: [PATCH 5/5] docs: update docxsearchtool.mdx (#2767) - add `docx2txt` as a dependency requirement for the tool --- docs/tools/docxsearchtool.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tools/docxsearchtool.mdx b/docs/tools/docxsearchtool.mdx index c3a501dc6..9e7ebee44 100644 --- a/docs/tools/docxsearchtool.mdx +++ b/docs/tools/docxsearchtool.mdx @@ -22,7 +22,7 @@ streamlining the process of finding specific information within large document c Install the crewai_tools package by running the following command in your terminal: ```shell -pip install 'crewai[tools]' +uv pip install docx2txt 'crewai[tools]' ``` ## Example @@ -76,4 +76,4 @@ tool = DOCXSearchTool( ), ) ) -``` \ No newline at end of file +```