Skip to content

Commit

Permalink
Merge pull request #29 from ShoggothAI/delegation-debug
Browse files Browse the repository at this point in the history
Fix delegation errors because of missing task-unit links
  • Loading branch information
ZmeiGorynych authored May 20, 2024
2 parents 254aced + 5675b0b commit e9da22a
Show file tree
Hide file tree
Showing 46 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion motleycrew/applications/research_agent/question_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_next_unit(self) -> QuestionGenerationTaskUnit | None:
logging.info("Most pertinent question according to the tool: %s", most_pertinent_question)
return QuestionGenerationTaskUnit(question=most_pertinent_question)

def register_completed_unit(self, task: TaskUnitType) -> None:
def register_completed_unit(self, unit: TaskUnitType) -> None:
logging.info("==== Completed iteration %s of %s ====", self.n_iter + 1, self.max_iter)
self.n_iter += 1
if self.n_iter >= self.max_iter:
Expand Down
2 changes: 1 addition & 1 deletion motleycrew/crew.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _run_sync(self) -> list[TaskUnit]:
agent = task.get_worker(extra_tools)
logging.info("Assigned unit %s to agent %s, dispatching", current_unit, agent)
current_unit.set_running()
self.graph_store.insert_node(current_unit)
task.register_started_unit(current_unit)

# TODO: accept and handle some sort of return value? Or just the final state of the task?
result = agent.invoke(current_unit.as_dict())
Expand Down
12 changes: 5 additions & 7 deletions motleycrew/tasks/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def compose_simple_task_prompt_with_dependencies(
continue

unit_name = getattr(unit, "name", default_task_name)
upstream_results.append(f"##{unit_name}\n" + "\n".join(str(out) for out in unit.output))
upstream_results.append(f"##{unit_name}\n" + str(unit.output))

if not upstream_results:
return description
Expand Down Expand Up @@ -76,11 +76,11 @@ def __init__(
self.crew = crew
self.crew.register_tasks([self])

def register_completed_unit(self, task: SimpleTaskUnit) -> None:
assert isinstance(task, SimpleTaskUnit)
assert task.done
def register_completed_unit(self, unit: SimpleTaskUnit) -> None:
assert isinstance(unit, SimpleTaskUnit)
assert unit.done

self.output = task.output
self.output = unit.output
self.set_done()

def get_next_unit(self) -> SimpleTaskUnit | None:
Expand All @@ -93,9 +93,7 @@ def get_next_unit(self) -> SimpleTaskUnit | None:
return None

upstream_task_units = [unit for task in upstream_tasks for unit in task.get_units()]
# print(upstream_tasks)
prompt = compose_simple_task_prompt_with_dependencies(self.description, upstream_task_units)
# print(prompt)
return SimpleTaskUnit(
name=self.name,
prompt=prompt,
Expand Down
18 changes: 14 additions & 4 deletions motleycrew/tasks/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_units(self) -> List[TaskUnitType]:
self.TASK_UNIT_BELONGS_LABEL,
self.NODE_CLASS.get_label(),
)
task_units = self.crew.graph_store.run_cypher_query(
task_units = self.graph_store.run_cypher_query(
query, parameters={"self_id": self.node.id}, container=self.TASK_UNIT_CLASS
)
return task_units
Expand All @@ -103,7 +103,7 @@ def get_upstream_tasks(self) -> List[Task]:
self.TASK_IS_UPSTREAM_LABEL,
self.NODE_CLASS.get_label(),
)
upstream_task_nodes = self.crew.graph_store.run_cypher_query(
upstream_task_nodes = self.graph_store.run_cypher_query(
query, parameters={"self_id": self.node.id}, container=self.NODE_CLASS
)
return [task for task in self.crew.tasks if task.node in upstream_task_nodes]
Expand All @@ -121,7 +121,7 @@ def get_downstream_tasks(self) -> List[Task]:
self.NODE_CLASS.get_label(),
self.TASK_IS_UPSTREAM_LABEL,
)
downstream_task_nodes = self.crew.graph_store.run_cypher_query(
downstream_task_nodes = self.graph_store.run_cypher_query(
query, parameters={"self_id": self.node.id}, container=self.NODE_CLASS
)
return [task for task in self.crew.tasks if task.node in downstream_task_nodes]
Expand All @@ -130,7 +130,17 @@ def set_done(self, value: bool = True):
self.done = value
self.node.done = value

def register_completed_unit(self, task: TaskUnitType) -> None:
def register_started_unit(self, unit: TaskUnitType) -> None:
assert isinstance(unit, self.TASK_UNIT_CLASS)
assert not unit.done

self.graph_store.upsert_triplet(
from_node=unit,
to_node=self.node,
label=self.TASK_UNIT_BELONGS_LABEL,
)

def register_completed_unit(self, unit: TaskUnitType) -> None:
pass

@abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion motleycrew/tools/image_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def run_dalle_and_save_images_partial(description: str):
return run_dalle_and_save_images(description=description, images_directory=images_directory)

return Tool(
name="Dall-E-Image-Generator",
name="dalle_image_generator",
func=run_dalle_and_save_images_partial,
description="A wrapper around OpenAI DALL-E API. Useful for when you need to generate images from a text description. "
"Input should be an image description.",
Expand Down
2 changes: 1 addition & 1 deletion motleycrew/tools/mermaid_evaluator_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def eval_mermaid_partial(mermaid_code: str):

langchain_tool = Tool.from_function(
func=eval_mermaid_partial,
name="Mermaid Evaluator Tool",
name="mermaid_evaluator_tool",
description="Evaluates Mermaid code and returns the output as a BytesIO object.",
args_schema=create_model(
"MermaidEvaluatorToolInput",
Expand Down
2 changes: 1 addition & 1 deletion motleycrew/tools/simple_retriever_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def call_retriever(question: Question) -> list:

retriever_tool = StructuredTool.from_function(
func=call_retriever,
name="Information retriever tool",
name="information_retriever_tool",
description="Useful for running a natural language query against a"
" knowledge base and retrieving a set of relevant documents.",
args_schema=RetrieverToolInput,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/itest_golden_data/delegation_crewai.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"**Title: Unveiling 2023's Game-Changing AI Innovations**\n\n**Introduction**\nAs we navigate through 2023, the landscape of artificial intelligence continues to evolve at a breathtaking pace. This year, we've witnessed some groundbreaking advancements that are not just reshaping industries but are also setting new benchmarks in the capabilities of AI technologies. Let's dive into some of the most thrilling developments that are making headlines this year!\n\n**Generative AI Takes the Lead**\nOne of the most buzzworthy breakthroughs has been in the realm of generative AI. Imagine a technology that can write poems, draft emails, or even generate computer code at the blink of an eye. This isn't science fiction anymore; it's the reality brought to us by the latest generative models like Gemini Ultra. This powerhouse has outperformed human experts in various benchmarks, showcasing an ability that was once thought to be decades away.\n\n**Business Transformation with AI**\nIt's not just about cool tech and fancy algorithms; the real-world impact of these AI advancements is profound. According to a recent McKinsey Global Survey, businesses across the globe are rapidly integrating AI tools into their operations. From automating routine tasks to enhancing decision-making processes, AI is becoming an indispensable asset for companies striving to stay competitive in a digital-first world.\n\n**Ethics and Policy: The Growing Debate**\nWith great power comes great responsibility. As AI technologies become more integrated into our daily lives, the discussions around ethics and transparency are gaining momentum. 2023 has seen significant strides in not only advancing AI technology but also in framing the necessary policies to ensure these tools are used wisely and ethically.\n\n**Conclusion**\nThe advancements in AI this year are nothing short of revolutionary. As we continue to explore the potential of these technologies, one thing is clear: the future is here, and it's powered by AI. Whether you're a tech enthusiast, a business leader, or just a curious mind, these developments promise exciting possibilities and a glimpse into a future where AI is at the heart of innovation and human progress. Stay tuned, because the AI revolution is just getting started!\n\nThis blog post is designed to be informative yet accessible, capturing the excitement surrounding the latest AI advancements while ensuring it remains engaging for a tech-savvy audience."
"**AI in 2024: A Leap Towards Accessible, Ethical, and Powerful Technology**\n\nIn the rapidly evolving landscape of artificial intelligence, 2024 has marked several groundbreaking advancements that are reshaping how we interact with technology on a daily basis. Here are some of the most significant AI developments this year:\n\n1. **Generative AI Becomes Mainstream**: This year, generative AI has transitioned from a niche technology to a mainstream tool accessible to the average person. Innovations in this space have enabled users to create customized content, from text to images, with an unprecedented level of ease and precision. This democratization of AI tools is fostering a new wave of creativity and personalization across various sectors.\n\n2. **Open Source AI Models**: 2024 has seen a surge in the availability and use of open source pretrained AI models. These models have become a catalyst for business growth, allowing companies to integrate advanced AI capabilities without the prohibitive costs of developing proprietary systems. By leveraging these open source models, businesses are enhancing productivity and driving cost-efficiency, particularly in data analysis and automated decision-making processes.\n\n3. **Quantum AI Emergence**: The intersection of quantum computing and AI is beginning to bear fruit, with developments that promise to make AI systems smarter and faster. Quantum AI is poised to revolutionize fields such as drug discovery, climate modeling, and complex system optimization by handling tasks that are currently beyond the reach of classical computers.\n\n4. **Explainable AI (XAI)**: There has been a significant push towards making AI decisions more transparent and understandable to humans. Explainable AI aims to bridge the gap between AI decision-making processes and human interpretability, ensuring that AI systems are not just powerful, but also trustworthy and accountable.\n\nThese advancements are not just technical feats but are paving the way for more ethical, efficient, and accessible AI applications that promise to transform everyday life, making technology an even more integral and seamless part of our daily existence."
2 changes: 1 addition & 1 deletion tests/itest_golden_data/single_llama_index.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"**Comprehensive Analysis of AI Advancements in 2024**\n\n**1. Generative AI: Mainstream Adoption and Practical Applications**\n - In 2024, generative AI is expected to transition from a primarily tech-centric tool to a more universally accessible technology. This shift will enable everyday users to engage with AI, fostering a culture of innovation across various sectors. The proliferation of user-friendly AI applications is anticipated to democratize technology, allowing more individuals to experiment with AI-driven solutions.\n\n**2. Breakthrough Technologies: The Rise of User-Friendly AI Platforms**\n - Following the impactful launch of OpenAI's ChatGPT in late 2022, the AI landscape has witnessed rapid growth in user-friendly platforms. These platforms are designed to be intuitive, making it easier for non-technical users to leverage advanced AI capabilities. This trend is likely to continue, with more platforms emerging that simplify the integration of AI into daily tasks and business operations.\n\n**3. Industry Impact: Transformation Across Sectors**\n - The widespread adoption of generative AI is set to trigger significant transformations across the global economic landscape. Industries ranging from healthcare to finance are expected to harness the power of AI to innovate and improve efficiency. This technological shift is poised to redefine business models and operational strategies, leading to enhanced productivity and competitiveness.\n\n**4. Organizational Changes: The Evolution of AI Leadership**\n - There has been a noticeable trend in organizations reducing the number of specialized technology and data roles, such as chief data officers and chief AI officers. This shift suggests a move towards integrating AI and data analytics into broader business functions, reflecting a more holistic approach to technology management within companies.\n\n**5. Future Outlook: Potential Challenges and Opportunities**\n - As AI continues to evolve, it presents both challenges and opportunities. Ethical considerations, privacy concerns, and the need for robust regulatory frameworks are among the key challenges that need addressing. Conversely, the ongoing advancements in AI offer substantial opportunities for innovation and growth across various industries.\n\nThis analysis highlights the dynamic nature of AI development in 2024, underscoring its potential to revolutionize both technology and business landscapes. As AI becomes more embedded in everyday life, its impact is expected to expand, paving the way for new possibilities and challenges alike."
"**Comprehensive Analysis Report on AI Advancements in 2024**\n\n**Introduction**\nThe year 2024 marks a significant phase in the evolution of artificial intelligence (AI), transitioning from experimental to practical, everyday applications. This report delves into the key trends, breakthrough technologies, and their potential impacts on various industries.\n\n**1. Key Trends**\n- **Generative AI Accessibility**: Generative AI is becoming increasingly user-friendly, allowing even non-technical individuals to experiment and innovate with AI models.\n- **Sophistication and Caution**: There is a noticeable shift towards more sophisticated and cautious development and deployment of AI technologies. This includes a stronger focus on ethics, safety, and compliance with evolving regulatory frameworks.\n- **Integration into Daily Life**: Following the release of technologies like ChatGPT by OpenAI, AI is becoming more woven into the fabric of daily life, influencing various sectors and enhancing user experiences.\n\n**2. Breakthrough Technologies**\n- **Multimodal AI**: This technology represents a significant advancement over traditional AI models that process data in a single mode. Multimodal AI can process and interpret multiple types of data simultaneously, such as text, images, and sounds, leading to more robust and versatile applications.\n\n**3. Industry Impacts**\n- **Reduction in Independent AI Leadership**: There is a trend of decreasing independence of AI leadership roles within organizations. Companies are consolidating roles like chief data officers and chief AI officers, possibly to streamline operations and foster more integrated strategic approaches.\n- **Propelling Industries**: Industries are being propelled into futuristic operational modes, with AI playing a pivotal role in automating processes, enhancing decision-making, and creating new value propositions.\n\n**Conclusion**\nThe advancements in AI in 2024 are set to transform how we interact with technology on a daily basis. With a focus on multimodal capabilities, ethical AI deployment, and practical applications, AI is not only becoming more sophisticated but also more integral to our daily lives and work environments. The ongoing evolution in AI governance and strategy reflects a maturing field that is increasingly aligned with broader societal and business needs."

0 comments on commit e9da22a

Please sign in to comment.