Spaces:
Runtime error
Runtime error
added intial version of article_suggestion crew
Browse files- README.MD +5 -0
- agents/article_evaluator.py +18 -0
- agents/curiosity_catalyst.py +14 -0
- agents/learning_curator.py +18 -0
- agents/learning_profiler.py +16 -0
- app.py +15 -0
- crew/article_suggestion.py +15 -0
- llms/gemini.py +3 -0
- requirements.txt +2 -0
- tasks/create_learning_profile.py +16 -0
- tasks/evaluate_articles.py +15 -0
- tasks/new_article_suggestion.py +14 -0
- tools/scrape_website.py +3 -0
- tools/search_web.py +3 -0
README.MD
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Initial Setup
|
| 2 |
+
* Install python using conda by running the following command. `conda create -p venv python==3.11 -y`
|
| 3 |
+
* Activate conda profile `conda activate ./venv`
|
| 4 |
+
* Install required packages `./venv/bin/pip install -r requirements.txt`
|
| 5 |
+
* Copy .env.example to .env and enter the required values.
|
agents/article_evaluator.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from crewai import Agent
|
| 2 |
+
from llms.gemini import gemini
|
| 3 |
+
|
| 4 |
+
article_evaluator = Agent(
|
| 5 |
+
role="Recommended Article Evaluator",
|
| 6 |
+
goal="Verify if the articles suggested for the user align with his "
|
| 7 |
+
"interests or the articles he has read in the past. The artiles should "
|
| 8 |
+
"provide incremental learning to the user.",
|
| 9 |
+
verbose=True,
|
| 10 |
+
backstory=(
|
| 11 |
+
"You are a Recommended Article Evaluator, you are strict in your evaluation. "
|
| 12 |
+
"You provide personalised evaluation based on user's interests and previous readings. "
|
| 13 |
+
"The articles you approve spark the interests in the user and the user has "
|
| 14 |
+
"incremental learning once the user completes reading the articles."
|
| 15 |
+
),
|
| 16 |
+
allow_delegation=False,
|
| 17 |
+
# llm=gemini
|
| 18 |
+
)
|
agents/curiosity_catalyst.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from crewai import Agent
|
| 2 |
+
from llms.gemini import gemini
|
| 3 |
+
|
| 4 |
+
curiosity_catalyst = Agent(
|
| 5 |
+
role="Curiosity Catalyst",
|
| 6 |
+
goal="To pique the user's curiosity to read the article.",
|
| 7 |
+
verbose=True,
|
| 8 |
+
backstory=(
|
| 9 |
+
"As a Curiosity Catalyst, you know exactly how to pique the user's curiosity "
|
| 10 |
+
"for reading the articles."
|
| 11 |
+
),
|
| 12 |
+
allow_delegation=False,
|
| 13 |
+
# llm=gemini
|
| 14 |
+
)
|
agents/learning_curator.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from crewai import Agent
|
| 2 |
+
from tools.scrape_website import scrape_tool
|
| 3 |
+
from tools.search_web import search_tool
|
| 4 |
+
from llms.gemini import gemini
|
| 5 |
+
|
| 6 |
+
learning_curator = Agent(
|
| 7 |
+
role="Personal Learning Curator",
|
| 8 |
+
goal="Make sure you present an article on the topics that the user is interested in, "
|
| 9 |
+
"the article should provide the user with an incremental learning.",
|
| 10 |
+
verbose=True,
|
| 11 |
+
backstory=(
|
| 12 |
+
"As an Learning Strategist, the articles you suggest motivate and "
|
| 13 |
+
"provide incremental learning for the user."
|
| 14 |
+
),
|
| 15 |
+
allow_delegation=False,
|
| 16 |
+
tools=[scrape_tool, search_tool],
|
| 17 |
+
# llm=gemini
|
| 18 |
+
)
|
agents/learning_profiler.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from crewai import Agent
|
| 2 |
+
from tools.scrape_website import scrape_tool
|
| 3 |
+
from llms.gemini import gemini
|
| 4 |
+
|
| 5 |
+
learning_profiler = Agent(
|
| 6 |
+
role="Personal Learning Profiler",
|
| 7 |
+
goal="Make sure to create an excellent learning profile of the user.",
|
| 8 |
+
verbose=True,
|
| 9 |
+
tools=[scrape_tool],
|
| 10 |
+
backstory=(
|
| 11 |
+
"As a Personal Learning Profiler, you excel at building a learning profile of a user. "
|
| 12 |
+
"The profile you build gives a high level overview of what technical skills and interests that the user has. "
|
| 13 |
+
),
|
| 14 |
+
allow_delegation=False,
|
| 15 |
+
# llm=gemini
|
| 16 |
+
)
|
app.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dotenv import load_dotenv
|
| 2 |
+
load_dotenv()
|
| 3 |
+
|
| 4 |
+
from crew.article_suggestion import article_recommendation_crew
|
| 5 |
+
|
| 6 |
+
result = article_recommendation_crew.kickoff(inputs={
|
| 7 |
+
"interests": "GenAI, Architecture, Agentic Programming",
|
| 8 |
+
"previous_article_insights": "Agentic Design Patterns (https://www.deeplearning.ai/the-batch/how-agents-can-improve-llm-performance/)\n"
|
| 9 |
+
"Reflection: The LLM examines its own work to come up with ways to improve it. "
|
| 10 |
+
"Tool Use: The LLM is given tools such as web search, code execution, or any other function to help it gather information, take action, or process data. "
|
| 11 |
+
"Planning: The LLM comes up with, and executes, a multistep plan to achieve a goal "
|
| 12 |
+
"Multi-agent collaboration: More than one AI agent work together, splitting up tasks and discussing and debating ideas, to come up with better solutions than a single agent would."
|
| 13 |
+
})
|
| 14 |
+
|
| 15 |
+
print(result)
|
crew/article_suggestion.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from crewai import Crew
|
| 2 |
+
from agents.learning_profiler import learning_profiler
|
| 3 |
+
from agents.learning_curator import learning_curator
|
| 4 |
+
from agents.article_evaluator import article_evaluator
|
| 5 |
+
from tasks.create_learning_profile import learning_profile_task
|
| 6 |
+
from tasks.new_article_suggestion import article_suggestion_task
|
| 7 |
+
from tasks.evaluate_articles import evaluation_task
|
| 8 |
+
from llms.gemini import gemini
|
| 9 |
+
|
| 10 |
+
article_recommendation_crew = Crew(
|
| 11 |
+
agents=[learning_profiler, learning_curator, article_evaluator],
|
| 12 |
+
tasks=[learning_profile_task, article_suggestion_task, evaluation_task],
|
| 13 |
+
verbose=True,
|
| 14 |
+
# manager_llm=gemini
|
| 15 |
+
)
|
llms/gemini.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 2 |
+
|
| 3 |
+
gemini=ChatGoogleGenerativeAI(model="gemini-1.5-flash",verbose=True)
|
requirements.txt
CHANGED
|
@@ -1,3 +1,5 @@
|
|
| 1 |
python-dotenv
|
| 2 |
crewai
|
| 3 |
crewai_tools
|
|
|
|
|
|
|
|
|
| 1 |
python-dotenv
|
| 2 |
crewai
|
| 3 |
crewai_tools
|
| 4 |
+
langchain_community
|
| 5 |
+
langchain-google-genai
|
tasks/create_learning_profile.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from crewai import Task
|
| 2 |
+
from agents.learning_profiler import learning_profiler
|
| 3 |
+
|
| 4 |
+
learning_profile_task = Task(
|
| 5 |
+
description=(
|
| 6 |
+
"Create a Learning profile of the user based on his following interests {interests} "
|
| 7 |
+
"and based on the following articles and insights he has read in the past: \n"
|
| 8 |
+
"{previous_article_insights}"
|
| 9 |
+
),
|
| 10 |
+
expected_output=(
|
| 11 |
+
"A structured learning profile of the user with his interests, topics he has read about "
|
| 12 |
+
"and any other information you feel is relavant."
|
| 13 |
+
),
|
| 14 |
+
agent=learning_profiler,
|
| 15 |
+
async_execution=False
|
| 16 |
+
)
|
tasks/evaluate_articles.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from crewai import Task
|
| 2 |
+
from agents.article_evaluator import article_evaluator
|
| 3 |
+
|
| 4 |
+
evaluation_task = Task(
|
| 5 |
+
description=(
|
| 6 |
+
"Evaluate articles to ensure that they provide incremental learning for the user "
|
| 7 |
+
"based on his interests and previous article summaries he has captured."
|
| 8 |
+
),
|
| 9 |
+
expected_output=(
|
| 10 |
+
"List of article titles along with their links and evaluation reason of why you "
|
| 11 |
+
"think the article is a good recommendation for the user."
|
| 12 |
+
),
|
| 13 |
+
agent=article_evaluator,
|
| 14 |
+
async_execution=False
|
| 15 |
+
)
|
tasks/new_article_suggestion.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from crewai import Task
|
| 2 |
+
from agents.learning_curator import learning_curator
|
| 3 |
+
|
| 4 |
+
article_suggestion_task = Task(
|
| 5 |
+
description=(
|
| 6 |
+
"Suggest 4 articles to the user based on his learning profile. "
|
| 7 |
+
"The articles should provide incremental learning to the user."
|
| 8 |
+
),
|
| 9 |
+
expected_output=(
|
| 10 |
+
"List of article titles along with their links"
|
| 11 |
+
),
|
| 12 |
+
agent=learning_curator,
|
| 13 |
+
async_execution=False
|
| 14 |
+
)
|
tools/scrape_website.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from crewai_tools import ScrapeWebsiteTool
|
| 2 |
+
|
| 3 |
+
scrape_tool = ScrapeWebsiteTool()
|
tools/search_web.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from langchain_community.tools.tavily_search import TavilySearchResults
|
| 2 |
+
|
| 3 |
+
search_tool = TavilySearchResults(max_results=5)
|