From 3aa48dcd588dcfa8681e7309213fbdffaa4456fe Mon Sep 17 00:00:00 2001 From: Gustavo Satheler Date: Fri, 21 Mar 2025 13:32:54 -0300 Subject: [PATCH 01/10] fix: move agent tools for a variable instead of use format (#2319) Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com> --- src/crewai/utilities/planning_handler.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/crewai/utilities/planning_handler.py b/src/crewai/utilities/planning_handler.py index 6ce74f236..1bd14a0c8 100644 --- a/src/crewai/utilities/planning_handler.py +++ b/src/crewai/utilities/planning_handler.py @@ -96,6 +96,10 @@ class CrewPlanner: tasks_summary = [] for idx, task in enumerate(self.tasks): knowledge_list = self._get_agent_knowledge(task) + agent_tools = ( + f"[{', '.join(str(tool) for tool in task.agent.tools)}]" if task.agent and task.agent.tools else '"agent has no tools"', + f',\n "agent_knowledge": "[\\"{knowledge_list[0]}\\"]"' if knowledge_list and str(knowledge_list) != "None" else "" + ) task_summary = f""" Task Number {idx + 1} - {task.description} "task_description": {task.description} @@ -103,10 +107,7 @@ class CrewPlanner: "agent": {task.agent.role if task.agent else "None"} "agent_goal": {task.agent.goal if task.agent else "None"} "task_tools": {task.tools} - "agent_tools": %s%s""" % ( - f"[{', '.join(str(tool) for tool in task.agent.tools)}]" if task.agent and task.agent.tools else '"agent has no tools"', - f',\n "agent_knowledge": "[\\"{knowledge_list[0]}\\"]"' if knowledge_list and str(knowledge_list) != "None" else "" - ) + "agent_tools": {"".join(agent_tools)}""" tasks_summary.append(task_summary) return " ".join(tasks_summary) From 32da76a2ca644d8472d0778c1b522b83928b9bd1 Mon Sep 17 00:00:00 2001 From: Jorge Gonzalez Date: Fri, 21 Mar 2025 13:17:43 -0400 Subject: [PATCH 02/10] Use task in the note about how methods names need to match task names (#2355) The note is about the task but mentions the agent incorrectly. Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com> --- docs/quickstart.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quickstart.mdx b/docs/quickstart.mdx index df57f756f..1edccee0e 100644 --- a/docs/quickstart.mdx +++ b/docs/quickstart.mdx @@ -300,7 +300,7 @@ email_summarizer: ``` - Note how we use the same name for the agent in the `tasks.yaml` (`email_summarizer_task`) file as the method name in the `crew.py` (`email_summarizer_task`) file. + Note how we use the same name for the task in the `tasks.yaml` (`email_summarizer_task`) file as the method name in the `crew.py` (`email_summarizer_task`) file. ```yaml tasks.yaml From 80f1a88b6356371ca622b74f80adf0cf62108661 Mon Sep 17 00:00:00 2001 From: Patcher Date: Fri, 21 Mar 2025 22:56:50 +0530 Subject: [PATCH 03/10] Upgrade OTel SDK version to 1.30.0 (#2375) Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com> --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2e319e8d0..6e895be32 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,9 +17,9 @@ dependencies = [ "pdfplumber>=0.11.4", "regex>=2024.9.11", # Telemetry and Monitoring - "opentelemetry-api>=1.22.0", - "opentelemetry-sdk>=1.22.0", - "opentelemetry-exporter-otlp-proto-http>=1.22.0", + "opentelemetry-api>=1.30.0", + "opentelemetry-sdk>=1.30.0", + "opentelemetry-exporter-otlp-proto-http>=1.30.0", # Data Handling "chromadb>=0.5.23", "openpyxl>=3.1.5", From 6b1cf78e410776ca2e3ac0a9a399c20cb9ed7753 Mon Sep 17 00:00:00 2001 From: Julio Peixoto <96303574+JulioPeixoto@users.noreply.github.com> Date: Fri, 21 Mar 2025 14:34:16 -0300 Subject: [PATCH 04/10] docs: add detailed docstrings to Telemetry class methods (#2377) Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com> --- src/crewai/telemetry/telemetry.py | 80 +++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 4 deletions(-) diff --git a/src/crewai/telemetry/telemetry.py b/src/crewai/telemetry/telemetry.py index 984a4938d..559ca8d4f 100644 --- a/src/crewai/telemetry/telemetry.py +++ b/src/crewai/telemetry/telemetry.py @@ -281,8 +281,16 @@ class Telemetry: return self._safe_telemetry_operation(operation) def task_ended(self, span: Span, task: Task, crew: Crew): - """Records task execution in a crew.""" + """Records the completion of a task execution in a crew. + Args: + span (Span): The OpenTelemetry span tracking the task execution + task (Task): The task that was completed + crew (Crew): The crew context in which the task was executed + + Note: + If share_crew is enabled, this will also record the task output + """ def operation(): if crew.share_crew: self._add_attribute( @@ -297,8 +305,13 @@ class Telemetry: self._safe_telemetry_operation(operation) def tool_repeated_usage(self, llm: Any, tool_name: str, attempts: int): - """Records the repeated usage 'error' of a tool by an agent.""" + """Records when a tool is used repeatedly, which might indicate an issue. + Args: + llm (Any): The language model being used + tool_name (str): Name of the tool being repeatedly used + attempts (int): Number of attempts made with this tool + """ def operation(): tracer = trace.get_tracer("crewai.telemetry") span = tracer.start_span("Tool Repeated Usage") @@ -317,8 +330,13 @@ class Telemetry: self._safe_telemetry_operation(operation) def tool_usage(self, llm: Any, tool_name: str, attempts: int): - """Records the usage of a tool by an agent.""" + """Records the usage of a tool by an agent. + Args: + llm (Any): The language model being used + tool_name (str): Name of the tool being used + attempts (int): Number of attempts made with this tool + """ def operation(): tracer = trace.get_tracer("crewai.telemetry") span = tracer.start_span("Tool Usage") @@ -337,8 +355,11 @@ class Telemetry: self._safe_telemetry_operation(operation) def tool_usage_error(self, llm: Any): - """Records the usage of a tool by an agent.""" + """Records when a tool usage results in an error. + Args: + llm (Any): The language model being used when the error occurred + """ def operation(): tracer = trace.get_tracer("crewai.telemetry") span = tracer.start_span("Tool Usage Error") @@ -357,6 +378,14 @@ class Telemetry: def individual_test_result_span( self, crew: Crew, quality: float, exec_time: int, model_name: str ): + """Records individual test results for a crew execution. + + Args: + crew (Crew): The crew being tested + quality (float): Quality score of the execution + exec_time (int): Execution time in seconds + model_name (str): Name of the model used + """ def operation(): tracer = trace.get_tracer("crewai.telemetry") span = tracer.start_span("Crew Individual Test Result") @@ -383,6 +412,14 @@ class Telemetry: inputs: dict[str, Any] | None, model_name: str, ): + """Records the execution of a test suite for a crew. + + Args: + crew (Crew): The crew being tested + iterations (int): Number of test iterations + inputs (dict[str, Any] | None): Input parameters for the test + model_name (str): Name of the model used in testing + """ def operation(): tracer = trace.get_tracer("crewai.telemetry") span = tracer.start_span("Crew Test Execution") @@ -408,6 +445,7 @@ class Telemetry: self._safe_telemetry_operation(operation) def deploy_signup_error_span(self): + """Records when an error occurs during the deployment signup process.""" def operation(): tracer = trace.get_tracer("crewai.telemetry") span = tracer.start_span("Deploy Signup Error") @@ -417,6 +455,11 @@ class Telemetry: self._safe_telemetry_operation(operation) def start_deployment_span(self, uuid: Optional[str] = None): + """Records the start of a deployment process. + + Args: + uuid (Optional[str]): Unique identifier for the deployment + """ def operation(): tracer = trace.get_tracer("crewai.telemetry") span = tracer.start_span("Start Deployment") @@ -428,6 +471,7 @@ class Telemetry: self._safe_telemetry_operation(operation) def create_crew_deployment_span(self): + """Records the creation of a new crew deployment.""" def operation(): tracer = trace.get_tracer("crewai.telemetry") span = tracer.start_span("Create Crew Deployment") @@ -437,6 +481,12 @@ class Telemetry: self._safe_telemetry_operation(operation) def get_crew_logs_span(self, uuid: Optional[str], log_type: str = "deployment"): + """Records the retrieval of crew logs. + + Args: + uuid (Optional[str]): Unique identifier for the crew + log_type (str, optional): Type of logs being retrieved. Defaults to "deployment". + """ def operation(): tracer = trace.get_tracer("crewai.telemetry") span = tracer.start_span("Get Crew Logs") @@ -449,6 +499,11 @@ class Telemetry: self._safe_telemetry_operation(operation) def remove_crew_span(self, uuid: Optional[str] = None): + """Records the removal of a crew. + + Args: + uuid (Optional[str]): Unique identifier for the crew being removed + """ def operation(): tracer = trace.get_tracer("crewai.telemetry") span = tracer.start_span("Remove Crew") @@ -574,6 +629,11 @@ class Telemetry: self._safe_telemetry_operation(operation) def flow_creation_span(self, flow_name: str): + """Records the creation of a new flow. + + Args: + flow_name (str): Name of the flow being created + """ def operation(): tracer = trace.get_tracer("crewai.telemetry") span = tracer.start_span("Flow Creation") @@ -584,6 +644,12 @@ class Telemetry: self._safe_telemetry_operation(operation) def flow_plotting_span(self, flow_name: str, node_names: list[str]): + """Records flow visualization/plotting activity. + + Args: + flow_name (str): Name of the flow being plotted + node_names (list[str]): List of node names in the flow + """ def operation(): tracer = trace.get_tracer("crewai.telemetry") span = tracer.start_span("Flow Plotting") @@ -595,6 +661,12 @@ class Telemetry: self._safe_telemetry_operation(operation) def flow_execution_span(self, flow_name: str, node_names: list[str]): + """Records the execution of a flow. + + Args: + flow_name (str): Name of the flow being executed + node_names (list[str]): List of nodes being executed in the flow + """ def operation(): tracer = trace.get_tracer("crewai.telemetry") span = tracer.start_span("Flow Execution") From 4d7aacb5f243aed4426914982506518126772f01 Mon Sep 17 00:00:00 2001 From: Saurabh Misra Date: Fri, 21 Mar 2025 10:43:48 -0700 Subject: [PATCH 05/10] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Speed=20up=20method?= =?UTF-8?q?=20`Repository.is=5Fgit=5Frepo`=20by=2072,270%=20(#2381)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Here is the optimized version of the `Repository` class. Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com> Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com> --- src/crewai/cli/git.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/crewai/cli/git.py b/src/crewai/cli/git.py index 94c3648b0..58836e733 100644 --- a/src/crewai/cli/git.py +++ b/src/crewai/cli/git.py @@ -1,4 +1,5 @@ import subprocess +from functools import lru_cache class Repository: @@ -35,6 +36,7 @@ class Repository: encoding="utf-8", ).strip() + @lru_cache(maxsize=None) def is_git_repo(self) -> bool: """Check if the current directory is a git repository.""" try: From d3a09c3180e86fc1d73492660627f0a39e6d4b2c Mon Sep 17 00:00:00 2001 From: Saurabh Misra Date: Fri, 21 Mar 2025 10:51:14 -0700 Subject: [PATCH 06/10] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Speed=20up=20method?= =?UTF-8?q?=20`CrewAgentParser.=5Fclean=5Faction`=20by=20427,565%=20(#2382?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Here is the optimized version of the program. Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com> Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com> --- src/crewai/agents/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crewai/agents/parser.py b/src/crewai/agents/parser.py index 05c5bc003..88a869c16 100644 --- a/src/crewai/agents/parser.py +++ b/src/crewai/agents/parser.py @@ -136,7 +136,7 @@ class CrewAgentParser: def _clean_action(self, text: str) -> str: """Clean action string by removing non-essential formatting characters.""" - return re.sub(r"^\s*\*+\s*|\s*\*+\s*$", "", text).strip() + return text.strip().strip("*").strip() def _safe_repair_json(self, tool_input: str) -> str: UNABLE_TO_REPAIR_JSON_RESULTS = ['""', "{}"] From 53067f8b9290986f22e2ef94eb92e5df1c24fb66 Mon Sep 17 00:00:00 2001 From: Parth Patel <64201651+parthbs@users.noreply.github.com> Date: Fri, 21 Mar 2025 23:27:24 +0530 Subject: [PATCH 07/10] add Mem0 OSS support (#2429) Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com> --- src/crewai/memory/storage/mem0_storage.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/crewai/memory/storage/mem0_storage.py b/src/crewai/memory/storage/mem0_storage.py index be889afff..0319c6a8a 100644 --- a/src/crewai/memory/storage/mem0_storage.py +++ b/src/crewai/memory/storage/mem0_storage.py @@ -1,7 +1,7 @@ import os from typing import Any, Dict, List -from mem0 import MemoryClient +from mem0 import Memory, MemoryClient from crewai.memory.storage.interface import Storage @@ -32,13 +32,16 @@ class Mem0Storage(Storage): mem0_org_id = config.get("org_id") mem0_project_id = config.get("project_id") - # Initialize MemoryClient with available parameters - if mem0_org_id and mem0_project_id: - self.memory = MemoryClient( - api_key=mem0_api_key, org_id=mem0_org_id, project_id=mem0_project_id - ) + # Initialize MemoryClient or Memory based on the presence of the mem0_api_key + if mem0_api_key: + if mem0_org_id and mem0_project_id: + self.memory = MemoryClient( + api_key=mem0_api_key, org_id=mem0_org_id, project_id=mem0_project_id + ) + else: + self.memory = MemoryClient(api_key=mem0_api_key) else: - self.memory = MemoryClient(api_key=mem0_api_key) + self.memory = Memory() # Fallback to Memory if no Mem0 API key is provided def _sanitize_role(self, role: str) -> str: """ From 4daa88fa59f22e77c5ba83b2c457c9ab0de9c9b0 Mon Sep 17 00:00:00 2001 From: Stefano Baccianella <4247706+mangiucugna@users.noreply.github.com> Date: Fri, 21 Mar 2025 19:25:19 +0100 Subject: [PATCH 08/10] As explained in https://github.com/mangiucugna/json_repair?tab=readme-ov-file#performance-considerations we can skip a wasteful json.loads() here and save quite some time (#2397) Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com> Co-authored-by: Lorenze Jay <63378463+lorenzejay@users.noreply.github.com> --- src/crewai/tools/tool_usage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crewai/tools/tool_usage.py b/src/crewai/tools/tool_usage.py index 25e4b126a..9c924027d 100644 --- a/src/crewai/tools/tool_usage.py +++ b/src/crewai/tools/tool_usage.py @@ -455,7 +455,7 @@ class ToolUsage: # Attempt 4: Repair JSON try: - repaired_input = repair_json(tool_input) + repaired_input = repair_json(tool_input, skip_json_loads=True) self._printer.print( content=f"Repaired JSON: {repaired_input}", color="blue" ) From 0a116202f04a8438404c2c3bcfaa4fde812f6917 Mon Sep 17 00:00:00 2001 From: Fernando Galves <157684778+cardofe@users.noreply.github.com> Date: Fri, 21 Mar 2025 19:48:25 +0100 Subject: [PATCH 09/10] Update the context window size for Amazon Bedrock FM- llm.py (#2304) Update the context window size for Amazon Bedrock Foundation Models. Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com> Co-authored-by: Lorenze Jay <63378463+lorenzejay@users.noreply.github.com> --- src/crewai/llm.py | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/crewai/llm.py b/src/crewai/llm.py index fb8367dfe..68ddbacc7 100644 --- a/src/crewai/llm.py +++ b/src/crewai/llm.py @@ -114,6 +114,60 @@ LLM_CONTEXT_WINDOW_SIZES = { "Llama-3.2-11B-Vision-Instruct": 16384, "Meta-Llama-3.2-3B-Instruct": 4096, "Meta-Llama-3.2-1B-Instruct": 16384, + # bedrock + "us.amazon.nova-pro-v1:0": 300000, + "us.amazon.nova-micro-v1:0": 128000, + "us.amazon.nova-lite-v1:0": 300000, + "us.anthropic.claude-3-5-sonnet-20240620-v1:0": 200000, + "us.anthropic.claude-3-5-haiku-20241022-v1:0": 200000, + "us.anthropic.claude-3-5-sonnet-20241022-v2:0": 200000, + "us.anthropic.claude-3-7-sonnet-20250219-v1:0": 200000, + "us.anthropic.claude-3-sonnet-20240229-v1:0": 200000, + "us.anthropic.claude-3-opus-20240229-v1:0": 200000, + "us.anthropic.claude-3-haiku-20240307-v1:0": 200000, + "us.meta.llama3-2-11b-instruct-v1:0": 128000, + "us.meta.llama3-2-3b-instruct-v1:0": 131000, + "us.meta.llama3-2-90b-instruct-v1:0": 128000, + "us.meta.llama3-2-1b-instruct-v1:0": 131000, + "us.meta.llama3-1-8b-instruct-v1:0": 128000, + "us.meta.llama3-1-70b-instruct-v1:0": 128000, + "us.meta.llama3-3-70b-instruct-v1:0": 128000, + "us.meta.llama3-1-405b-instruct-v1:0": 128000, + "eu.anthropic.claude-3-5-sonnet-20240620-v1:0": 200000, + "eu.anthropic.claude-3-sonnet-20240229-v1:0": 200000, + "eu.anthropic.claude-3-haiku-20240307-v1:0": 200000, + "eu.meta.llama3-2-3b-instruct-v1:0": 131000, + "eu.meta.llama3-2-1b-instruct-v1:0": 131000, + "apac.anthropic.claude-3-5-sonnet-20240620-v1:0": 200000, + "apac.anthropic.claude-3-5-sonnet-20241022-v2:0": 200000, + "apac.anthropic.claude-3-sonnet-20240229-v1:0": 200000, + "apac.anthropic.claude-3-haiku-20240307-v1:0": 200000, + "amazon.nova-pro-v1:0": 300000, + "amazon.nova-micro-v1:0": 128000, + "amazon.nova-lite-v1:0": 300000, + "anthropic.claude-3-5-sonnet-20240620-v1:0": 200000, + "anthropic.claude-3-5-haiku-20241022-v1:0": 200000, + "anthropic.claude-3-5-sonnet-20241022-v2:0": 200000, + "anthropic.claude-3-7-sonnet-20250219-v1:0": 200000, + "anthropic.claude-3-sonnet-20240229-v1:0": 200000, + "anthropic.claude-3-opus-20240229-v1:0": 200000, + "anthropic.claude-3-haiku-20240307-v1:0": 200000, + "anthropic.claude-v2:1": 200000, + "anthropic.claude-v2": 100000, + "anthropic.claude-instant-v1": 100000, + "meta.llama3-1-405b-instruct-v1:0": 128000, + "meta.llama3-1-70b-instruct-v1:0": 128000, + "meta.llama3-1-8b-instruct-v1:0": 128000, + "meta.llama3-70b-instruct-v1:0": 8000, + "meta.llama3-8b-instruct-v1:0": 8000, + "amazon.titan-text-lite-v1": 4000, + "amazon.titan-text-express-v1": 8000, + "cohere.command-text-v14": 4000, + "ai21.j2-mid-v1": 8191, + "ai21.j2-ultra-v1": 8191, + "ai21.jamba-instruct-v1:0": 256000, + "mistral.mistral-7b-instruct-v0:2": 32000, + "mistral.mixtral-8x7b-instruct-v0:1": 32000, # mistral "mistral-tiny": 32768, "mistral-small-latest": 32768, From bb3829a9ed4886da7a284bc89fc8bd7eda168ce2 Mon Sep 17 00:00:00 2001 From: Matisse <54796148+AMatisse@users.noreply.github.com> Date: Fri, 21 Mar 2025 15:12:26 -0400 Subject: [PATCH 10/10] docs: Update model reference in LLM configuration (#2267) Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com> --- docs/concepts/llms.mdx | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/docs/concepts/llms.mdx b/docs/concepts/llms.mdx index e17098f6a..2aada5fac 100644 --- a/docs/concepts/llms.mdx +++ b/docs/concepts/llms.mdx @@ -59,7 +59,7 @@ There are three ways to configure LLMs in CrewAI. Choose the method that best fi 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: openai/gpt-4o-mini # your model here # (see provider configuration examples below for more) ``` @@ -111,7 +111,7 @@ 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. +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. @@ -121,7 +121,7 @@ In this section, you'll find detailed examples that help you select, configure, ```toml Code # Required OPENAI_API_KEY=sk-... - + # Optional OPENAI_API_BASE= OPENAI_ORGANIZATION= @@ -226,7 +226,7 @@ In this section, you'll find detailed examples that help you select, configure, AZURE_API_KEY= AZURE_API_BASE= AZURE_API_VERSION= - + # Optional AZURE_AD_TOKEN= AZURE_API_TYPE= @@ -289,7 +289,7 @@ In this section, you'll find detailed examples that help you select, configure, | Mistral 8x7B Instruct | Up to 32k tokens | An MOE LLM that follows instructions, completes requests, and generates creative text. | - + ```toml Code AWS_ACCESS_KEY_ID= @@ -474,7 +474,7 @@ In this section, you'll find detailed examples that help you select, configure, WATSONX_URL= WATSONX_APIKEY= WATSONX_PROJECT_ID= - + # Optional WATSONX_TOKEN= WATSONX_DEPLOYMENT_SPACE_ID= @@ -491,7 +491,7 @@ In this section, you'll find detailed examples that help you select, configure, 1. Install Ollama: [ollama.ai](https://ollama.ai/) - 2. Run a model: `ollama run llama2` + 2. Run a model: `ollama run llama3` 3. Configure: ```python Code @@ -600,7 +600,7 @@ In this section, you'll find detailed examples that help you select, configure, ```toml Code OPENROUTER_API_KEY= ``` - + Example usage in your CrewAI project: ```python Code llm = LLM( @@ -723,7 +723,7 @@ Learn how to get the most out of your LLM configuration: - Small tasks (up to 4K tokens): Standard models - Medium tasks (between 4K-32K): Enhanced models - Large tasks (over 32K): Large context models - + ```python # Configure model with appropriate settings llm = LLM( @@ -760,11 +760,11 @@ Learn how to get the most out of your LLM configuration: Most authentication issues can be resolved by checking API key format and environment variable names. - + ```bash # OpenAI OPENAI_API_KEY=sk-... - + # Anthropic ANTHROPIC_API_KEY=sk-ant-... ``` @@ -773,11 +773,11 @@ Learn how to get the most out of your LLM configuration: Always include the provider prefix in model names - + ```python # Correct llm = LLM(model="openai/gpt-4") - + # Incorrect llm = LLM(model="gpt-4") ``` @@ -786,5 +786,10 @@ 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 + ```