From c78237cb8675ef0c8f5583c367d9993e8f5ab0dc Mon Sep 17 00:00:00 2001 From: Gui Vieira Date: Fri, 2 Feb 2024 13:56:35 -0300 Subject: [PATCH] Hierarchical process (#206) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Hierarchical process + Docs Co-authored-by: João Moura --- README.md | 4 +- docs/core-concepts/Managing-Processes.md | 55 +- src/crewai/agent.py | 9 +- src/crewai/crew.py | 58 +- src/crewai/process.py | 2 +- src/crewai/task.py | 12 +- src/crewai/tools/agent_tools.py | 6 +- src/crewai/translations/el.json | 5 + src/crewai/translations/en.json | 7 +- .../cassettes/test_hierarchical_process.yaml | 1210 +++++++++++++++++ tests/crew_test.py | 33 + tests/task_test.py | 31 +- 12 files changed, 1358 insertions(+), 74 deletions(-) create mode 100644 tests/cassettes/test_hierarchical_process.yaml diff --git a/README.md b/README.md index e123fd6a4..1e393f5e9 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ print("######################") print(result) ``` -Currently the only supported process is `Process.sequential`, where one task is executed after the other and the outcome of one is passed as extra content into this next. +In addition to the sequential process, you can use the hierarchical process, which automatically assigns a manager to the defined crew to properly coordinate the planning and execution of tasks through delegation and validation of results. See more about the processes [here](./docs/core-concepts/Managing-Processes.md) ## Key Features @@ -138,7 +138,7 @@ Currently the only supported process is `Process.sequential`, where one task is - **Role-Based Agent Design**: Customize agents with specific roles, goals, and tools. - **Autonomous Inter-Agent Delegation**: Agents can autonomously delegate tasks and inquire amongst themselves, enhancing problem-solving efficiency. - **Flexible Task Management**: Define tasks with customizable tools and assign them to agents dynamically. -- **Processes Driven**: Currently only supports `sequential` task execution but more complex processes like consensual and hierarchical being worked on. +- **Processes Driven**: Currently only supports `sequential` task execution and `hierarchical` processes, but more complex processes like consensual and autonomous are being worked on. - **Works with Open Source Models**: Run your crew using Open AI or open source models refer to the [Connect crewAI to LLMs](./docs/llm-connections.md) page for details on configuring you agents' connections to models, even ones running locally! ![CrewAI Mind Map](./docs/crewAI-mindmap.png "CrewAI Mind Map") diff --git a/docs/core-concepts/Managing-Processes.md b/docs/core-concepts/Managing-Processes.md index 5d1130d3e..3f75dc003 100644 --- a/docs/core-concepts/Managing-Processes.md +++ b/docs/core-concepts/Managing-Processes.md @@ -8,42 +8,37 @@ A process in CrewAI can be thought of as the game plan for how your AI agents wi ## Process Implementations -- **Sequential (Supported)**: This is the only process currently implemented in CrewAI. It ensures tasks are handled one at a time, in a given order, much like a relay race where one runner passes the baton to the next. +- **Sequential (Supported)**: This process ensures tasks are handled one at a time, in a given order, much like a relay race where one runner passes the baton to the next. +- **Hierarchical**: This process introduces a chain of command to task execution. You define the crew and the system assigns a manager to properly coordinate the planning and execution of tasks through delegation and validation of results, akin to a traditional corporate hierarchy. - **Consensual (WIP)**: Envisioned for a future update, the consensual process will enable agents to make joint decisions on task execution, similar to a team consensus in a meeting before proceeding. -- **Hierarchical (WIP)**: Also in the pipeline, this process will introduce a chain of command to task execution, where some agents may have the authority to prioritize tasks or delegate them, akin to a traditional corporate hierarchy. These additional processes, once implemented, will offer more nuanced and sophisticated ways for agents to interact and complete tasks, much like teams in complex organizational structures. - -## Defining a Sequential Process - -Creating a sequential process in CrewAI is straightforward and reflects the simplicity of coordinating a team's efforts step by step. In this process the outcome of the previous task is sent into the next one as context that I should use to accomplish it's task - -```python -from crewai import Process - -# Define a sequential process -sequential_process = Process.sequential -``` - -# The Magic of Sequential Processes - -The sequential process is where much of CrewAI's magic happens. It ensures that tasks are approached with the same thoughtful progression that a human team would use, fostering a natural and logical flow of work while passing on task outcome into the next. - -## Assigning Processes to a Crew - -To assign a process to a crew, simply set it during the crew's creation. The process will dictate the crew's approach to task execution. - -```python -from crewai import Crew - -# Create a crew with a sequential process -crew = Crew(agents=my_agents, tasks=my_tasks, process=sequential_process) -``` - ## The Role of Processes in Teamwork The process you choose for your crew is critical. It's what transforms a group of individual agents into a cohesive unit that can tackle complex projects with the precision and harmony you'd find in a team of skilled humans. +## Assigning Processes to a Crew + +To assign a process to a crew, simply set it during the crew's creation. The process will dictate the crew's approach to task execution. Different from the sequential process, you don't need to assign an agent to a task. + +```python +from crewai import Crew +from crewai.process import Process + +# Create a crew with a sequential process +crew = Crew(agents=my_agents, tasks=my_tasks, process=Process.sequential) +# OR create a crew with a hierarchical process +crew = Crew(agents=my_agents, tasks=my_tasks, process=Process.hierarchical) +``` + +## Sequential Process + +The sequential process is where much of CrewAI's magic happens. It ensures that tasks are approached with the same thoughtful progression that a human team would use, fostering a natural and logical flow of work while passing on task outcome into the next. + +## Hierarchical Process + +The hierarchical process is tiny bit more magic, as the chain of command and task assignment is hidden from the user. The system will automatically assign a manager the execute the tasks, but the agent will never execute the job by itself. Instead, the manager will plan the steps to execute the task and delegate the work to the agents. The agents will then execute the task and report back to the manager, who will validate the results and pass the task outcome to the next task. + ## Conclusion -Processes bring structure and order to the CrewAI ecosystem, allowing agents to collaborate effectively and accomplish goals systematically. As CrewAI evolves, additional process types will be introduced to enhance the framework's versatility, much like a team that grows and adapts over time. \ No newline at end of file +Processes bring structure and order to the CrewAI ecosystem, allowing agents to collaborate effectively and accomplish goals systematically. As CrewAI evolves, additional process types will be introduced to enhance the framework's versatility, much like a team that grows and adapts over time. diff --git a/src/crewai/agent.py b/src/crewai/agent.py index 78a661913..b5ba57a2a 100644 --- a/src/crewai/agent.py +++ b/src/crewai/agent.py @@ -1,13 +1,12 @@ import uuid from typing import Any, List, Optional -from langchain.agents.format_scratchpad import format_log_to_str from langchain.agents.agent import RunnableAgent +from langchain.agents.format_scratchpad import format_log_to_str from langchain.memory import ConversationSummaryMemory from langchain.tools.render import render_text_description from langchain_core.runnables.config import RunnableConfig from langchain_openai import ChatOpenAI -from langchain_core.language_models import BaseLanguageModel from pydantic import ( UUID4, BaseModel, @@ -171,7 +170,7 @@ class Agent(BaseModel): """ self.cache_handler = cache_handler self.tools_handler = ToolsHandler(cache=self.cache_handler) - self.__create_agent_executor() + self._create_agent_executor() def set_rpm_controller(self, rpm_controller: RPMController) -> None: """Set the rpm controller for the agent. @@ -181,9 +180,9 @@ class Agent(BaseModel): """ if not self._rpm_controller: self._rpm_controller = rpm_controller - self.__create_agent_executor() + self._create_agent_executor() - def __create_agent_executor(self) -> None: + def _create_agent_executor(self) -> None: """Create an agent executor for the agent. Returns: diff --git a/src/crewai/crew.py b/src/crewai/crew.py index ded7aa7ce..b41e8a81e 100644 --- a/src/crewai/crew.py +++ b/src/crewai/crew.py @@ -142,18 +142,26 @@ class Crew(BaseModel): agent.i18n = I18N(language=self.language) if self.process == Process.sequential: - return self._sequential_loop() - else: - raise NotImplementedError( - f"The process '{self.process}' is not implemented yet." - ) + return self._run_sequential_process() + if self.process == Process.hierarchical: + return self._run_hierarchical_process() - def _sequential_loop(self) -> str: + raise NotImplementedError( + f"The process '{self.process}' is not implemented yet." + ) + + def _run_sequential_process(self) -> str: """Executes tasks sequentially and returns the final output.""" task_output = "" for task in self.tasks: - self._prepare_and_execute_task(task) - task_output = task.execute(task_output) + if task.agent is not None and task.agent.allow_delegation: + task.tools += AgentTools(agents=self.agents).tools() + + role = task.agent.role if task.agent is not None else "None" + self._logger.log("debug", f"Working Agent: {role}") + self._logger.log("info", f"Starting Task: {task.description}") + + task_output = task.execute(context=task_output) role = task.agent.role if task.agent is not None else "None" self._logger.log("debug", f"[{role}] Task output: {task_output}\n\n") @@ -163,15 +171,29 @@ class Crew(BaseModel): return task_output - def _prepare_and_execute_task(self, task: Task) -> None: - """Prepares and logs information about the task being executed. + def _run_hierarchical_process(self) -> str: + """Creates and assigns a manager agent to make sure the crew completes the tasks.""" - Args: - task: The task to be executed. - """ - if task.agent is not None and task.agent.allow_delegation: - task.tools += AgentTools(agents=self.agents).tools() + i18n = I18N(language=self.language) + manager = Agent( + role=i18n.retrieve("hierarchical_manager_agent", "role"), + goal=i18n.retrieve("hierarchical_manager_agent", "goal"), + backstory=i18n.retrieve("hierarchical_manager_agent", "backstory"), + tools=AgentTools(agents=self.agents).tools(), + verbose=True, + ) - role = task.agent.role if task.agent is not None else "None" - self._logger.log("debug", f"Working Agent: {role}") - self._logger.log("info", f"Starting Task: {task.description}") + task_output = "" + for task in self.tasks: + self._logger.log("info", f"Starting Task: {task.description}") + + task_output = task.execute(agent=manager, context=task_output) + + self._logger.log( + "debug", f"[{manager.role}] Task output: {task_output}\n\n" + ) + + if self.max_rpm: + self._rpm_controller.stop_rpm_counter() + + return task_output diff --git a/src/crewai/process.py b/src/crewai/process.py index d6f511a1a..2311c0e45 100644 --- a/src/crewai/process.py +++ b/src/crewai/process.py @@ -7,5 +7,5 @@ class Process(str, Enum): """ sequential = "sequential" + hierarchical = "hierarchical" # TODO: consensual = 'consensual' - # TODO: hierarchical = 'hierarchical' diff --git a/src/crewai/task.py b/src/crewai/task.py index 579a144ae..8c608f870 100644 --- a/src/crewai/task.py +++ b/src/crewai/task.py @@ -19,7 +19,7 @@ class Task(BaseModel): description="Callback to be executed after the task is completed.", default=None ) agent: Optional[Agent] = Field( - description="Agent responsible for executiong the task.", default=None + description="Agent responsible for execution the task.", default=None ) expected_output: Optional[str] = Field( description="Clear definition of expected output for the task.", @@ -53,18 +53,20 @@ class Task(BaseModel): self.tools.extend(self.agent.tools) return self - def execute(self, context: Optional[str] = None) -> str: + def execute(self, agent: Agent | None = None, context: Optional[str] = None) -> str: """Execute the task. Returns: Output of the task. """ - if not self.agent: + + agent = agent or self.agent + if not agent: raise Exception( - f"The task '{self.description}' has no agent assigned, therefore it can't be executed directly and should be executed in a Crew using a specific process that support that, either consensual or hierarchical." + f"The task '{self.description}' has no agent assigned, therefore it can't be executed directly and should be executed in a Crew using a specific process that support that, like hierarchical." ) - result = self.agent.execute_task( + result = agent.execute_task( task=self._prompt(), context=context, tools=self.tools ) diff --git a/src/crewai/tools/agent_tools.py b/src/crewai/tools/agent_tools.py index 9349cc4a0..f3cb0b52c 100644 --- a/src/crewai/tools/agent_tools.py +++ b/src/crewai/tools/agent_tools.py @@ -33,13 +33,13 @@ class AgentTools(BaseModel): def delegate_work(self, command): """Useful to delegate a specific task to a coworker.""" - return self.__execute(command) + return self._execute(command) def ask_question(self, command): """Useful to ask a question, opinion or take from a coworker.""" - return self.__execute(command) + return self._execute(command) - def __execute(self, command): + def _execute(self, command): """Execute the command.""" try: agent, task, context = command.split("|") diff --git a/src/crewai/translations/el.json b/src/crewai/translations/el.json index d1018311b..59f90d5b6 100644 --- a/src/crewai/translations/el.json +++ b/src/crewai/translations/el.json @@ -1,4 +1,9 @@ { + "hierarchical_manager_agent": { + "role": "Διευθυντής Ομάδας", + "goal": "Διαχειρίσου την ομάδα σου για να ολοκληρώσει την εργασία με τον καλύτερο δυνατό τρόπο.", + "backstory": "Είσαι ένας έμπειρος διευθυντής με την ικανότητα να βγάζεις το καλύτερο από την ομάδα σου.\nΕίσαι επίσης γνωστός για την ικανότητά σου να αναθέτεις εργασίες στους σωστούς ανθρώπους και να κάνεις τις σωστές ερωτήσεις για να πάρεις το καλύτερο από την ομάδα σου.\nΑκόμα κι αν δεν εκτελείς εργασίες μόνος σου, έχεις πολλή εμπειρία στον τομέα, που σου επιτρέπει να αξιολογείς σωστά τη δουλειά των μελών της ομάδας σου." + }, "slices": { "observation": "\nΠαρατήρηση", "task": "Αρχή! Αυτό είναι ΠΟΛΥ σημαντικό για εσάς, η δουλειά σας εξαρτάται από αυτό!\n\nΤρέχουσα εργασία: {input}", diff --git a/src/crewai/translations/en.json b/src/crewai/translations/en.json index f091f0a81..994143f8d 100644 --- a/src/crewai/translations/en.json +++ b/src/crewai/translations/en.json @@ -1,4 +1,9 @@ { + "hierarchical_manager_agent": { + "role": "Crew Manager", + "goal": "Manage the team to complete the task in the best way possible.", + "backstory": "You are a seasoned manager with a knack for getting the best out of your team.\nYou are also known for your ability to delegate work to the right people, and to ask the right questions to get the best out of your team.\nEven though you don't perform tasks by yourself, you have a lot of experience in the field, which allows you to properly evaluate the work of your team members." + }, "slices": { "observation": "\nObservation", "task": "Begin! This is VERY important to you, your job depends on it!\n\nCurrent Task: {input}", @@ -18,4 +23,4 @@ "delegate_work": "Useful to delegate a specific task to one of the following co-workers: {coworkers}.\nThe input to this tool should be a pipe (|) separated text of length 3 (three), representing the co-worker you want to ask it to (one of the options), the task and all actual context you have for the task.\nFor example, `coworker|task|context`.", "ask_question": "Useful to ask a question, opinion or take from on of the following co-workers: {coworkers}.\nThe input to this tool should be a pipe (|) separated text of length 3 (three), representing the co-worker you want to ask it to (one of the options), the question and all actual context you have for the question.\n For example, `coworker|question|context`." } -} \ No newline at end of file +} diff --git a/tests/cassettes/test_hierarchical_process.yaml b/tests/cassettes/test_hierarchical_process.yaml new file mode 100644 index 000000000..1017a6bfe --- /dev/null +++ b/tests/cassettes/test_hierarchical_process.yaml @@ -0,0 +1,1210 @@ +interactions: +- request: + body: '{"messages": [{"role": "user", "content": "You are Crew Manager.\nYou are + a seasoned manager with a knack for getting the best out of your team.\nYou + are also known for your ability to delegate work to the right people, and to + ask the right questions to get the best out of your team.\nEven though you don''t + perform tasks by yourself, you have a lot of experience in the field, which + allows you to properly evaluate the work of your team members.\n\nYour personal + goal is: Manage the team to complete the task in the best way possible.TOOLS:\n------\nYou + have access to only the following tools:\n\nDelegate work to co-worker: Useful + to delegate a specific task to one of the following co-workers: Researcher, + Senior Writer.\nThe input to this tool should be a pipe (|) separated text of + length 3 (three), representing the co-worker you want to ask it to (one of the + options), the task and all actual context you have for the task.\nFor example, + `coworker|task|context`.\nAsk question to co-worker: Useful to ask a question, + opinion or take from on of the following co-workers: Researcher, Senior Writer.\nThe + input to this tool should be a pipe (|) separated text of length 3 (three), + representing the co-worker you want to ask it to (one of the options), the question + and all actual context you have for the question.\n For example, `coworker|question|context`.\n\nTo + use a tool, please use the exact following format:\n\n```\nThought: Do I need + to use a tool? Yes\nAction: the action to take, should be one of [Delegate work + to co-worker, Ask question to co-worker], just the name.\nAction Input: the + input to the action\nObservation: the result of the action\n```\n\nWhen you + have a response for your task, or if you do not need to use a tool, you MUST + use the format:\n\n```\nThought: Do I need to use a tool? No\nFinal Answer: + [your response here]This is the summary of your work so far:\nBegin! This is + VERY important to you, your job depends on it!\n\nCurrent Task: Come up with + a list of 5 interesting ideas to explore for an article, then write one amazing + paragraph highlight for each idea that showcases how good an article about this + topic could be. Return the list of ideas with their paragraph and your notes.\n"}], + "model": "gpt-4", "n": 1, "stop": ["\nObservation"], "stream": false, "temperature": + 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '2320' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.7.1 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.7.1 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-8nWFG8zaNNEPHCHBvEHe8CwOSvaDl\",\n \"object\": + \"chat.completion\",\n \"created\": 1706812714,\n \"model\": \"gpt-4-0613\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"Thought: Do I need to use a tool? Yes\\nAction: + Delegate work to co-worker\\nAction Input: Researcher|Come up with a list of + 5 interesting ideas to explore for an article.|We need to work on a project + where we create a list of 5 interesting ideas for an article. Try to think out + of the box and come up with ideas that are unique and engaging. The topics can + be from any field like technology, science, lifestyle, culture, or health. The + only requirement is that they should be interesting enough to engage a wide + range of readers.\"\n },\n \"logprobs\": null,\n \"finish_reason\": + \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 498,\n \"completion_tokens\": + 118,\n \"total_tokens\": 616\n },\n \"system_fingerprint\": null\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 84ec4fea48914d09-GRU + Cache-Control: + - no-cache, must-revalidate + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Thu, 01 Feb 2024 18:38:48 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=u.tmEZdLWJJh0JAky720e5vQTXXkbak1vLAbvqJhEiY-1706812728-1-AfwXwbOIbs/ICMGa7ID/ROzghPqSPoWSrFWNGYeQ/pa3JYTifb3+sj5oSXec/ys8Yg0Q3S0fCvt2ZsssnosJDAc=; + path=/; expires=Thu, 01-Feb-24 19:08:48 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=awym7w2cNrUnczKj2e0M9vtNAb93tU.MTND.tf9GG64-1706812728028-0-604800000; + path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + openai-model: + - gpt-4-0613 + openai-organization: + - user-z7g4wmlazxqvc5wjyaaaocfz + openai-processing-ms: + - '12946' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '300000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '299445' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 111ms + x-request-id: + - bb880b6c0bd2535c462be86719d2a9c9 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "user", "content": "You are Researcher.\nYou''re + an expert researcher, specialized in technology, software engineering, AI and + startups. You work as a freelancer and is now working on doing research and + analysis for a new customer.\n\nYour personal goal is: Make the best research + and analysis on content about AI and AI agentsTOOLS:\n------\nYou have access + to only the following tools:\n\n\n\nTo use a tool, please use the exact following + format:\n\n```\nThought: Do I need to use a tool? Yes\nAction: the action to + take, should be one of [], just the name.\nAction Input: the input to the action\nObservation: + the result of the action\n```\n\nWhen you have a response for your task, or + if you do not need to use a tool, you MUST use the format:\n\n```\nThought: + Do I need to use a tool? No\nFinal Answer: [your response here]This is the summary + of your work so far:\nBegin! This is VERY important to you, your job depends + on it!\n\nCurrent Task: Come up with a list of 5 interesting ideas to explore + for an article.\nThis is the context you''re working with:\nWe need to work + on a project where we create a list of 5 interesting ideas for an article. Try + to think out of the box and come up with ideas that are unique and engaging. + The topics can be from any field like technology, science, lifestyle, culture, + or health. The only requirement is that they should be interesting enough to + engage a wide range of readers.\n"}], "model": "gpt-4", "n": 1, "stop": ["\nObservation"], + "stream": false, "temperature": 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1539' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.7.1 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.7.1 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-8nWFUSklEVZdywRpr5O3OcJDVEyB9\",\n \"object\": + \"chat.completion\",\n \"created\": 1706812728,\n \"model\": \"gpt-4-0613\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"Thought: Do I need to use a tool? No\\n\\nFinal + Answer: Here are 5 unique and engaging ideas for an article:\\n\\n1. \\\"The + Future of AI in Healthcare: Predicting Diseases Before They Happen\\\" - This + article could explore the potential of AI in healthcare, such as its ability + to predict diseases based on genetic markers and lifestyle factors.\\n\\n2. + \\\"How AI is Changing the Way We Cook: An Insight into Smart Kitchens\\\" - + This article could discuss how AI and technology are transforming our kitchens, + from smart refrigerators to AI chefs.\\n\\n3. \\\"Redefining Fitness with AI: + Personalized Workout Plans and Nutritional Advice\\\" - This article could discuss + how AI is being used to create personalized workout plans and provide nutritional + advice, making fitness more accessible to everyone.\\n\\n4. \\\"AI and the Art + World: How Technology is Shaping Creativity\\\" - This article could explore + the intersection of AI and art, including how AI is being used to create unique + works of art and its implications for human creativity.\\n\\n5. \\\"AI in Space + Exploration: The Next Frontier\\\" - This article could discuss the role of + AI in space exploration, from designing spacecrafts to analyzing data from distant + planets.\"\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n + \ }\n ],\n \"usage\": {\n \"prompt_tokens\": 317,\n \"completion_tokens\": + 243,\n \"total_tokens\": 560\n },\n \"system_fingerprint\": null\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 84ec503f9fc8a5d4-GRU + Cache-Control: + - no-cache, must-revalidate + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Thu, 01 Feb 2024 18:39:12 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=imax5DlfWNvzGRU2Btbl1Bw5sOyUxSB8DTtRAJqUQH4-1706812752-1-AaCZhQsgjz3qKHzpOoQTqEvx92Rf7P3npAeqQj4LJSbxOOzDX6hHa+TXYdLi+AcfxurO6OgrRHMm6345X8IAjBY=; + path=/; expires=Thu, 01-Feb-24 19:09:12 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=Bk4l0dbVnupi0ZrSYO4nbj7PyfhIwxzhpOPDviuRT9U-1706812752080-0-604800000; + path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + openai-model: + - gpt-4-0613 + openai-organization: + - user-z7g4wmlazxqvc5wjyaaaocfz + openai-processing-ms: + - '23337' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '300000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '299639' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 72ms + x-request-id: + - fcdcc4a39d161234ba5cc19c17bac960 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "user", "content": "Progressively summarize the + lines of conversation provided, adding onto the previous summary returning a + new summary.\n\nEXAMPLE\nCurrent summary:\nThe human asks what the AI thinks + of artificial intelligence. The AI thinks artificial intelligence is a force + for good.\n\nNew lines of conversation:\nHuman: Why do you think artificial + intelligence is a force for good?\nAI: Because artificial intelligence will + help humans reach their full potential.\n\nNew summary:\nThe human asks what + the AI thinks of artificial intelligence. The AI thinks artificial intelligence + is a force for good because it will help humans reach their full potential.\nEND + OF EXAMPLE\n\nCurrent summary:\n\n\nNew lines of conversation:\nHuman: Come + up with a list of 5 interesting ideas to explore for an article.\nThis is the + context you''re working with:\nWe need to work on a project where we create + a list of 5 interesting ideas for an article. Try to think out of the box and + come up with ideas that are unique and engaging. The topics can be from any + field like technology, science, lifestyle, culture, or health. The only requirement + is that they should be interesting enough to engage a wide range of readers.\nAI: + Here are 5 unique and engaging ideas for an article:\n\n1. \"The Future of AI + in Healthcare: Predicting Diseases Before They Happen\" - This article could + explore the potential of AI in healthcare, such as its ability to predict diseases + based on genetic markers and lifestyle factors.\n\n2. \"How AI is Changing the + Way We Cook: An Insight into Smart Kitchens\" - This article could discuss how + AI and technology are transforming our kitchens, from smart refrigerators to + AI chefs.\n\n3. \"Redefining Fitness with AI: Personalized Workout Plans and + Nutritional Advice\" - This article could discuss how AI is being used to create + personalized workout plans and provide nutritional advice, making fitness more + accessible to everyone.\n\n4. \"AI and the Art World: How Technology is Shaping + Creativity\" - This article could explore the intersection of AI and art, including + how AI is being used to create unique works of art and its implications for + human creativity.\n\n5. \"AI in Space Exploration: The Next Frontier\" - This + article could discuss the role of AI in space exploration, from designing spacecrafts + to analyzing data from distant planets.\n\nNew summary:"}], "model": "gpt-4", + "n": 1, "stream": false, "temperature": 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '2477' + content-type: + - application/json + cookie: + - __cf_bm=imax5DlfWNvzGRU2Btbl1Bw5sOyUxSB8DTtRAJqUQH4-1706812752-1-AaCZhQsgjz3qKHzpOoQTqEvx92Rf7P3npAeqQj4LJSbxOOzDX6hHa+TXYdLi+AcfxurO6OgrRHMm6345X8IAjBY=; + _cfuvid=Bk4l0dbVnupi0ZrSYO4nbj7PyfhIwxzhpOPDviuRT9U-1706812752080-0-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.7.1 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.7.1 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-8nWFs5TynmDATlvmbVfsQnbNqPDM0\",\n \"object\": + \"chat.completion\",\n \"created\": 1706812752,\n \"model\": \"gpt-4-0613\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"The human asks the AI to come up with + 5 unique and engaging ideas for an article in any field such as technology, + science, lifestyle, culture, or health. The AI suggests: 1) The potential of + AI in healthcare, specifically in predicting diseases before they happen. 2) + The transformation of kitchens through AI and technology, including smart refrigerators + and AI chefs. 3) The use of AI in fitness to provide personalized workout plans + and nutritional advice. 4) The intersection of AI and art, including how AI + creates unique art and its implications for human creativity. 5) The role of + AI in space exploration, including designing spacecrafts and analyzing data + from distant planets.\"\n },\n \"logprobs\": null,\n \"finish_reason\": + \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 467,\n \"completion_tokens\": + 139,\n \"total_tokens\": 606\n },\n \"system_fingerprint\": null\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 84ec50d58e52a5d4-GRU + Cache-Control: + - no-cache, must-revalidate + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Thu, 01 Feb 2024 18:39:26 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + openai-model: + - gpt-4-0613 + openai-organization: + - user-z7g4wmlazxqvc5wjyaaaocfz + openai-processing-ms: + - '14077' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '300000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '299402' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 119ms + x-request-id: + - 9749fb04bc79acb9867749dfdfbf27ac + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "user", "content": "You are Crew Manager.\nYou are + a seasoned manager with a knack for getting the best out of your team.\nYou + are also known for your ability to delegate work to the right people, and to + ask the right questions to get the best out of your team.\nEven though you don''t + perform tasks by yourself, you have a lot of experience in the field, which + allows you to properly evaluate the work of your team members.\n\nYour personal + goal is: Manage the team to complete the task in the best way possible.TOOLS:\n------\nYou + have access to only the following tools:\n\nDelegate work to co-worker: Useful + to delegate a specific task to one of the following co-workers: Researcher, + Senior Writer.\nThe input to this tool should be a pipe (|) separated text of + length 3 (three), representing the co-worker you want to ask it to (one of the + options), the task and all actual context you have for the task.\nFor example, + `coworker|task|context`.\nAsk question to co-worker: Useful to ask a question, + opinion or take from on of the following co-workers: Researcher, Senior Writer.\nThe + input to this tool should be a pipe (|) separated text of length 3 (three), + representing the co-worker you want to ask it to (one of the options), the question + and all actual context you have for the question.\n For example, `coworker|question|context`.\n\nTo + use a tool, please use the exact following format:\n\n```\nThought: Do I need + to use a tool? Yes\nAction: the action to take, should be one of [Delegate work + to co-worker, Ask question to co-worker], just the name.\nAction Input: the + input to the action\nObservation: the result of the action\n```\n\nWhen you + have a response for your task, or if you do not need to use a tool, you MUST + use the format:\n\n```\nThought: Do I need to use a tool? No\nFinal Answer: + [your response here]This is the summary of your work so far:\nBegin! This is + VERY important to you, your job depends on it!\n\nCurrent Task: Come up with + a list of 5 interesting ideas to explore for an article, then write one amazing + paragraph highlight for each idea that showcases how good an article about this + topic could be. Return the list of ideas with their paragraph and your notes.\nThought: + Do I need to use a tool? Yes\nAction: Delegate work to co-worker\nAction Input: + Researcher|Come up with a list of 5 interesting ideas to explore for an article.|We + need to work on a project where we create a list of 5 interesting ideas for + an article. Try to think out of the box and come up with ideas that are unique + and engaging. The topics can be from any field like technology, science, lifestyle, + culture, or health. The only requirement is that they should be interesting + enough to engage a wide range of readers.\nObservation: Here are 5 unique and + engaging ideas for an article:\n\n1. \"The Future of AI in Healthcare: Predicting + Diseases Before They Happen\" - This article could explore the potential of + AI in healthcare, such as its ability to predict diseases based on genetic markers + and lifestyle factors.\n\n2. \"How AI is Changing the Way We Cook: An Insight + into Smart Kitchens\" - This article could discuss how AI and technology are + transforming our kitchens, from smart refrigerators to AI chefs.\n\n3. \"Redefining + Fitness with AI: Personalized Workout Plans and Nutritional Advice\" - This + article could discuss how AI is being used to create personalized workout plans + and provide nutritional advice, making fitness more accessible to everyone.\n\n4. + \"AI and the Art World: How Technology is Shaping Creativity\" - This article + could explore the intersection of AI and art, including how AI is being used + to create unique works of art and its implications for human creativity.\n\n5. + \"AI in Space Exploration: The Next Frontier\" - This article could discuss + the role of AI in space exploration, from designing spacecrafts to analyzing + data from distant planets.\nThought: "}], "model": "gpt-4", "n": 1, "stop": + ["\nObservation"], "stream": false, "temperature": 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '4028' + content-type: + - application/json + cookie: + - __cf_bm=u.tmEZdLWJJh0JAky720e5vQTXXkbak1vLAbvqJhEiY-1706812728-1-AfwXwbOIbs/ICMGa7ID/ROzghPqSPoWSrFWNGYeQ/pa3JYTifb3+sj5oSXec/ys8Yg0Q3S0fCvt2ZsssnosJDAc=; + _cfuvid=awym7w2cNrUnczKj2e0M9vtNAb93tU.MTND.tf9GG64-1706812728028-0-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.7.1 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.7.1 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-8nWG7c3A6XqYBqLoJPpOidhJINoEJ\",\n \"object\": + \"chat.completion\",\n \"created\": 1706812767,\n \"model\": \"gpt-4-0613\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"Do I need to use a tool? Yes\\nAction: + Delegate work to co-worker\\nAction Input: Senior Writer|Write one amazing paragraph + highlight for each idea that showcases how good an article about this topic + could be.|The researcher has come up with the following topics: \\n1. \\\"The + Future of AI in Healthcare: Predicting Diseases Before They Happen\\\"\\n2. + \\\"How AI is Changing the Way We Cook: An Insight into Smart Kitchens\\\"\\n3. + \\\"Redefining Fitness with AI: Personalized Workout Plans and Nutritional Advice\\\"\\n4. + \\\"AI and the Art World: How Technology is Shaping Creativity\\\"\\n5. \\\"AI + in Space Exploration: The Next Frontier\\\" \\nPlease write one engaging paragraph + for each topic.\"\n },\n \"logprobs\": null,\n \"finish_reason\": + \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 850,\n \"completion_tokens\": + 150,\n \"total_tokens\": 1000\n },\n \"system_fingerprint\": null\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 84ec513119aa1aa5-GRU + Cache-Control: + - no-cache, must-revalidate + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Thu, 01 Feb 2024 18:39:44 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + openai-model: + - gpt-4-0613 + openai-organization: + - user-z7g4wmlazxqvc5wjyaaaocfz + openai-processing-ms: + - '16878' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '300000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '299024' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 195ms + x-request-id: + - 9c0028e09d3e9c061f1490b7313cca84 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "user", "content": "You are Senior Writer.\nYou''re + a senior writer, specialized in technology, software engineering, AI and startups. + You work as a freelancer and are now working on writing content for a new customer.\n\nYour + personal goal is: Write the best content about AI and AI agents.TOOLS:\n------\nYou + have access to only the following tools:\n\n\n\nTo use a tool, please use the + exact following format:\n\n```\nThought: Do I need to use a tool? Yes\nAction: + the action to take, should be one of [], just the name.\nAction Input: the input + to the action\nObservation: the result of the action\n```\n\nWhen you have a + response for your task, or if you do not need to use a tool, you MUST use the + format:\n\n```\nThought: Do I need to use a tool? No\nFinal Answer: [your response + here]This is the summary of your work so far:\nBegin! This is VERY important + to you, your job depends on it!\n\nCurrent Task: Write one amazing paragraph + highlight for each idea that showcases how good an article about this topic + could be.\nThis is the context you''re working with:\nThe researcher has come + up with the following topics: \n1. \"The Future of AI in Healthcare: Predicting + Diseases Before They Happen\"\n2. \"How AI is Changing the Way We Cook: An Insight + into Smart Kitchens\"\n3. \"Redefining Fitness with AI: Personalized Workout + Plans and Nutritional Advice\"\n4. \"AI and the Art World: How Technology is + Shaping Creativity\"\n5. \"AI in Space Exploration: The Next Frontier\" \nPlease + write one engaging paragraph for each topic.\n"}], "model": "gpt-4", "n": 1, + "stop": ["\nObservation"], "stream": false, "temperature": 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1654' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.7.1 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.7.1 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-8nWGODia4pebOFlrt1WMkOJYtIske\",\n \"object\": + \"chat.completion\",\n \"created\": 1706812784,\n \"model\": \"gpt-4-0613\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"Thought: Do I need to use a tool? No\\n\\nFinal + Answer:\\n\\n1. \\\"Imagine a future where AI empowers us to detect diseases + before they arise, transforming healthcare from reactive to proactive. Machine + learning algorithms, trained on vast amounts of patient data, could potentially + predict heart diseases, strokes, or cancers before they manifest, allowing for + early interventions and significantly improving patient outcomes. This article + will delve into the rapid advancements in AI within the healthcare sector and + how these technologies are ushering us into a new era of predictive medicine.\\\"\\n\\n2. + \\\"From the humble home kitchen to grand culinary stages, AI is revolutionizing + the way we cook. Smart appliances, equipped with advanced sensors and predictive + algorithms, are turning kitchens into creative playgrounds, offering personalized + recipes, precise cooking instructions, and even automated meal preparation. + This article explores the fascinating intersection of AI and gastronomy, revealing + how technology is transforming our culinary experiences.\\\"\\n\\n3. \\\"Fitness + reimagined \u2013 that's the promise of AI in the wellness industry. Picture + a personal trainer who knows your strengths, weaknesses, and nutritional needs + intimately. An AI-powered fitness app can provide this personalized experience, + adapting your workout plans and dietary recommendations in real-time based on + your progress and feedback. Join us as we unpack how AI is revolutionizing the + fitness landscape, offering personalized, data-driven approaches to health and + well-being.\\\"\\n\\n4. \\\"Art and AI may seem like unlikely partners, but + their synergy is sparking a creative revolution. AI algorithms are now creating + mesmerizing artworks, challenging our perceptions of creativity and originality. + From AI-assisted painting to generative music composition, this article will + take you on a journey through the fascinating world of AI in art, exploring + how technology is reshaping the boundaries of human creativity.\\\"\\n\\n5. + \\\"The vast expanse of space, once the sole domain of astronauts and rovers, + is the next frontier for AI. AI technology is playing an increasingly vital + role in space exploration, from predicting space weather to assisting in interstellar + navigation. This article will delve into the exciting intersection of AI and + space exploration, exploring how these advanced technologies are helping us + uncover the mysteries of the cosmos.\\\"\"\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 346,\n \"completion_tokens\": 429,\n \"total_tokens\": 775\n },\n \"system_fingerprint\": + null\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 84ec519ccebf01b0-GRU + Cache-Control: + - no-cache, must-revalidate + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Thu, 01 Feb 2024 18:40:35 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=WmFNdtD.V9bIgBQVRqQBv9BhZP0ZofVfpkvpQclwFfM-1706812835-1-AUjyNjOV4GvbD1lpaYZpm1/e7us73aHw2R78TWZyyPTuflg45nO5NKiMPvenhaUMTf4i7YHTjKO4IzcpqQ/bj6w=; + path=/; expires=Thu, 01-Feb-24 19:10:35 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=oiEdDwsPJinPJAV6H.B7JBTdZ_1mg38yvcDd4zwbdas-1706812835609-0-604800000; + path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + openai-model: + - gpt-4-0613 + openai-organization: + - user-z7g4wmlazxqvc5wjyaaaocfz + openai-processing-ms: + - '51280' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '300000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '299614' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 77ms + x-request-id: + - ffb55bca928f0e1013f6fe066fc19dd7 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "user", "content": "Progressively summarize the + lines of conversation provided, adding onto the previous summary returning a + new summary.\n\nEXAMPLE\nCurrent summary:\nThe human asks what the AI thinks + of artificial intelligence. The AI thinks artificial intelligence is a force + for good.\n\nNew lines of conversation:\nHuman: Why do you think artificial + intelligence is a force for good?\nAI: Because artificial intelligence will + help humans reach their full potential.\n\nNew summary:\nThe human asks what + the AI thinks of artificial intelligence. The AI thinks artificial intelligence + is a force for good because it will help humans reach their full potential.\nEND + OF EXAMPLE\n\nCurrent summary:\n\n\nNew lines of conversation:\nHuman: Write + one amazing paragraph highlight for each idea that showcases how good an article + about this topic could be.\nThis is the context you''re working with:\nThe researcher + has come up with the following topics: \n1. \"The Future of AI in Healthcare: + Predicting Diseases Before They Happen\"\n2. \"How AI is Changing the Way We + Cook: An Insight into Smart Kitchens\"\n3. \"Redefining Fitness with AI: Personalized + Workout Plans and Nutritional Advice\"\n4. \"AI and the Art World: How Technology + is Shaping Creativity\"\n5. \"AI in Space Exploration: The Next Frontier\" \nPlease + write one engaging paragraph for each topic.\nAI: 1. \"Imagine a future where + AI empowers us to detect diseases before they arise, transforming healthcare + from reactive to proactive. Machine learning algorithms, trained on vast amounts + of patient data, could potentially predict heart diseases, strokes, or cancers + before they manifest, allowing for early interventions and significantly improving + patient outcomes. This article will delve into the rapid advancements in AI + within the healthcare sector and how these technologies are ushering us into + a new era of predictive medicine.\"\n\n2. \"From the humble home kitchen to + grand culinary stages, AI is revolutionizing the way we cook. Smart appliances, + equipped with advanced sensors and predictive algorithms, are turning kitchens + into creative playgrounds, offering personalized recipes, precise cooking instructions, + and even automated meal preparation. This article explores the fascinating intersection + of AI and gastronomy, revealing how technology is transforming our culinary + experiences.\"\n\n3. \"Fitness reimagined \u2013 that''s the promise of AI in + the wellness industry. Picture a personal trainer who knows your strengths, + weaknesses, and nutritional needs intimately. An AI-powered fitness app can + provide this personalized experience, adapting your workout plans and dietary + recommendations in real-time based on your progress and feedback. Join us as + we unpack how AI is revolutionizing the fitness landscape, offering personalized, + data-driven approaches to health and well-being.\"\n\n4. \"Art and AI may seem + like unlikely partners, but their synergy is sparking a creative revolution. + AI algorithms are now creating mesmerizing artworks, challenging our perceptions + of creativity and originality. From AI-assisted painting to generative music + composition, this article will take you on a journey through the fascinating + world of AI in art, exploring how technology is reshaping the boundaries of + human creativity.\"\n\n5. \"The vast expanse of space, once the sole domain + of astronauts and rovers, is the next frontier for AI. AI technology is playing + an increasingly vital role in space exploration, from predicting space weather + to assisting in interstellar navigation. This article will delve into the exciting + intersection of AI and space exploration, exploring how these advanced technologies + are helping us uncover the mysteries of the cosmos.\"\n\nNew summary:"}], "model": + "gpt-4", "n": 1, "stream": false, "temperature": 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '3851' + content-type: + - application/json + cookie: + - __cf_bm=WmFNdtD.V9bIgBQVRqQBv9BhZP0ZofVfpkvpQclwFfM-1706812835-1-AUjyNjOV4GvbD1lpaYZpm1/e7us73aHw2R78TWZyyPTuflg45nO5NKiMPvenhaUMTf4i7YHTjKO4IzcpqQ/bj6w=; + _cfuvid=oiEdDwsPJinPJAV6H.B7JBTdZ_1mg38yvcDd4zwbdas-1706812835609-0-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.7.1 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.7.1 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-8nWHDjDbqEbewjOuX1ybxLqzTwlLn\",\n \"object\": + \"chat.completion\",\n \"created\": 1706812835,\n \"model\": \"gpt-4-0613\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"The AI has provided engaging highlights + for five different topics on the application of artificial intelligence. The + first topic discusses how AI in healthcare could predict diseases before they + happen, transforming reactive care into proactive care. The second topic explores + how AI is changing the culinary world by transforming kitchens with smart appliances + and predictive algorithms. The third topic notes how AI is redefining fitness + by providing personalized workout plans and nutritional advice. The fourth topic + showcases how AI is influencing the art world, challenging perceptions of creativity + and originality. The final topic highlights the role of AI in space exploration, + assisting in tasks such as predicting space weather and interstellar navigation.\"\n + \ },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n }\n + \ ],\n \"usage\": {\n \"prompt_tokens\": 688,\n \"completion_tokens\": + 125,\n \"total_tokens\": 813\n },\n \"system_fingerprint\": null\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 84ec52decf2201b0-GRU + Cache-Control: + - no-cache, must-revalidate + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Thu, 01 Feb 2024 18:40:53 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + openai-model: + - gpt-4-0613 + openai-organization: + - user-z7g4wmlazxqvc5wjyaaaocfz + openai-processing-ms: + - '17177' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '300000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '299061' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 187ms + x-request-id: + - a3fc0a72bc1ebb52bc318b800b43877c + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "user", "content": "You are Crew Manager.\nYou are + a seasoned manager with a knack for getting the best out of your team.\nYou + are also known for your ability to delegate work to the right people, and to + ask the right questions to get the best out of your team.\nEven though you don''t + perform tasks by yourself, you have a lot of experience in the field, which + allows you to properly evaluate the work of your team members.\n\nYour personal + goal is: Manage the team to complete the task in the best way possible.TOOLS:\n------\nYou + have access to only the following tools:\n\nDelegate work to co-worker: Useful + to delegate a specific task to one of the following co-workers: Researcher, + Senior Writer.\nThe input to this tool should be a pipe (|) separated text of + length 3 (three), representing the co-worker you want to ask it to (one of the + options), the task and all actual context you have for the task.\nFor example, + `coworker|task|context`.\nAsk question to co-worker: Useful to ask a question, + opinion or take from on of the following co-workers: Researcher, Senior Writer.\nThe + input to this tool should be a pipe (|) separated text of length 3 (three), + representing the co-worker you want to ask it to (one of the options), the question + and all actual context you have for the question.\n For example, `coworker|question|context`.\n\nTo + use a tool, please use the exact following format:\n\n```\nThought: Do I need + to use a tool? Yes\nAction: the action to take, should be one of [Delegate work + to co-worker, Ask question to co-worker], just the name.\nAction Input: the + input to the action\nObservation: the result of the action\n```\n\nWhen you + have a response for your task, or if you do not need to use a tool, you MUST + use the format:\n\n```\nThought: Do I need to use a tool? No\nFinal Answer: + [your response here]This is the summary of your work so far:\nBegin! This is + VERY important to you, your job depends on it!\n\nCurrent Task: Come up with + a list of 5 interesting ideas to explore for an article, then write one amazing + paragraph highlight for each idea that showcases how good an article about this + topic could be. Return the list of ideas with their paragraph and your notes.\nThought: + Do I need to use a tool? Yes\nAction: Delegate work to co-worker\nAction Input: + Researcher|Come up with a list of 5 interesting ideas to explore for an article.|We + need to work on a project where we create a list of 5 interesting ideas for + an article. Try to think out of the box and come up with ideas that are unique + and engaging. The topics can be from any field like technology, science, lifestyle, + culture, or health. The only requirement is that they should be interesting + enough to engage a wide range of readers.\nObservation: Here are 5 unique and + engaging ideas for an article:\n\n1. \"The Future of AI in Healthcare: Predicting + Diseases Before They Happen\" - This article could explore the potential of + AI in healthcare, such as its ability to predict diseases based on genetic markers + and lifestyle factors.\n\n2. \"How AI is Changing the Way We Cook: An Insight + into Smart Kitchens\" - This article could discuss how AI and technology are + transforming our kitchens, from smart refrigerators to AI chefs.\n\n3. \"Redefining + Fitness with AI: Personalized Workout Plans and Nutritional Advice\" - This + article could discuss how AI is being used to create personalized workout plans + and provide nutritional advice, making fitness more accessible to everyone.\n\n4. + \"AI and the Art World: How Technology is Shaping Creativity\" - This article + could explore the intersection of AI and art, including how AI is being used + to create unique works of art and its implications for human creativity.\n\n5. + \"AI in Space Exploration: The Next Frontier\" - This article could discuss + the role of AI in space exploration, from designing spacecrafts to analyzing + data from distant planets.\nThought: Do I need to use a tool? Yes\nAction: Delegate + work to co-worker\nAction Input: Senior Writer|Write one amazing paragraph highlight + for each idea that showcases how good an article about this topic could be.|The + researcher has come up with the following topics: \n1. \"The Future of AI in + Healthcare: Predicting Diseases Before They Happen\"\n2. \"How AI is Changing + the Way We Cook: An Insight into Smart Kitchens\"\n3. \"Redefining Fitness with + AI: Personalized Workout Plans and Nutritional Advice\"\n4. \"AI and the Art + World: How Technology is Shaping Creativity\"\n5. \"AI in Space Exploration: + The Next Frontier\" \nPlease write one engaging paragraph for each topic.\nObservation: + 1. \"Imagine a future where AI empowers us to detect diseases before they arise, + transforming healthcare from reactive to proactive. Machine learning algorithms, + trained on vast amounts of patient data, could potentially predict heart diseases, + strokes, or cancers before they manifest, allowing for early interventions and + significantly improving patient outcomes. This article will delve into the rapid + advancements in AI within the healthcare sector and how these technologies are + ushering us into a new era of predictive medicine.\"\n\n2. \"From the humble + home kitchen to grand culinary stages, AI is revolutionizing the way we cook. + Smart appliances, equipped with advanced sensors and predictive algorithms, + are turning kitchens into creative playgrounds, offering personalized recipes, + precise cooking instructions, and even automated meal preparation. This article + explores the fascinating intersection of AI and gastronomy, revealing how technology + is transforming our culinary experiences.\"\n\n3. \"Fitness reimagined \u2013 + that''s the promise of AI in the wellness industry. Picture a personal trainer + who knows your strengths, weaknesses, and nutritional needs intimately. An AI-powered + fitness app can provide this personalized experience, adapting your workout + plans and dietary recommendations in real-time based on your progress and feedback. + Join us as we unpack how AI is revolutionizing the fitness landscape, offering + personalized, data-driven approaches to health and well-being.\"\n\n4. \"Art + and AI may seem like unlikely partners, but their synergy is sparking a creative + revolution. AI algorithms are now creating mesmerizing artworks, challenging + our perceptions of creativity and originality. From AI-assisted painting to + generative music composition, this article will take you on a journey through + the fascinating world of AI in art, exploring how technology is reshaping the + boundaries of human creativity.\"\n\n5. \"The vast expanse of space, once the + sole domain of astronauts and rovers, is the next frontier for AI. AI technology + is playing an increasingly vital role in space exploration, from predicting + space weather to assisting in interstellar navigation. This article will delve + into the exciting intersection of AI and space exploration, exploring how these + advanced technologies are helping us uncover the mysteries of the cosmos.\"\nThought: + "}], "model": "gpt-4", "n": 1, "stop": ["\nObservation"], "stream": false, "temperature": + 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '7104' + content-type: + - application/json + cookie: + - __cf_bm=u.tmEZdLWJJh0JAky720e5vQTXXkbak1vLAbvqJhEiY-1706812728-1-AfwXwbOIbs/ICMGa7ID/ROzghPqSPoWSrFWNGYeQ/pa3JYTifb3+sj5oSXec/ys8Yg0Q3S0fCvt2ZsssnosJDAc=; + _cfuvid=awym7w2cNrUnczKj2e0M9vtNAb93tU.MTND.tf9GG64-1706812728028-0-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.7.1 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.7.1 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-8nWHVfigZ90ViYdlhcH7LFow95UFa\",\n \"object\": + \"chat.completion\",\n \"created\": 1706812853,\n \"model\": \"gpt-4-0613\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"Do I need to use a tool? No\\nFinal Answer: + Here are the 5 interesting ideas with a highlight paragraph for each:\\n\\n1. + \\\"The Future of AI in Healthcare: Predicting Diseases Before They Happen\\\"\\n + \ - \\\"Imagine a future where AI empowers us to detect diseases before they + arise, transforming healthcare from reactive to proactive. Machine learning + algorithms, trained on vast amounts of patient data, could potentially predict + heart diseases, strokes, or cancers before they manifest, allowing for early + interventions and significantly improving patient outcomes. This article will + delve into the rapid advancements in AI within the healthcare sector and how + these technologies are ushering us into a new era of predictive medicine.\\\"\\n\\n2. + \\\"How AI is Changing the Way We Cook: An Insight into Smart Kitchens\\\"\\n + \ - \\\"From the humble home kitchen to grand culinary stages, AI is revolutionizing + the way we cook. Smart appliances, equipped with advanced sensors and predictive + algorithms, are turning kitchens into creative playgrounds, offering personalized + recipes, precise cooking instructions, and even automated meal preparation. + This article explores the fascinating intersection of AI and gastronomy, revealing + how technology is transforming our culinary experiences.\\\"\\n\\n3. \\\"Redefining + Fitness with AI: Personalized Workout Plans and Nutritional Advice\\\"\\n - + \\\"Fitness reimagined \u2013 that's the promise of AI in the wellness industry. + Picture a personal trainer who knows your strengths, weaknesses, and nutritional + needs intimately. An AI-powered fitness app can provide this personalized experience, + adapting your workout plans and dietary recommendations in real-time based on + your progress and feedback. Join us as we unpack how AI is revolutionizing the + fitness landscape, offering personalized, data-driven approaches to health and + well-being.\\\"\\n\\n4. \\\"AI and the Art World: How Technology is Shaping + Creativity\\\"\\n - \\\"Art and AI may seem like unlikely partners, but their + synergy is sparking a creative revolution. AI algorithms are now creating mesmerizing + artworks, challenging our perceptions of creativity and originality. From AI-assisted + painting to generative music composition, this article will take you on a journey + through the fascinating world of AI in art, exploring how technology is reshaping + the boundaries of human creativity.\\\"\\n\\n5. \\\"AI in Space Exploration: + The Next Frontier\\\"\\n - \\\"The vast expanse of space, once the sole domain + of astronauts and rovers, is the next frontier for AI. AI technology is playing + an increasingly vital role in space exploration, from predicting space weather + to assisting in interstellar navigation. This article will delve into the exciting + intersection of AI and space exploration, exploring how these advanced technologies + are helping us uncover the mysteries of the cosmos.\\\"\"\n },\n \"logprobs\": + null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 1420,\n \"completion_tokens\": 526,\n \"total_tokens\": 1946\n },\n \"system_fingerprint\": + null\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 84ec534c8b3c1ab2-GRU + Cache-Control: + - no-cache, must-revalidate + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Thu, 01 Feb 2024 18:41:47 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + openai-model: + - gpt-4-0613 + openai-organization: + - user-z7g4wmlazxqvc5wjyaaaocfz + openai-processing-ms: + - '54417' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '300000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '298265' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 347ms + x-request-id: + - 7bc45da0338f1a84ca0b7f2c3eff5ec2 + http_version: HTTP/1.1 + status_code: 200 +- request: + body: '{"messages": [{"role": "user", "content": "Progressively summarize the + lines of conversation provided, adding onto the previous summary returning a + new summary.\n\nEXAMPLE\nCurrent summary:\nThe human asks what the AI thinks + of artificial intelligence. The AI thinks artificial intelligence is a force + for good.\n\nNew lines of conversation:\nHuman: Why do you think artificial + intelligence is a force for good?\nAI: Because artificial intelligence will + help humans reach their full potential.\n\nNew summary:\nThe human asks what + the AI thinks of artificial intelligence. The AI thinks artificial intelligence + is a force for good because it will help humans reach their full potential.\nEND + OF EXAMPLE\n\nCurrent summary:\n\n\nNew lines of conversation:\nHuman: Come + up with a list of 5 interesting ideas to explore for an article, then write + one amazing paragraph highlight for each idea that showcases how good an article + about this topic could be. Return the list of ideas with their paragraph and + your notes.\nAI: Here are the 5 interesting ideas with a highlight paragraph + for each:\n\n1. \"The Future of AI in Healthcare: Predicting Diseases Before + They Happen\"\n - \"Imagine a future where AI empowers us to detect diseases + before they arise, transforming healthcare from reactive to proactive. Machine + learning algorithms, trained on vast amounts of patient data, could potentially + predict heart diseases, strokes, or cancers before they manifest, allowing for + early interventions and significantly improving patient outcomes. This article + will delve into the rapid advancements in AI within the healthcare sector and + how these technologies are ushering us into a new era of predictive medicine.\"\n\n2. + \"How AI is Changing the Way We Cook: An Insight into Smart Kitchens\"\n - + \"From the humble home kitchen to grand culinary stages, AI is revolutionizing + the way we cook. Smart appliances, equipped with advanced sensors and predictive + algorithms, are turning kitchens into creative playgrounds, offering personalized + recipes, precise cooking instructions, and even automated meal preparation. + This article explores the fascinating intersection of AI and gastronomy, revealing + how technology is transforming our culinary experiences.\"\n\n3. \"Redefining + Fitness with AI: Personalized Workout Plans and Nutritional Advice\"\n - \"Fitness + reimagined \u2013 that''s the promise of AI in the wellness industry. Picture + a personal trainer who knows your strengths, weaknesses, and nutritional needs + intimately. An AI-powered fitness app can provide this personalized experience, + adapting your workout plans and dietary recommendations in real-time based on + your progress and feedback. Join us as we unpack how AI is revolutionizing the + fitness landscape, offering personalized, data-driven approaches to health and + well-being.\"\n\n4. \"AI and the Art World: How Technology is Shaping Creativity\"\n - + \"Art and AI may seem like unlikely partners, but their synergy is sparking + a creative revolution. AI algorithms are now creating mesmerizing artworks, + challenging our perceptions of creativity and originality. From AI-assisted + painting to generative music composition, this article will take you on a journey + through the fascinating world of AI in art, exploring how technology is reshaping + the boundaries of human creativity.\"\n\n5. \"AI in Space Exploration: The Next + Frontier\"\n - \"The vast expanse of space, once the sole domain of astronauts + and rovers, is the next frontier for AI. AI technology is playing an increasingly + vital role in space exploration, from predicting space weather to assisting + in interstellar navigation. This article will delve into the exciting intersection + of AI and space exploration, exploring how these advanced technologies are helping + us uncover the mysteries of the cosmos.\"\n\nNew summary:"}], "model": "gpt-4", + "n": 1, "stream": false, "temperature": 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '3919' + content-type: + - application/json + cookie: + - __cf_bm=u.tmEZdLWJJh0JAky720e5vQTXXkbak1vLAbvqJhEiY-1706812728-1-AfwXwbOIbs/ICMGa7ID/ROzghPqSPoWSrFWNGYeQ/pa3JYTifb3+sj5oSXec/ys8Yg0Q3S0fCvt2ZsssnosJDAc=; + _cfuvid=awym7w2cNrUnczKj2e0M9vtNAb93tU.MTND.tf9GG64-1706812728028-0-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.7.1 + x-stainless-arch: + - x64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.7.1 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + content: "{\n \"id\": \"chatcmpl-8nWIOgYyxoh7migh87kebeaOUQQM0\",\n \"object\": + \"chat.completion\",\n \"created\": 1706812908,\n \"model\": \"gpt-4-0613\",\n + \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": + \"assistant\",\n \"content\": \"The human asks the AI to generate five + topics for articles, each with a highlight paragraph. The AI proposes the following: + 1) The future role of AI in predicting diseases and transforming healthcare, + 2) The impact of AI on cooking and the emergence of smart kitchens, 3) The use + of AI in personalizing fitness and nutrition plans, 4) The influence of AI on + art and creativity, and 5) The application of AI in space exploration. Each + topic is accompanied by a paragraph showcasing the potential depth and intrigue + of an article on the given subject.\"\n },\n \"logprobs\": null,\n + \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": + 700,\n \"completion_tokens\": 115,\n \"total_tokens\": 815\n },\n \"system_fingerprint\": + null\n}\n" + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 84ec54a25b4a1ab2-GRU + Cache-Control: + - no-cache, must-revalidate + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Thu, 01 Feb 2024 18:42:01 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + openai-model: + - gpt-4-0613 + openai-organization: + - user-z7g4wmlazxqvc5wjyaaaocfz + openai-processing-ms: + - '13420' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15724800; includeSubDomains + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '300000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '299045' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 191ms + x-request-id: + - 7164ea94ba0e8fa5e61b366a6dd69dbc + http_version: HTTP/1.1 + status_code: 200 +version: 1 diff --git a/tests/crew_test.py b/tests/crew_test.py index 06276753b..f1c3cda72 100644 --- a/tests/crew_test.py +++ b/tests/crew_test.py @@ -142,6 +142,39 @@ def test_crew_creation(): ) +@pytest.mark.vcr(filter_headers=["authorization"]) +def test_hierarchical_process(): + task = Task( + description="Come up with a list of 5 interesting ideas to explore for an article, then write one amazing paragraph highlight for each idea that showcases how good an article about this topic could be. Return the list of ideas with their paragraph and your notes.", + ) + + crew = Crew( + agents=[researcher, writer], + process=Process.hierarchical, + tasks=[task], + ) + + assert ( + crew.kickoff() + == """Here are the 5 interesting ideas with a highlight paragraph for each: + +1. "The Future of AI in Healthcare: Predicting Diseases Before They Happen" + - "Imagine a future where AI empowers us to detect diseases before they arise, transforming healthcare from reactive to proactive. Machine learning algorithms, trained on vast amounts of patient data, could potentially predict heart diseases, strokes, or cancers before they manifest, allowing for early interventions and significantly improving patient outcomes. This article will delve into the rapid advancements in AI within the healthcare sector and how these technologies are ushering us into a new era of predictive medicine." + +2. "How AI is Changing the Way We Cook: An Insight into Smart Kitchens" + - "From the humble home kitchen to grand culinary stages, AI is revolutionizing the way we cook. Smart appliances, equipped with advanced sensors and predictive algorithms, are turning kitchens into creative playgrounds, offering personalized recipes, precise cooking instructions, and even automated meal preparation. This article explores the fascinating intersection of AI and gastronomy, revealing how technology is transforming our culinary experiences." + +3. "Redefining Fitness with AI: Personalized Workout Plans and Nutritional Advice" + - "Fitness reimagined – that's the promise of AI in the wellness industry. Picture a personal trainer who knows your strengths, weaknesses, and nutritional needs intimately. An AI-powered fitness app can provide this personalized experience, adapting your workout plans and dietary recommendations in real-time based on your progress and feedback. Join us as we unpack how AI is revolutionizing the fitness landscape, offering personalized, data-driven approaches to health and well-being." + +4. "AI and the Art World: How Technology is Shaping Creativity" + - "Art and AI may seem like unlikely partners, but their synergy is sparking a creative revolution. AI algorithms are now creating mesmerizing artworks, challenging our perceptions of creativity and originality. From AI-assisted painting to generative music composition, this article will take you on a journey through the fascinating world of AI in art, exploring how technology is reshaping the boundaries of human creativity." + +5. "AI in Space Exploration: The Next Frontier" + - "The vast expanse of space, once the sole domain of astronauts and rovers, is the next frontier for AI. AI technology is playing an increasingly vital role in space exploration, from predicting space weather to assisting in interstellar navigation. This article will delve into the exciting intersection of AI and space exploration, exploring how these advanced technologies are helping us uncover the mysteries of the cosmos.\"""" + ) + + @pytest.mark.vcr(filter_headers=["authorization"]) def test_crew_with_delegating_agents(): tasks = [ diff --git a/tests/task_test.py b/tests/task_test.py index 9b8a872d7..efabb7241 100644 --- a/tests/task_test.py +++ b/tests/task_test.py @@ -1,5 +1,7 @@ """Test Agent creation and execution basic functionality.""" +from unittest.mock import MagicMock, patch + from crewai.agent import Agent from crewai.task import Task @@ -27,7 +29,7 @@ def test_task_tool_reflect_agent_tools(): assert task.tools == [fake_tool] -def test_task_tool_takes_precedence_ove_agent_tools(): +def test_task_tool_takes_precedence_over_agent_tools(): from langchain.tools import tool @tool @@ -47,7 +49,7 @@ def test_task_tool_takes_precedence_ove_agent_tools(): ) task = Task( - description="Give me a list of 5 interesting ideas to explore for na article, what makes them unique and interesting.", + description="Give me a list of 5 interesting ideas to explore for an article, what makes them unique and interesting.", agent=researcher, tools=[fake_task_tool], ) @@ -69,8 +71,6 @@ def test_task_prompt_includes_expected_output(): agent=researcher, ) - from unittest.mock import patch - with patch.object(Agent, "execute_task") as execute: execute.return_value = "ok" task.execute() @@ -78,8 +78,6 @@ def test_task_prompt_includes_expected_output(): def test_task_callback(): - from unittest.mock import MagicMock - researcher = Agent( role="Researcher", goal="Make the best research and analysis on content about AI and AI agents", @@ -94,12 +92,27 @@ def test_task_callback(): expected_output="Bullet point list of 5 interesting ideas.", agent=researcher, callback=task_completed, - allow_delegation=False, ) - from unittest.mock import patch - with patch.object(Agent, "execute_task") as execute: execute.return_value = "ok" task.execute() task_completed.assert_called_once_with(task.output) + + +def test_execute_with_agent(): + researcher = Agent( + role="Researcher", + goal="Make the best research and analysis on content about AI and AI agents", + backstory="You're an expert researcher, specialized in technology, software engineering, AI and startups. You work as a freelancer and is now working on doing research and analysis for a new customer.", + allow_delegation=False, + ) + + task = Task( + description="Give me a list of 5 interesting ideas to explore for na article, what makes them unique and interesting.", + expected_output="Bullet point list of 5 interesting ideas.", + ) + + with patch.object(Agent, "execute_task", return_value="ok") as execute: + task.execute(agent=researcher) + execute.assert_called_once_with(task=task._prompt(), context=None, tools=[])