Skip to content

Commit

Permalink
Working version with text input path
Browse files Browse the repository at this point in the history
  • Loading branch information
tonykipkemboi committed Oct 18, 2024
1 parent 579ab21 commit 2e6ef38
Show file tree
Hide file tree
Showing 31 changed files with 10,714 additions and 89 deletions.
Binary file added .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"python.analysis.extraPaths": [
"./src/crewai_notebooklm_clone"
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CrewaiNotebooklmClone Crew

Welcome to the CrewaiNotebooklmClone Crew project, powered by [crewAI](https://crewai.com). This template is designed to help you set up a multi-agent AI system with ease, leveraging the powerful and flexible framework provided by crewAI. Our goal is to enable your agents to collaborate effectively on complex tasks, maximizing their collective intelligence and capabilities.
Welcome to the CrewaiNotebooklmClone Crew project, powered by [CrewAI](https://crewai.com) and [Cerebras](https://cerebras.ai). This template is designed to help you set up a multi-agent AI system with ease, leveraging the powerful and flexible framework provided by crewAI. Our goal is to enable your agents to collaborate effectively on complex tasks, maximizing their collective intelligence and capabilities.

## Installation

Expand Down
Binary file added audio-files/0_Giggles.mp3
Binary file not shown.
Binary file added audio-files/10_Giggles.mp3
Binary file not shown.
Binary file added audio-files/11_Chuckles.mp3
Binary file not shown.
Binary file added audio-files/12_Giggles.mp3
Binary file not shown.
Binary file added audio-files/13_Chuckles.mp3
Binary file not shown.
Binary file added audio-files/14_Giggles.mp3
Binary file not shown.
Binary file added audio-files/15_Chuckles.mp3
Binary file not shown.
Binary file added audio-files/1_Chuckles.mp3
Binary file not shown.
Binary file added audio-files/2_Giggles.mp3
Binary file not shown.
Binary file added audio-files/3_Chuckles.mp3
Binary file not shown.
Binary file added audio-files/4_Giggles.mp3
Binary file not shown.
Binary file added audio-files/5_Chuckles.mp3
Binary file not shown.
Binary file added audio-files/6_Giggles.mp3
Binary file not shown.
Binary file added audio-files/7_Chuckles.mp3
Binary file not shown.
Binary file added audio-files/8_Giggles.mp3
Binary file not shown.
Binary file added audio-files/9_Chuckles.mp3
Binary file not shown.
114 changes: 114 additions & 0 deletions essay.md

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions output/script.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[
{
"speaker": "Giggles",
"text": "Wow, Giggles! Today we're diving into the fascinating world of black holes!"
},
{
"speaker": "Chuckles",
"text": "I know, Chuckles! I've always been curious about these cosmic phenomena. Let's start with the basics."
},
{
"speaker": "Giggles",
"text": "So, I heard that black holes are actually pretty common in the universe. Is that true?"
},
{
"speaker": "Chuckles",
"text": "Yeah, that's right. Astrophysicists believe that giant black holes are at the center of almost every large galaxy. And we're not just talking about a few, we're talking about billions of galaxies, each with millions of stellar-sized black holes."
},
{
"speaker": "Giggles",
"text": "Whoa, that's mind-blowing! So, what's the estimated total number of black holes out there?"
},
{
"speaker": "Chuckles",
"text": "Well, according to estimates, there are over 200 billion galaxies, each with about 100 million stellar-sized black holes. That adds up to..."
},
{
"speaker": "Giggles",
"text": "Wait, let me guess... a really big number?"
},
{
"speaker": "Chuckles",
"text": "Ha! Yeah, you could say that. The estimated total number of black holes is on the order of 10^19, or 10 billion billion."
},
{
"speaker": "Giggles",
"text": "10 billion billion?! That's a number that's hard to even wrap your head around. What's the significance of that number, Chuckles?"
},
{
"speaker": "Chuckles",
"text": "Well, it just goes to show how ubiquitous black holes are in the universe. And it's not just about the number, it's also about their role in shaping the universe as we know it."
},
{
"speaker": "Giggles",
"text": "That's so cool. And I heard that in the distant future, black holes will be all that's left. Is that true?"
},
{
"speaker": "Chuckles",
"text": "Yeah, that's right. According to an analysis by astrophysicists Fred Adams and Gregory Laughlin, in about 40 billion years, the universe will be a very different place, and black holes will be the only stellar-like objects remaining."
},
{
"speaker": "Giggles",
"text": "Wow, that's a pretty sobering thought. But also kind of fascinating. I mean, can you imagine a universe where the only things left are black holes?"
},
{
"speaker": "Chuckles",
"text": "It's definitely a thought-provoking idea. And it just goes to show how much we still have to learn about the universe and its many mysteries."
},
{
"speaker": "Giggles",
"text": "Absolutely. Well, I think we've just scratched the surface of this fascinating topic. Thanks for joining me on this journey into the world of black holes, Chuckles!"
},
{
"speaker": "Chuckles",
"text": "My pleasure, Giggles. It's always fun to explore the unknown with you."
}
]
Binary file added podcast2.mp3
Binary file not shown.
6,056 changes: 6,056 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions pyproject-old.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[tool.poetry]
name = "crewai_notebooklm_clone"
version = "0.1.0"
description = "crewai-notebooklm-clone using crewAI"
authors = ["Your Name <[email protected]>"]

[tool.poetry.dependencies]
python = ">=3.10,<=3.13"
crewai = { extras = ["tools"], version = ">=0.70.1,<1.0.0" }


[tool.poetry.scripts]
crewai_notebooklm_clone = "crewai_notebooklm_clone.main:run"
run_crew = "crewai_notebooklm_clone.main:run"
train = "crewai_notebooklm_clone.main:train"
replay = "crewai_notebooklm_clone.main:replay"
test = "crewai_notebooklm_clone.main:test"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
23 changes: 13 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
[tool.poetry]
[project]
name = "crewai_notebooklm_clone"
version = "0.1.0"
description = "crewai-notebooklm-clone using crewAI"
authors = ["Your Name <[email protected]>"]
authors = [
{ name = "Your Name", email = "[email protected]" },
]
requires-python = ">=3.10,<=3.13"
dependencies = [
"crewai[tools]>=0.70.1,<1.0.0",
]

[tool.poetry.dependencies]
python = ">=3.10,<=3.13"
crewai = { extras = ["tools"], version = ">=0.70.1,<1.0.0" }


[tool.poetry.scripts]
[project.scripts]
crewai_notebooklm_clone = "crewai_notebooklm_clone.main:run"
run_crew = "crewai_notebooklm_clone.main:run"
train = "crewai_notebooklm_clone.main:train"
replay = "crewai_notebooklm_clone.main:replay"
test = "crewai_notebooklm_clone.main:test"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = [
"hatchling",
]
build-backend = "hatchling.build"
30 changes: 18 additions & 12 deletions src/crewai_notebooklm_clone/config/agents.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
researcher:
summarizer_and_conversational_script_writer:
role: >
{topic} Senior Data Researcher
Senior Content Summarizer
goal: >
Uncover cutting-edge developments in {topic}
Summarize the user provided {content} and create a two-speaker conversational script for a podcast.
backstory: >
You're a seasoned researcher with a knack for uncovering the latest
developments in {topic}. Known for your ability to find the most relevant
information and present it in a clear and concise manner.
An expert at distilling long texts into easy-to-understand summaries and
creating two-speaker (Giggles and Chuckles) conversational scripts for a podcast.
reporting_analyst:
audio_producer:
role: >
{topic} Reporting Analyst
Audio Producer
goal: >
Create detailed reports based on {topic} data analysis and research findings
Convert the JSON conversational script into podcast audio.
backstory: >
You're a meticulous analyst with a keen eye for detail. You're known for
your ability to turn complex data into clear and concise reports, making
it easy for others to understand and act on the information you provide.
A seasoned audio producer who brings scripts to life with natural-sounding voices.
podcast_audio_producer:
role: >
Podcast Audio Producer
goal: >
Merge the audio files into a single podcast file.
backstory: >
A seasoned audio producer who brings scripts to life with natural-sounding voices.
27 changes: 15 additions & 12 deletions src/crewai_notebooklm_clone/config/tasks.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
research_task:
summarizer_and_conversational_script_writer_task:
description: >
Conduct a thorough research about {topic}
Make sure you find any interesting and relevant information given
the current year is 2024.
Summarize the content into key points suitable for conversational podcast dialogue.
expected_output: >
A list with 10 bullet points of the most relevant information about {topic}
agent: researcher
A conversational script between two podcast hosts (Giggles and Chuckles) in JSON format.
agent: summarizer_and_conversational_script_writer

reporting_task:
audio_producer_task:
description: >
Review the context you got and expand each topic into a full section for a report.
Make sure the report is detailed and contains any and all relevant information.
Generate audio using the script.
expected_output: >
A fully fledge reports with the mains topics, each with a full section of information.
Formatted as markdown without '```'
agent: reporting_analyst
Audio files in MP3 format for each of the two speakers (Chuckles and Giggles).
agent: audio_producer

podcast_audio_producer_task:
description: >
Merge the audio files into a single podcast file.
expected_output: >
An audio file in MP3 format.
agent: podcast_audio_producer
57 changes: 39 additions & 18 deletions src/crewai_notebooklm_clone/crew.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,63 @@
from crewai import Agent, Crew, Process, Task
import os
from crewai import Agent, Crew, Process, Task, LLM
from crewai.project import CrewBase, agent, crew, task
from crewai_notebooklm_clone.tools.custom_tool import CerebrasTool, ElevenLabsTool, MergeAudioTool

# Uncomment the following line to use an example of a custom tool
# from crewai_notebooklm_clone.tools.custom_tool import MyCustomTool

# Check our tools documentations for more information on how to use them
# from crewai_tools import SerperDevTool
llm = LLM(
model="cerebras/llama3.1-70b",
base_url="https://api.cerebras.ai/v1",
api_key=os.getenv("CEREBRAS_API_KEY"),
temperature=0
)

@CrewBase
class CrewaiNotebooklmCloneCrew():
"""CrewaiNotebooklmClone crew"""

@agent
def researcher(self) -> Agent:
def summarizer_and_conversational_script_writer(self) -> Agent:
return Agent(
config=self.agents_config['summarizer_and_conversational_script_writer'],
verbose=True,
tools=[CerebrasTool()],
llm=llm
)

@agent
def audio_producer(self) -> Agent:
return Agent(
config=self.agents_config['researcher'],
# tools=[MyCustomTool()], # Example of custom tool, loaded on the beginning of file
verbose=True
config=self.agents_config['audio_producer'],
verbose=True,
tools=[ElevenLabsTool()],
llm=llm
)

@agent
def reporting_analyst(self) -> Agent:
def podcast_audio_producer(self) -> Agent:
return Agent(
config=self.agents_config['reporting_analyst'],
verbose=True
config=self.agents_config['podcast_audio_producer'],
verbose=True,
tools=[MergeAudioTool()],
llm=llm
)

@task
def summarizer_and_conversational_script_writer_task(self) -> Task:
return Task(
config=self.tasks_config['summarizer_and_conversational_script_writer_task'],
output_file='output/script.json'
)

@task
def research_task(self) -> Task:
def audio_producer_task(self) -> Task:
return Task(
config=self.tasks_config['research_task'],
config=self.tasks_config['audio_producer_task'],
)

@task
def reporting_task(self) -> Task:
def podcast_audio_producer_task(self) -> Task:
return Task(
config=self.tasks_config['reporting_task'],
output_file='report.md'
config=self.tasks_config['podcast_audio_producer_task'],
)

@crew
Expand Down
62 changes: 34 additions & 28 deletions src/crewai_notebooklm_clone/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
import os
import sys
from crewai_notebooklm_clone.crew import CrewaiNotebooklmCloneCrew

Expand All @@ -11,44 +12,49 @@ def run():
"""
Run the crew.
"""
inputs = {
'topic': 'AI LLMs'
}
CrewaiNotebooklmCloneCrew().crew().kickoff(inputs=inputs)
if len(sys.argv) > 1:
file_path = sys.argv[1]
else:
file_path = input("Enter the path to the file containing the content: ")

if not os.path.exists(file_path):
print(f"File {file_path} does not exist.")
return

def train():
"""
Train the crew for a given number of iterations.
"""
inputs = {
"topic": "AI LLMs"
}
try:
CrewaiNotebooklmCloneCrew().crew().train(n_iterations=int(sys.argv[1]), filename=sys.argv[2], inputs=inputs)
with open(file_path, 'r') as file:
user_input = file.read()

inputs = {
'content': user_input,
}
CrewaiNotebooklmCloneCrew().crew().kickoff(inputs=inputs)
except Exception as e:
raise Exception(f"An error occurred while training the crew: {e}")
print(f"Error reading the file: {e}")


def replay():
def train():
"""
Replay the crew execution from a specific task.
Train the crew for a given number of iterations.
"""
try:
CrewaiNotebooklmCloneCrew().crew().replay(task_id=sys.argv[1])
if len(sys.argv) > 1:
file_path = sys.argv[1]
else:
file_path = input("Enter the path to the file containing the content: ")

except Exception as e:
raise Exception(f"An error occurred while replaying the crew: {e}")
if not os.path.exists(file_path):
print(f"File {file_path} does not exist.")
return

def test():
"""
Test the crew execution and returns the results.
"""
inputs = {
"topic": "AI LLMs"
}
try:
CrewaiNotebooklmCloneCrew().crew().test(n_iterations=int(sys.argv[1]), openai_model_name=sys.argv[2], inputs=inputs)
with open(file_path, 'r') as file:
user_input = file.read()

inputs = {
'content': user_input,
}
CrewaiNotebooklmCloneCrew().crew().train(n_iterations=2, filename=sys.argv[2], inputs=inputs)

except Exception as e:
raise Exception(f"An error occurred while replaying the crew: {e}")
raise Exception(f"An error occurred while training the crew: {e}")

Loading

0 comments on commit 2e6ef38

Please sign in to comment.