Skip to content

Commit 10b0d98

Browse files
committed
Numerous updates and new features added to the project.
1 parent 7f68d78 commit 10b0d98

31 files changed

+1874
-112
lines changed

‎AI_Agents.db

20 KB
Binary file not shown.

‎agent_tweeter.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import time
2+
3+
import py_trees
4+
5+
from playground.behavior_trees import (
6+
create_assistant_action,
7+
)
8+
9+
# Create the root node (sequence)
10+
root = py_trees.composites.Sequence("RootSequence", memory=True)
11+
12+
selector = py_trees.composites.Selector("Search Selector", memory=True)
13+
root.add_child(selector)
14+
15+
16+
def get_search_instructions():
17+
return """
18+
Use the function/tool get_search_term to load a search term from the list of search terms.
19+
Query the "{search_term}" to search for "this week" videos on YouTube.
20+
Use the filter "this week" to search for videos on YouTube.
21+
then for each video download the transcript and summarize it for relevance to {search_term}
22+
be sure to include a link to each of the videos,
23+
and then save all the transcript summarizations to a file called youtube_transcripts.txt
24+
Make sure to save the search term at the top of the file.
25+
Always make sure to use save_file tool/function to save the file before moving on.
26+
If you encounter any errors, please return just the word FAILURE.
27+
"""
28+
29+
30+
search_youtube_action = create_assistant_action(
31+
action_name="Search YouTube",
32+
assistant_name="YouTube Researcher v3",
33+
assistant_instructions=get_search_instructions(),
34+
)
35+
selector.add_child(search_youtube_action)
36+
37+
write_post_action = create_assistant_action(
38+
action_name="Write Post",
39+
assistant_name="Twitter Post Writer",
40+
assistant_instructions="""
41+
Load the file called youtube_transcripts.txt,
42+
analyze the contents for references to search term at the top and then select
43+
the most exciting and relevant video related to:
44+
eduction, tutorials, news or current events, to post on Twitter.
45+
Avoid any negative or controversial content.
46+
Avoid any content that is not relevant to the search term.
47+
Avoid content that promotes a business, jobs, real estate or investments.
48+
Then write a Twitter post that is relevant to the video,
49+
and always include a link to the video, along
50+
with exciting highlights or mentions,
51+
and post it to the Twitter outbox.
52+
Remember to always include a link to the video and always
53+
use the post_to_twitter_outbox tool/function to post the content.
54+
If you encounter any errors, please return just the word FAILURE.
55+
""",
56+
)
57+
root.add_child(write_post_action)
58+
59+
cleanup_action = create_assistant_action(
60+
action_name="Cleanup",
61+
assistant_name="File Manager",
62+
assistant_instructions="""
63+
Delete the youtube_transcripts.txt file.
64+
If you encounter any errors, please return just the word FAILURE.
65+
""",
66+
)
67+
root.add_child(cleanup_action)
68+
69+
70+
# Create the behavior tree
71+
tree = py_trees.trees.BehaviourTree(root)
72+
73+
# Tick the tree to run it
74+
while True:
75+
tree.tick()
76+
time.sleep(30) # Simulate time between ticks

‎blogging_agents.py

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import random
2+
import time
3+
4+
import py_trees
5+
6+
from playground.behavior_trees import (
7+
create_assistant_action,
8+
)
9+
10+
# Create the root node (sequence)
11+
root = py_trees.composites.Sequence("RootSequence", memory=True)
12+
13+
selector = py_trees.composites.Selector("Search Selector", memory=True)
14+
root.add_child(selector)
15+
16+
17+
def get_search_instructions(search_term):
18+
return f"""
19+
Search Term: {search_term}
20+
Use the query "{search_term}" to search for this weeks videos on YouTube. Set the publish time filter to "this week".
21+
then for each video download the transcript and determine its relevance to the {search_term}
22+
From the collection of transcripts select a single common technology theme or topic that is relevant to the search term.
23+
Summarize the content that is relevant to the single technology theme/topic into 5 paragraphs,
24+
and then save all the summarized content to a file called youtube_transcripts.txt
25+
If you encounter any errors, please return just the word FAILURE.
26+
"""
27+
28+
29+
search_terms = [
30+
"AI Agents In Action",
31+
"AI Agents In Games",
32+
"AI News",
33+
"AI in Games",
34+
"AI Business News",
35+
"AI Music",
36+
"AI Video",
37+
"AI Startups",
38+
"AI Innovations and New Technolgoy",
39+
"AI in Medicine",
40+
"AI in Education",
41+
"AI in Agriculture",
42+
"AI in Transportation",
43+
"AI in Space",
44+
"AI in Robotics",
45+
"AI in Manufacturing",
46+
"AI in Retail",
47+
"AI in Finance",
48+
"AI in Sports",
49+
"AI in Entertainment",
50+
"AI in Art",
51+
"AI in Fashion",
52+
"AI in Travel",
53+
"AI in Environment",
54+
"AI in Energy",
55+
"AI in Security",
56+
"AI in Politics",
57+
"AI in Society",
58+
"AI in Health",
59+
"AI in Science",
60+
"AI in Technology",
61+
"AI in Engineering",
62+
"AI in Research",
63+
"AI in Software Development",
64+
]
65+
66+
for i in range(10):
67+
search_term = random.choice(search_terms)
68+
search_terms.remove(search_term)
69+
search_youtube_action = create_assistant_action(
70+
action_name=f"Search YouTube({search_term})",
71+
assistant_name="YouTube Blog Researcher",
72+
assistant_instructions=get_search_instructions(search_term),
73+
)
74+
selector.add_child(search_youtube_action)
75+
76+
# search_term = "AI Agents In Games"
77+
# search_youtube_action = create_assistant_action(
78+
# action_name=f"Search YouTube({search_term})",
79+
# assistant_name="YouTube Blog Researcher",
80+
# assistant_instructions=get_search_instructions(search_term),
81+
# )
82+
# selector.add_child(search_youtube_action)
83+
84+
# search_term = "AI News"
85+
# search_youtube_action = create_assistant_action(
86+
# action_name=f"Search YouTube({search_term})",
87+
# assistant_name="YouTube Blog Researcher",
88+
# assistant_instructions=get_search_instructions(search_term),
89+
# )
90+
# selector.add_child(search_youtube_action)
91+
92+
write_blog_action = create_assistant_action(
93+
action_name="Write blog",
94+
assistant_name="Medium Blogger",
95+
assistant_instructions="""
96+
Load the file called youtube_transcripts.txt,
97+
analyze the contents for references to the search term
98+
at the top of the file and then select
99+
the most exciting and relevant content related to the search term but also:
100+
news, noteworthy, and informative, to blog on Medium.
101+
102+
Write a blog in Word docx that is relevant to the content of the summarizations,
103+
Be sure the blog captures the spirit of the themes and topic content,
104+
The name of the file should be {search term}_blog_{timestamp}.docx (You can get the timestamp using the get_current_timestamp() tool/function.)
105+
RULES:
106+
Avoid quoting individuals or organizations but rather generalize their statements.
107+
Focus on new and innovative content.
108+
Be sure to highlight the technology theme/topic that was summarized.
109+
Make sure and add a compelling title for the blog post.
110+
111+
If you encounter any errors, please return just the word FAILURE.
112+
""",
113+
)
114+
root.add_child(write_blog_action)
115+
116+
post_action = create_assistant_action(
117+
action_name="Post",
118+
assistant_name="File Manager",
119+
assistant_instructions="""
120+
Delete the youtube_transcripts.txt file.
121+
If you encounter any errors, please return just the word FAILURE.
122+
""",
123+
)
124+
root.add_child(post_action)
125+
126+
127+
# Create the behavior tree
128+
tree = py_trees.trees.BehaviourTree(root)
129+
130+
# Tick the tree to run it
131+
while True:
132+
tree.tick()
133+
time.sleep(30) # Simulate time between ticks

‎blogging_agents_v2.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import time
2+
3+
import py_trees
4+
5+
from playground.behavior_trees import (
6+
create_assistant_action,
7+
)
8+
9+
# Create the root node (sequence)
10+
root = py_trees.composites.Sequence("RootSequence", memory=True)
11+
12+
selector = py_trees.composites.Selector("Search Selector", memory=True)
13+
root.add_child(selector)
14+
15+
16+
def get_search_instructions():
17+
return """
18+
Use the function/tool get_search_term to load a search term from the list of search terms.
19+
Query the "{search_term}" to search for "this week" videos on YouTube.
20+
Use the filter "this week" to search for videos on YouTube.
21+
then for each video download the transcript and summarize it for relevance to {search_term}
22+
be sure to include a link to each of the videos,
23+
and then save all the transcript summarizations to a file called youtube_transcripts.txt
24+
Make sure to save the search term at the top of the file.
25+
Always make sure to use save_file tool/function to save the file before moving on.
26+
If you encounter any errors, please return just the word FAILURE.
27+
"""
28+
29+
30+
search_youtube_action = create_assistant_action(
31+
action_name="Search YouTube",
32+
assistant_name="YouTube Researcher v3",
33+
assistant_instructions=get_search_instructions(),
34+
)
35+
selector.add_child(search_youtube_action)
36+
37+
write_blog_action = create_assistant_action(
38+
action_name="Write blog",
39+
assistant_name="Medium Blogger",
40+
assistant_instructions="""
41+
Load the file called youtube_transcripts.txt,
42+
analyze the contents for references to the search term
43+
at the top of the file and then select
44+
the most exciting and relevant content related to the search term but also:
45+
educational, tutorial, informative, demonstation, to blog on Medium.
46+
47+
Write a blog in Word docx that is relevant to the content of the summarizations,
48+
Be sure the blog captures the spirit of the themes and topic content,
49+
The name of the file should be {search term}_blog_{timestamp}.docx (You can get the timestamp using the get_current_timestamp() tool/function.)
50+
RULES:
51+
Avoid quoting individuals or organizations but rather generalize their statements.
52+
Be sure to add references to the video links in the blog post.
53+
Focus on new and innovative content.
54+
Be sure to highlight the technology theme/topic that was summarized.
55+
Make sure and add a compelling title for the blog post.
56+
57+
At the top of the blog under the first section add the following disclainer in full:
58+
Disclaimer: this blog is entirely written by a team of agents including the images, layout and content. The process works by having the agents search, review and summarize the transcripts of YouTube videos, the summarized content is then written into a blog. If you want to understand more check out my book AI Agents In Action. My contribution is the selection of the stories to publish, copy/pasting content and writing the agents.
59+
60+
If you encounter any errors, please return just the word FAILURE.
61+
""",
62+
)
63+
root.add_child(write_blog_action)
64+
65+
post_action = create_assistant_action(
66+
action_name="Post",
67+
assistant_name="File Manager",
68+
assistant_instructions="""
69+
Delete the youtube_transcripts.txt file.
70+
If you encounter any errors, please return just the word FAILURE.
71+
""",
72+
)
73+
root.add_child(post_action)
74+
75+
76+
# Create the behavior tree
77+
tree = py_trees.trees.BehaviourTree(root)
78+
79+
# Tick the tree to run it
80+
while True:
81+
tree.tick()
82+
time.sleep(30) # Simulate time between ticks

‎blogging_agents_v3.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import time
2+
3+
import py_trees
4+
5+
from playground.behavior_trees import (
6+
create_assistant_action,
7+
)
8+
9+
# Create the root node (sequence)
10+
root = py_trees.composites.Sequence("RootSequence", memory=True)
11+
12+
selector = py_trees.composites.Selector("Search Selector", memory=True)
13+
root.add_child(selector)
14+
15+
16+
def get_search_instructions():
17+
return """
18+
Use the function/tool get_search_term to load a search term from the list of search terms.
19+
Query the "{search_term}" to search for "this week" videos on YouTube.
20+
Use the filter "this week" to search for videos on YouTube.
21+
then for each video download the transcript and determine relevance to the {search_term}
22+
then select a single video that is most relevant to the search term.
23+
Summarize the content of the video into 5 paragraphs,
24+
be sure to include a link to the video and highlight the link as a reference for the content.
25+
and then save the transcript summarizations to a file called youtube_transcripts.txt
26+
Make sure to save the search term at the top of the file.
27+
Always make sure to use save_file tool/function to save the file before moving on.
28+
If you encounter any errors, please return just the word FAILURE.
29+
"""
30+
31+
32+
search_youtube_action = create_assistant_action(
33+
action_name="Search YouTube",
34+
assistant_name="YouTube Researcher v3",
35+
assistant_instructions=get_search_instructions(),
36+
)
37+
selector.add_child(search_youtube_action)
38+
39+
write_blog_action = create_assistant_action(
40+
action_name="Write blog",
41+
assistant_name="Medium Blogger",
42+
assistant_instructions="""
43+
Load the file called youtube_transcripts.txt,
44+
analyze the contents for references to the search term
45+
at the top of the file and then select
46+
the most exciting and relevant content related to the search term but also:
47+
educational, tutorial, informative, demonstation, to blog on Medium.
48+
49+
Write a blog in Word docx that is relevant to the content of the summarization,
50+
Be sure the blog captures the spirit of the themes and topic content,
51+
The name of the file should be {search term}_blog_{timestamp}.docx (You can get the timestamp using the get_current_timestamp() tool/function.)
52+
RULES:
53+
Avoid quoting individuals or organizations but rather generalize their statements.
54+
IMPORTANT: Be sure to add a reference to the video link in the blog post.
55+
Focus on new and innovative content.
56+
Be sure to highlight the technology theme/topic that was summarized.
57+
Make sure and add a compelling title for the blog post.
58+
59+
At the top of the blog under the first section add the following disclainer in full:
60+
Disclaimer: this blog is entirely written by a team of agents including the images, layout and content. The process works by having the agents search, review and summarize the transcripts of YouTube videos, the summarized content is then written into a blog. If you want to understand more check out my book AI Agents In Action. My contribution is the selection of the stories to publish, copy/pasting content and writing the agents.
61+
As your last operation write the blog filename to a file called blog_filenames.txt.
62+
If you encounter any errors, please return just the word FAILURE.
63+
""",
64+
)
65+
root.add_child(write_blog_action)
66+
67+
post_action = create_assistant_action(
68+
action_name="Post",
69+
assistant_name="Medium Post Writer",
70+
assistant_instructions="""
71+
Load the blog_filenames.txt file and to located Word docx file to load the blog content.
72+
Load the blog content for the Word docx file.
73+
Write a post about the blog content for the following platforms: LinkedIn, Twitter, Reddit.
74+
Save each of the post contents to a file called {word docx filename}_post_{platform name}.txt.
75+
If you encounter any errors, please return just the word FAILURE.
76+
""",
77+
)
78+
root.add_child(post_action)
79+
80+
cleanup_action = create_assistant_action(
81+
action_name="Cleanup",
82+
assistant_name="File Manager",
83+
assistant_instructions="""
84+
Delete the youtube_transcripts.txt file.
85+
Delete the blog_filenames.txt file.
86+
If you encounter any errors, please return just the word FAILURE.
87+
""",
88+
)
89+
root.add_child(cleanup_action)
90+
91+
92+
# Create the behavior tree
93+
tree = py_trees.trees.BehaviourTree(root)
94+
95+
96+
# Tick the tree to run it
97+
while True:
98+
tree.tick()
99+
time.sleep(30) # Simulate time between ticks

0 commit comments

Comments
 (0)