WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
E0000 00:00:1735796581.437522 19888 init.cc:229] grpc_wait_for_shutdown_with_timeout() timed out.
Hi @pschoudhary
Thank you for reaching out and using Phidata! We’re currently easing into the New Year, so the team might take a bit longer than usual to respond, but we’ll aim to get back to you within 24 hours. I’ve also tagged the relevant engineers to assist you with your query.
If this is urgent, please let us know, and we’ll do our best to prioritize it.
Thanks for your understanding and patience, and Happy New Year!
@pschoudhary can you help me with your code to help you better?
here is my code
import os
from phi.model import Agent
from phi.storage.agent.sqlite import SqlAgentStorage
from phi.model.google import Gemini
from phi.tools.googlesearch import GoogleSearch
from phi.storage.agent.sqlite import SqlAgentStorage
from phi.playground import Playground, serve_playground_app
from dotenv import load_dotenv
load_dotenv()
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
GOOGLE_ENGINE_ID = os.getenv("GOOGLE_ENGINE_ID")
web_search_agent=Agent(
name="web_search_agent",
role="Researcher Agent",
description="Your goal is to assists in content research by gathering, analyzing, and summarizing information on specified topics.",
instructions="""
Your goal is to assists in content research by gathering, analyzing, and summarizing information on specified topics.
### You are conducting keyword research and identifying trending topics relevant to the content strategy.
- This involves using various tools and techniques to identify keywords and topics that are relevant to the content strategy of the organization.
- Keyword research helps in understanding what topics are popular among the target audience and what keywords are commonly used in search queries related to the organization's industry or niche.
- Identifying trending topics allows the organization to capitalize on current trends and create content that is timely and relevant.
### Also, you are collecting data and insights from reputable sources to support content creation.
- This involves gathering data and information from reputable sources such as research papers, industry reports, authoritative websites, and credible publications.
- The collected data and insights serve as valuable resources for content creation, providing facts, statistics, case studies, and other supporting evidence to strengthen the content's credibility and relevance.
- Data collection may include conducting surveys, interviews, or market research to gather firsthand insights from target audiences or industry experts.
### Finally, you are proving summaries and briefs to human content creators to streamline their research phase.
- This responsibility entails summarizing the gathered information and insights into concise and actionable briefs for human content creators.
- Summaries and briefs help content creators quickly grasp the key points and main findings of the research, saving time and effort during the content creation process.
- By providing organized and digestible summaries, the AI Research Assistant enables content creators to focus on creative ideation, storytelling, and content development rather than spending excessive time on research and information gathering.
""",
tools=[GoogleSearch()],
markdown=True,
model=Gemini(id="gemini-2.0-flash-exp"),
add_datetime_to_instructions=True,
show_tool_calls=True,
)
content_creator_agent=Agent(
role="Content Creator",
tools=[GoogleSearch()],
description="you are a senior NYT editor and your task is to write the New yourk times worthy cover story. Your goal is to generate initial drafts of content based on templates, guidelines, and inputs for the research phase.",
instructions="""
Your goal is to generate initial drafts of content based on templates, guidelines, and inputs for the research phase.
- **Creating Initial Content Drafts for Various Formats:** This involves using natural language generation (NLG) technologies to generate preliminary drafts of content in different formats, such as blog posts, articles, and social media updates. NLG technologies use algorithms to analyze data and generate human-like text based on predefined rules, templates, or machine learning models. By leveraging NLG, content creators can quickly generate draft content that can then be refined and customized as needed.
- **Adhering to Brand Voice, Style Guides, and Content Objectives:** Content creators must ensure that the generated content aligns with the brand's voice and adheres to established style guides and content objectives. This includes maintaining consistency in tone, language, and messaging across all content assets to reinforce the brand identity and messaging strategy. Content strategists may provide guidelines and objectives to ensure that the content effectively communicates the brand's values, resonates with the target audience, and supports broader marketing goals.
- **Generating Creative Ideas for Content:** In addition to generating draft content, content creators are responsible for brainstorming and developing creative ideas for content campaigns. This includes crafting engaging headlines, taglines, and calls-to-action that capture the audience's attention and compel them to take action. Creativity is essential in devising unique and compelling content concepts that differentiate the brand from competitors and resonate with the target audience's interests and preferences.
""",
model=Gemini(id="gemini-2.0-flash-exp"),
show_tool_calls=True,
add_datetime_to_instructions=True,
)
seo_analyst_agent = Agent(
tools=[GoogleSearch()],
role="SEO Analyst",
description="Optimizes content for search engines and improves content discoverability online.",
instructions="""
Optimizes content for search engines and improves content discoverability online.
- **Analyzing Content for SEO Best Practices:** Content analysts assess content to ensure it adheres to SEO best practices, including keyword density, meta descriptions, and title tags. This optimization enhances content visibility and ranking on search engine results pages (SERPs).
- **Recommending Improvements to Enhance Content Ranking:** Content analysts suggest improvements based on their analysis to enhance content ranking. This includes suggesting additional keywords, refining meta descriptions, and optimizing title tags to increase relevance and authority in the eyes of search engines.
- **Monitoring Content Performance and Providing Insights:** Content analysts continuously monitor content performance, including organic search traffic and user engagement metrics. They provide insights for content optimization by identifying underperforming content and recognizing successful content strategies for future campaigns. These insights drive continuous improvement in search engine visibility and performance.
""",
model=Gemini(id="gemini-2.0-flash-exp"),
storage=SqlAgentStorage(table_name="seo_analyst_agent_session", db_file="tmp/agents.db"),
show_tool_calls=True,
add_datetime_to_instructions=True,
)
editorial_assistant_agent = Agent(
role = "Editorial Assistant",
description= "Your goal is to implement a review process to check the content for accuracy, coherence, grammar, and style. Make necessary adjustments.",
instructions="""
Your goal is to implement a review process to check the content for accuracy, coherence, grammar, and style. Make necessary adjustments.
- Detailed Grammar and Spelling Checks: The Editorial Assistant meticulously examines content to identify and rectify any grammatical or spelling errors. This involves scrutinizing each sentence and paragraph to ensure correctness in language usage.
- Stylistic Adjustments:
In addition to grammar and spelling, the Editorial Assistant makes stylistic adjustments to harmonize content with the publication's designated tone and style guidelines. This involves refining sentences, adjusting word choices, and ensuring consistency throughout the text.
- Conducting Final Reviews:
The Editorial Assistant performs thorough final reviews to verify the readiness of content for publication. This entails assessing all aspects of the content, including grammar, spelling, style, formatting, and adherence to publication standards.
""",
model=Gemini(id="gemini-2.0-flash-exp"),
add_datetime_to_instructions=True,
)
multi_agent=Agent(
model=Gemini(id="gemini-2.0-flash-exp"),
team=[web_search_agent, content_creator_agent, seo_analyst_agent, editorial_assistant_agent],
show_tool_calls=True,
markdown=True,
add_datetime_to_instructions=True,
#debug_mode=True,
)
#TO RUN IT AS AN CHAT APPLICATION IN TERMINAL
multi_agent.cli_app(stream=False, show_full_reasoning=True)
@pschoudhary this code worked for me
import os
from phi.agent import Agent
from phi.storage.agent.sqlite import SqlAgentStorage
from phi.model.google import Gemini
from phi.tools.googlesearch import GoogleSearch
from phi.storage.agent.sqlite import SqlAgentStorage
from phi.playground import Playground, serve_playground_app
from dotenv import load_dotenv
load_dotenv()
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
GOOGLE_ENGINE_ID = os.getenv("GOOGLE_ENGINE_ID")
web_search_agent=Agent(
name="web_search_agent",
role="Researcher Agent",
description="Your goal is to assists in content research by gathering, analyzing, and summarizing information on specified topics.",
instructions="""
Your goal is to assists in content research by gathering, analyzing, and summarizing information on specified topics.
### You are conducting keyword research and identifying trending topics relevant to the content strategy.
- This involves using various tools and techniques to identify keywords and topics that are relevant to the content strategy of the organization.
- Keyword research helps in understanding what topics are popular among the target audience and what keywords are commonly used in search queries related to the organization's industry or niche.
- Identifying trending topics allows the organization to capitalize on current trends and create content that is timely and relevant.
### Also, you are collecting data and insights from reputable sources to support content creation.
- This involves gathering data and information from reputable sources such as research papers, industry reports, authoritative websites, and credible publications.
- The collected data and insights serve as valuable resources for content creation, providing facts, statistics, case studies, and other supporting evidence to strengthen the content's credibility and relevance.
- Data collection may include conducting surveys, interviews, or market research to gather firsthand insights from target audiences or industry experts.
### Finally, you are proving summaries and briefs to human content creators to streamline their research phase.
- This responsibility entails summarizing the gathered information and insights into concise and actionable briefs for human content creators.
- Summaries and briefs help content creators quickly grasp the key points and main findings of the research, saving time and effort during the content creation process.
- By providing organized and digestible summaries, the AI Research Assistant enables content creators to focus on creative ideation, storytelling, and content development rather than spending excessive time on research and information gathering.
""",
tools=[GoogleSearch()],
markdown=True,
model=Gemini(id="gemini-2.0-flash-exp"),
add_datetime_to_instructions=True,
show_tool_calls=True,
)
content_creator_agent=Agent(
role="Content Creator",
tools=[GoogleSearch()],
description="you are a senior NYT editor and your task is to write the New yourk times worthy cover story. Your goal is to generate initial drafts of content based on templates, guidelines, and inputs for the research phase.",
instructions="""
Your goal is to generate initial drafts of content based on templates, guidelines, and inputs for the research phase.
- **Creating Initial Content Drafts for Various Formats:** This involves using natural language generation (NLG) technologies to generate preliminary drafts of content in different formats, such as blog posts, articles, and social media updates. NLG technologies use algorithms to analyze data and generate human-like text based on predefined rules, templates, or machine learning models. By leveraging NLG, content creators can quickly generate draft content that can then be refined and customized as needed.
- **Adhering to Brand Voice, Style Guides, and Content Objectives:** Content creators must ensure that the generated content aligns with the brand's voice and adheres to established style guides and content objectives. This includes maintaining consistency in tone, language, and messaging across all content assets to reinforce the brand identity and messaging strategy. Content strategists may provide guidelines and objectives to ensure that the content effectively communicates the brand's values, resonates with the target audience, and supports broader marketing goals.
- **Generating Creative Ideas for Content:** In addition to generating draft content, content creators are responsible for brainstorming and developing creative ideas for content campaigns. This includes crafting engaging headlines, taglines, and calls-to-action that capture the audience's attention and compel them to take action. Creativity is essential in devising unique and compelling content concepts that differentiate the brand from competitors and resonate with the target audience's interests and preferences.
""",
model=Gemini(id="gemini-2.0-flash-exp"),
show_tool_calls=True,
add_datetime_to_instructions=True,
)
seo_analyst_agent = Agent(
tools=[GoogleSearch()],
role="SEO Analyst",
description="Optimizes content for search engines and improves content discoverability online.",
instructions="""
Optimizes content for search engines and improves content discoverability online.
- **Analyzing Content for SEO Best Practices:** Content analysts assess content to ensure it adheres to SEO best practices, including keyword density, meta descriptions, and title tags. This optimization enhances content visibility and ranking on search engine results pages (SERPs).
- **Recommending Improvements to Enhance Content Ranking:** Content analysts suggest improvements based on their analysis to enhance content ranking. This includes suggesting additional keywords, refining meta descriptions, and optimizing title tags to increase relevance and authority in the eyes of search engines.
- **Monitoring Content Performance and Providing Insights:** Content analysts continuously monitor content performance, including organic search traffic and user engagement metrics. They provide insights for content optimization by identifying underperforming content and recognizing successful content strategies for future campaigns. These insights drive continuous improvement in search engine visibility and performance.
""",
model=Gemini(id="gemini-2.0-flash-exp"),
storage=SqlAgentStorage(table_name="seo_analyst_agent_session", db_file="tmp/agents.db"),
show_tool_calls=True,
add_datetime_to_instructions=True,
)
editorial_assistant_agent = Agent(
role = "Editorial Assistant",
description= "Your goal is to implement a review process to check the content for accuracy, coherence, grammar, and style. Make necessary adjustments.",
instructions="""
Your goal is to implement a review process to check the content for accuracy, coherence, grammar, and style. Make necessary adjustments.
- Detailed Grammar and Spelling Checks: The Editorial Assistant meticulously examines content to identify and rectify any grammatical or spelling errors. This involves scrutinizing each sentence and paragraph to ensure correctness in language usage.
- Stylistic Adjustments:
In addition to grammar and spelling, the Editorial Assistant makes stylistic adjustments to harmonize content with the publication's designated tone and style guidelines. This involves refining sentences, adjusting word choices, and ensuring consistency throughout the text.
- Conducting Final Reviews:
The Editorial Assistant performs thorough final reviews to verify the readiness of content for publication. This entails assessing all aspects of the content, including grammar, spelling, style, formatting, and adherence to publication standards.
""",
model=Gemini(id="gemini-2.0-flash-exp"),
add_datetime_to_instructions=True,
)
multi_agent=Agent(
model=Gemini(id="gemini-2.0-flash-exp"),
team=[web_search_agent, content_creator_agent, seo_analyst_agent, editorial_assistant_agent],
show_tool_calls=True,
markdown=True,
add_datetime_to_instructions=True,
#debug_mode=True,
)
#TO RUN IT AS AN CHAT APPLICATION IN TERMINAL
multi_agent.cli_app(stream=False, show_full_reasoning=True)
not working properly for me sometimes it works fine but sometimes it crashed without giving the complete output or in the middle of the output.
It’s a little difficult to help on the network side of things as it’s not under our control
I am also getting the same issue. Plus I am unable to get data from knowledge base.
from phi.agent import Agent
from phi.knowledge.pdf import PDFUrlKnowledgeBase
from phi.vectordb.pgvector import PgVector, SearchType
from phi.model.google import Gemini
from phi.embedder.google import GeminiEmbedder
# Create a knowledge base from a PDF
knowledge_base = PDFUrlKnowledgeBase(
urls=["https://phi-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"],
# Use LanceDB as the vector database
vector_db=PgVector(
table_name="recipes",
db_url="postgresql+psycopg://ai:ai@localhost:5532/ai",
search_type=SearchType.hybrid,
embedder=GeminiEmbedder(dimensions=768),
),
)
# Comment out after first run as the knowledge base is loaded
#knowledge_base.load(recreate=False)
agent = Agent(
model=Gemini(id="gemini-1.5-flash"),
# Add the knowledge base to the agent
knowledge=knowledge_base,
show_tool_calls=True,
search_knowledge=True,
read_chat_history=True,
#markdown=True,
debug_mode=True,
)
# agent.print_response("How do I make chicken and galangal in coconut milk soup", stream=True)
#agent.print_response("What was my last question?", stream=True)
agent.print_response(
"Hi, i want to make a 3 course meal. Can you recommend some recipes. "
"I'd like to start with a soup, then im thinking a thai curry for the main course and finish with a dessert",
stream=True,
)
Response it like
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ How do I make chicken and galangal in coconut milk soup ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (2.0s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ I am sorry, I cannot find a recipe for chicken and galangal in coconut milk soup using the available tools. I do not have ┃
┃ access to the internet or external websites to search for recipes. ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
E0000 00:00:1736618835.609415 1205889 init.cc:232] grpc_wait_for_shutdown_with_timeout() timed out.
I can we embeddings in my pgvector in my local…but agent is not able to retrieve it. Please help me on that.
Just a comment on the original question, that warning comes from grpcio, a package that gemini’s python client uses. We are all waiting until it is patched. It is a non-lethal warning, but if it bothers you, you can manually run pip install grpcio==1.60.1
@puru2901is as Dirk said you can remove that warning by running pip install grpcio==1.60.1
on the terminal. As for the agent not being able to retrieve from Knowledge Base. Can you try adding explicit instructions for the agent to use the knowledge base?
agent = Agent(
...
instructions=["Use knowledge base to retrieve recipes"]
...
)
Keep fine tuning the instructions until it works. Let me know if this works for you