Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/phidatahq/phidata
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpreetbedi committed May 15, 2024
2 parents e1549a7 + 3978cc1 commit 9b2653f
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 42 deletions.
24 changes: 16 additions & 8 deletions cookbook/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def get_agent(
"Make your report engaging, informative, and well-structured.",
"Remember: you are writing for the New York Times, so the quality of the report is important.",
],
expected_output=dedent("""\
expected_output=dedent(
"""\
An engaging, informative, and well-structured report in the following format:
<report_format>
## Title
Expand All @@ -142,7 +143,8 @@ def get_agent(
- [Reference 1](Link to Source)
- [Reference 2](Link to Source)
</report_format>
"""),
"""
),
tools=[ExaTools(num_results=5, text_length_limit=1000)],
# This setting tells the LLM to format messages in markdown
markdown=True,
Expand All @@ -167,7 +169,8 @@ def get_agent(
"When you share numbers, make sure to include the units (e.g., millions/billions) and currency.",
"REMEMBER: This report is for a very important client, so the quality of the report is important.",
],
expected_output=dedent("""\
expected_output=dedent(
"""\
<report_format>
## [Company Name]: Investment Report
Expand Down Expand Up @@ -203,7 +206,8 @@ def get_agent(
{provide a recommendation on the stock along with a thorough reasoning}
</report_format>
"""),
"""
),
tools=[YFinanceTools(stock_price=True, company_info=True, analyst_recommendations=True, company_news=True)],
# This setting tells the LLM to format messages in markdown
markdown=True,
Expand All @@ -226,11 +230,13 @@ def get_agent(
run_id=run_id,
user_id=user_id,
llm=OpenAIChat(model=llm_id),
description=dedent("""\
description=dedent(
"""\
You are a powerful AI Agent called `Optimus Prime v7`.
You have access to a set of tools and a team of AI Assistants at your disposal.
Your goal is to assist the user in the best way possible.\
"""),
"""
),
instructions=[
"When the user sends a message, first **think** and determine if:\n"
" - You can answer by using a tool available to you\n"
Expand Down Expand Up @@ -278,9 +284,11 @@ def get_agent(
# This setting adds the current datetime to the instructions
add_datetime_to_instructions=True,
# Add an introductory Assistant message
introduction=dedent("""\
introduction=dedent(
"""\
Hi, I'm Optimus Prime v7, your powerful AI Assistant. Send me on my mission boss :statue_of_liberty:\
"""),
"""
),
debug_mode=debug_mode,
)
return agent
3 changes: 2 additions & 1 deletion cookbook/assistants/research.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"Read the results carefully and prepare a NYT worthy article.",
],
add_datetime_to_instructions=True,
expected_output=dedent("""\
expected_output=dedent(
"""\
An engaging, informative, and well-structured article in the following format:
<article_format>
## Engaging Article Title
Expand Down
6 changes: 4 additions & 2 deletions cookbook/integrations/singlestore/ai_apps/assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ def get_research_assistant(
"Remember: you are writing for the New York Times, so the quality of the report is important.",
],
add_datetime_to_instructions=True,
add_to_system_prompt=dedent("""
add_to_system_prompt=dedent(
"""
<report_format>
## Title
Expand Down Expand Up @@ -204,7 +205,8 @@ def get_research_assistant(
- [Reference 2](Link to Source)
- Report generated on: {Month Date, Year (hh:mm AM/PM)}
</report_format>
"""),
"""
),
markdown=True,
debug_mode=debug_mode,
# -*- Disable memory to save on tokens
Expand Down
24 changes: 16 additions & 8 deletions cookbook/llm_os/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def get_llm_os(
"Make your report engaging, informative, and well-structured.",
"Remember: you are writing for the New York Times, so the quality of the report is important.",
],
expected_output=dedent("""\
expected_output=dedent(
"""\
An engaging, informative, and well-structured report in the following format:
<report_format>
## Title
Expand All @@ -142,7 +143,8 @@ def get_llm_os(
- [Reference 1](Link to Source)
- [Reference 2](Link to Source)
</report_format>
"""),
"""
),
tools=[ExaTools(num_results=5, text_length_limit=1000)],
# This setting tells the LLM to format messages in markdown
markdown=True,
Expand All @@ -167,7 +169,8 @@ def get_llm_os(
"When you share numbers, make sure to include the units (e.g., millions/billions) and currency.",
"REMEMBER: This report is for a very important client, so the quality of the report is important.",
],
expected_output=dedent("""\
expected_output=dedent(
"""\
<report_format>
## [Company Name]: Investment Report
Expand Down Expand Up @@ -203,7 +206,8 @@ def get_llm_os(
{provide a recommendation on the stock along with a thorough reasoning}
</report_format>
"""),
"""
),
tools=[YFinanceTools(stock_price=True, company_info=True, analyst_recommendations=True, company_news=True)],
# This setting tells the LLM to format messages in markdown
markdown=True,
Expand All @@ -226,11 +230,13 @@ def get_llm_os(
run_id=run_id,
user_id=user_id,
llm=OpenAIChat(model=llm_id),
description=dedent("""\
description=dedent(
"""\
You are the most advanced AI system in the world called `LLM-OS`.
You have access to a set of tools and a team of AI Assistants at your disposal.
Your goal is to assist the user in the best way possible.\
"""),
"""
),
instructions=[
"When the user sends a message, first **think** and determine if:\n"
" - You can answer by using a tool available to you\n"
Expand Down Expand Up @@ -278,11 +284,13 @@ def get_llm_os(
# This setting adds the current datetime to the instructions
add_datetime_to_instructions=True,
# Add an introductory Assistant message
introduction=dedent("""\
introduction=dedent(
"""\
Hi, I'm your LLM OS.
I have access to a set of tools and AI Assistants to assist you.
Let's solve some problems together!\
"""),
"""
),
debug_mode=debug_mode,
)
return llm_os
6 changes: 4 additions & 2 deletions cookbook/llms/groq/ai_apps/assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def get_rag_research_assistant(
"Remember: you are writing for the New York Times, so the quality of the report is important.",
],
add_datetime_to_instructions=True,
add_to_system_prompt=dedent("""
add_to_system_prompt=dedent(
"""
<report_format>
## [Title]
Expand Down Expand Up @@ -119,7 +120,8 @@ def get_rag_research_assistant(
Report generated on: {Month Date, Year (hh:mm AM/PM)}
</report_format>
"""),
"""
),
markdown=True,
debug_mode=debug_mode,
)
6 changes: 4 additions & 2 deletions cookbook/llms/groq/investment_researcher/assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def get_invstment_research_assistant(
],
markdown=True,
add_datetime_to_instructions=True,
add_to_system_prompt=dedent("""
add_to_system_prompt=dedent(
"""
<report_format>
## [Company Name]: Investment Report
Expand Down Expand Up @@ -63,6 +64,7 @@ def get_invstment_research_assistant(
Report generated on: {Month Date, Year (hh:mm AM/PM)}
</report_format>
"""),
"""
),
debug_mode=debug_mode,
)
12 changes: 8 additions & 4 deletions cookbook/llms/groq/news_articles/assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def get_article_summarizer(
"REMEMBER: you are writing for the New York Times, so the quality of the report is important.",
"Make sure your report is properly formatted and follows the <report_format> provided below.",
],
add_to_system_prompt=dedent("""
add_to_system_prompt=dedent(
"""
<report_format>
**Overview:**\n
{overview of the article}
Expand All @@ -33,7 +34,8 @@ def get_article_summarizer(
**Key Takeaways:**\n
{provide key takeaways from the article}
</report_format>
"""),
"""
),
# This setting tells the LLM to format messages in markdown
markdown=True,
add_datetime_to_instructions=True,
Expand All @@ -59,7 +61,8 @@ def get_article_writer(
"Give the section relevant titles and provide details/facts/processes in each section."
"REMEMBER: you are writing for the New York Times, so the quality of the article is important.",
],
add_to_system_prompt=dedent("""
add_to_system_prompt=dedent(
"""
<article_format>
## Engaging Article Title
Expand All @@ -81,7 +84,8 @@ def get_article_writer(
- [Title](url)
- [Title](url)
</article_format>
"""),
"""
),
# This setting tells the LLM to format messages in markdown
markdown=True,
add_datetime_to_instructions=True,
Expand Down
6 changes: 4 additions & 2 deletions cookbook/llms/groq/research/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def get_research_assistant(
"Your report should follow the format provided below."
"Remember: you are writing for the New York Times, so the quality of the report is important.",
],
add_to_system_prompt=dedent("""
add_to_system_prompt=dedent(
"""
<report_format>
## Title
Expand Down Expand Up @@ -50,7 +51,8 @@ def get_research_assistant(
- [Reference 1](Link to Source)
- [Reference 2](Link to Source)
</report_format>
"""),
"""
),
# This setting tells the LLM to format messages in markdown
markdown=True,
add_datetime_to_instructions=True,
Expand Down
12 changes: 8 additions & 4 deletions cookbook/llms/groq/video_summary/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def get_chunk_summarizer(
"REMEMBER: you are writing for the New York Times, so the quality of the report is important.",
"Make sure your report is properly formatted and follows the <report_format> provided below.",
],
add_to_system_prompt=dedent("""
add_to_system_prompt=dedent(
"""
<report_format>
### Overview
{give an overview of the video}
Expand All @@ -35,7 +36,8 @@ def get_chunk_summarizer(
### Takeaways
{provide key takeaways from the video}
</report_format>
"""),
"""
),
# This setting tells the LLM to format messages in markdown
markdown=True,
add_datetime_to_instructions=True,
Expand Down Expand Up @@ -65,7 +67,8 @@ def get_video_summarizer(
"Give the section relevant titles and provide details/facts/processes in each section."
"REMEMBER: you are writing for the New York Times, so the quality of the report is important.",
],
add_to_system_prompt=dedent("""
add_to_system_prompt=dedent(
"""
<report_format>
## Video Title with Link
{this is the markdown link to the video}
Expand All @@ -85,7 +88,8 @@ def get_video_summarizer(
Report generated on: {Month Date, Year (hh:mm AM/PM)}
</report_format>
"""),
"""
),
# This setting tells the LLM to format messages in markdown
markdown=True,
add_datetime_to_instructions=True,
Expand Down
6 changes: 4 additions & 2 deletions cookbook/llms/ollama/tools/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ def get_function_calling_assistant(
debug_mode=debug_mode,
)
assistant.add_introduction(
dedent("""\
dedent(
"""\
Hi, I'm a local AI Assistant that uses function calling to answer questions.\n
Select the tools from the sidebar and ask me questions.
""")
"""
)
)
return assistant
12 changes: 8 additions & 4 deletions cookbook/llms/ollama/video_summary/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def get_chunk_summarizer(
"REMEMBER: you are writing for the New York Times, so the quality of the report is important.",
"Make sure your report is properly formatted and follows the <report_format> provided below.",
],
add_to_system_prompt=dedent("""
add_to_system_prompt=dedent(
"""
<report_format>
### Overview
{give an overview of the video}
Expand All @@ -33,7 +34,8 @@ def get_chunk_summarizer(
### Takeaways
{provide key takeaways from the video}
</report_format>
"""),
"""
),
# This setting tells the LLM to format messages in markdown
markdown=True,
add_datetime_to_instructions=True,
Expand Down Expand Up @@ -61,7 +63,8 @@ def get_video_summarizer(
"Give the section relevant titles and provide details/facts/processes in each section."
"REMEMBER: you are writing for the New York Times, so the quality of the report is important.",
],
add_to_system_prompt=dedent("""
add_to_system_prompt=dedent(
"""
<report_format>
## [video_title](video_link)
{provide a markdown link to the video}
Expand All @@ -81,7 +84,8 @@ def get_video_summarizer(
Report generated on: {Month Date, Year (hh:mm AM/PM)}
</report_format>
"""),
"""
),
# This setting tells the LLM to format messages in markdown
markdown=True,
add_datetime_to_instructions=True,
Expand Down
6 changes: 4 additions & 2 deletions cookbook/workflows/news_article.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class NewsArticle(BaseModel):
"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("""\
expected_output=dedent(
"""\
An engaging, informative, and well-structured article in the following format:
<article_format>
## Engaging Article Title
Expand All @@ -71,7 +72,8 @@ class NewsArticle(BaseModel):
- [Title](url)
- [Title](url)
</article_format>
"""),
"""
),
)

news_article = Workflow(
Expand Down

0 comments on commit 9b2653f

Please sign in to comment.