Skip to content

Commit

Permalink
Update Workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpreetbedi committed May 5, 2024
1 parent 1d8ca2a commit d734646
Show file tree
Hide file tree
Showing 13 changed files with 290 additions and 157 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
Assistant(
llm=OpenAIChat(model="gpt-3.5-turbo", stop="</answer>"),
system_prompt="What is the color of a banana? Provide your answer in the xml tag <answer>.",
add_messages=[{"role": "assistant", "content": "<answer>"}],
additional_messages=[{"role": "assistant", "content": "<answer>"}],
debug_mode=True,
).print_response()
1 change: 0 additions & 1 deletion cookbook/assistants/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
llm=OpenAIChat(model="gpt-3.5-turbo"),
description="You help people with their health and fitness goals.",
instructions=["Recipes should be under 5 ingredients"],
debug_mode=True,
)
# -*- Print a response to the cli
assistant.print_response("Share a breakfast recipe.", markdown=True)
2 changes: 1 addition & 1 deletion cookbook/assistants/movie_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class MovieScript(BaseModel):
movie_assistant = Assistant(
description="You help write movie scripts.",
output_model=MovieScript,
debug_mode=True,
)

pprint(movie_assistant.run("New York"))
32 changes: 30 additions & 2 deletions cookbook/assistants/research.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,44 @@
from textwrap import dedent

from phi.assistant import Assistant
from phi.tools.duckduckgo import DuckDuckGo
from phi.tools.newspaper4k import Newspaper4k

assistant = Assistant(
tools=[DuckDuckGo(), Newspaper4k()],
show_tool_calls=True,
description="You are a senior NYT researcher writing an article on a topic.",
instructions=[
"For the provided topic, search for the top 3 links.",
"For the provided topic, search for the top 5 links.",
"Then read each URL and extract the article text. If a URL isn't available, ignore and move on.",
"Analyse and prepare an NYT worthy article based on the information.",
],
add_datetime_to_instructions=True,
expected_output=dedent("""\
An engaging, informative, and well-structured article in the following format:
<article_format>
## Engaging Article Title
### Overview
{give a brief introduction of the article and why the user should read this report}
{make this section engaging and create a hook for the reader}
### Section 1
{break the article into sections}
{provide details/facts/processes in this section}
... more sections as necessary...
### Takeaways
{provide key takeaways from the article}
### References
- [Title](url)
- [Title](url)
- [Title](url)
</article_format>\
"""),
# show_tool_calls=True,
debug_mode=True,
save_output_to_file="news_article.md",
)
assistant.print_response("Latest developments in AI", markdown=True)
5 changes: 2 additions & 3 deletions cookbook/assistants/web_search.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from phi.assistant import Assistant
from phi.tools.duckduckgo import DuckDuckGo

assistant = Assistant(tools=[DuckDuckGo()], show_tool_calls=True, monitoring=True, debug_mode=True)
assistant.print_response("Share 1 story from France?", markdown=True)
assistant.print_response("Share 1 story from UK?", markdown=True)
assistant = Assistant(tools=[DuckDuckGo()], show_tool_calls=True, markdown=True)
assistant.print_response("Share 1 story from France?")
8 changes: 3 additions & 5 deletions cookbook/workflows/hackernews.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,13 @@ def get_user_details(username: str) -> str:
show_tool_calls=True,
)

hn_team = Workflow(
hn_workflow = Workflow(
name="HackerNews Workflow",
debug_mode=True,
tasks=[
Task(description="Get top hackernews stories", assistant=hn_top_stories, show_output=False),
Task(description="Get information about hackernews users", assistant=hn_user_researcher, show_output=False),
Task(description="Write an engaging article"),
],
debug_mode=True,
)
hn_team.print_response(
"Write a report about the users with the top 2 stories on hackernews, skip the whoishiring user?", markdown=True
)
hn_workflow.print_response("Write a report about the users with the top 2 stories on hackernews", markdown=True)
10 changes: 5 additions & 5 deletions cookbook/workflows/investment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Please install dependencies using:
pip install openai newspaper4k lxml_html_clean phidata yfinance
pip install openai newspaper4k lxml_html_clean yfinance phidata
"""

from textwrap import dedent
Expand All @@ -13,7 +13,7 @@
from phi.tools.file import FileTools


reports_dir = Path(__file__).parent.parent.parent.joinpath("junk", "reports")
reports_dir = Path(__file__).parent.parent.parent.joinpath("wip", "reports")
if reports_dir.exists():
rmtree(path=reports_dir, ignore_errors=True)
reports_dir.mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -54,8 +54,8 @@
# debug_mode=True,
)

investor = Workflow(
name="Investor Workflow",
investment_workflow = Workflow(
name="Investment Research Workflow",
tasks=[
Task(
description=dedent("""\
Expand Down Expand Up @@ -85,7 +85,7 @@
debug_mode=True,
)

investor.print_response(
investment_workflow.print_response(
"NVDA",
markdown=True,
)
97 changes: 97 additions & 0 deletions cookbook/workflows/news_article.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
"""
Please install dependencies using:
pip install openai duckduckgo-search newspaper4k lxml_html_clean phidata
"""

from shutil import rmtree
from pathlib import Path
from textwrap import dedent
from typing import Optional

from pydantic import BaseModel, Field
from phi.assistant import Assistant
from phi.workflow import Workflow, Task
from phi.tools.duckduckgo import DuckDuckGo
from phi.tools.newspaper4k import Newspaper4k


articles_dir = Path(__file__).parent.parent.parent.joinpath("wip", "articles")
if articles_dir.exists():
rmtree(path=articles_dir, ignore_errors=True)
articles_dir.mkdir(parents=True, exist_ok=True)


class NewsArticle(BaseModel):
title: str = Field(..., description="Title of the article.")
url: str = Field(..., description="Link to the article.")
summary: Optional[str] = Field(..., description="Summary of the article if available.")


researcher = Assistant(
name="Article Researcher",
tools=[DuckDuckGo()],
description="Given a topic, search for 15 articles and return the 7 most relevant articles.",
output_model=NewsArticle,
)

writer = Assistant(
name="Article Writer",
tools=[Newspaper4k()],
description="You are a Senior NYT Editor and your task is to write a NYT cover story worthy article due tomorrow.",
instructions=[
"You will be provided with news articles and their links.",
"Carefully read each article and think about the contents",
"Then generate a final New York Times worthy article in the <article_format> provided below.",
"Break the article into sections and provide key takeaways at the end.",
"Make sure the title is catchy and engaging.",
"Give the section relevant titles and provide details/facts/processes in each section."
"Ignore articles that you cannot read or understand.",
"REMEMBER: you are writing for the New York Times, so the quality of the article is important.",
],
expected_output=dedent("""\
An engaging, informative, and well-structured article in the following format:
<article_format>
## Engaging Article Title
### Overview
{give a brief introduction of the article and why the user should read this report}
{make this section engaging and create a hook for the reader}
### Section 1
{break the article into sections}
{provide details/facts/processes in this section}
... more sections as necessary...
### Takeaways
{provide key takeaways from the article}
### References
- [Title](url)
- [Title](url)
- [Title](url)
</article_format>
"""),
)

news_article = Workflow(
name="News Article Workflow",
tasks=[
Task(
description="Find the 7 most relevant articles on a topic.",
assistant=researcher,
show_output=False,
),
Task(
description="Read each article and and write a NYT worthy news article.",
assistant=writer,
),
],
debug_mode=True,
save_output_to_file="news_article.md",
)

news_article.print_response(
"Hashicorp IBM acquisition",
markdown=True,
)
28 changes: 28 additions & 0 deletions news_article.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

## IBM Acquires HashiCorp: A Game-Changer in Hybrid Cloud Platform Innovation

### Overview
In a landmark transaction, IBM has officially announced its acquisition of HashiCorp Inc. for an impressive $6.4 billion, cashing in at $35 per share. This strategic move is set to redefine the contours of the hybrid cloud market, integrating HashiCorp's robust capabilities in multi-cloud infrastructure automation with IBM's expansive technology ecosystem. This article delves into the strategic imperatives of the acquisition and its potential to revolutionize the industry by fostering an integrated hybrid cloud platform optimized for the AI era.

### Genesis of a Tech Giant Collaboration
Arvind Krishna, IBM's Chairman and CEO, emphasized that the acquisition is a strategic response to the escalating complexity within enterprise IT environments, exacerbated by the rapid proliferation of multi-cloud and hybrid infrastructures and the generative AI revolution. HashiCorp, renowned for its pioneering products like Terraform and Vault, provides critical tools that enable effective lifecycle management across diverse cloud environments. This acquisition is not just a merger of technologies but a confluence of visions aimed at simplifying the inherent complexities of modern IT infrastructure.

### Enhancing Hybrid Cloud Capabilities
The fusion of IBM and HashiCorp promises extensive enhancements to hybrid cloud capabilities. For instance, HashiCorp's Terraform complements IBM’s existing enterprise solutions, potentially transforming infrastructure management by providing a unified workflow for provisioning both cloud-based and on-premises resources. IBM's strategy appears twofold: to deepen its cloud management prowess while simultaneously advancing its stake in the burgeoning AI-centric market, which is increasingly reliant on diverse and scalable cloud infrastructures.

### Strategic Synergies and Financial Prospects
The deal is strategically aligned with IBM’s ongoing investment in hybrid cloud and AI technologies, areas identified by the tech giant as crucial for its future growth. Financially, the acquisition is poised to be immediately accretive to IBM’s adjusted EBITDA post-closing, with expected substantial margin expansion due to synergistic efficiencies between the two companies' offerings. Moreover, HashiCorp’s strong customer base, including industry giants like Bloomberg and Vodafone, combined with its impressive revenue growth, positions IBM to potentially enhance its market share and financial performance in the cloud sector.

### Future Outlook and Integration Strategy
Looking forward, the integration strategy centers around maintaining HashiCorp’s brand and operational independence within IBM’s larger framework. This approach is intended to preserve HashiCorp’s innovative culture and core values while leveraging IBM's extensive market reach and industrial expertise. The overarching goal is to create a holistic platform that not only aligns with but also propels the current and future requirements of hybrid cloud and AI applications across various industries.

### Takeaways
- The acquisition of HashiCorp by IBM for $6.4 billion marks a significant enhancement of IBM's capabilities in hybrid cloud and automation technologies.
- HashiCorp’s strengths in multi-cloud infrastructure automation are a strategic fit within IBM’s broader technology and business strategy.
- Financially, the acquisition is expected to contribute positively to IBM's profitability metrics and market positioning in the hybrid cloud space.
- The strategic integration of IBM and HashiCorp's technologies aims to create a comprehensive end-to-end platform that addresses the dynamic and complex nature of modern digital infrastructures.

### References
- [IBM to Acquire HashiCorp, Inc. Creating a Comprehensive End-to-End Hybrid Cloud Platform](https://newsroom.ibm.com/2024-04-24-IBM-to-Acquire-HashiCorp-Inc-Creating-a-Comprehensive-End-to-End-Hybrid-Cloud-Platform)
- [IBM moves deeper into hybrid cloud management with $6.4B HashiCorp acquisition](https://techcrunch.com/2024/04/24/ibm-moves-deeper-into-hybrid-cloud-management-with-6-4b-hashicorp-acquisition/)
- [IBM Acquires HashiCorp for $6.4 Billion, Expanding Hybrid Cloud Offerings](https://www.techrepublic.com/article/ibm-hashicorp-acquisition/)
Loading

0 comments on commit d734646

Please sign in to comment.