theRealNG commited on
Commit
68e1277
·
1 Parent(s): a4529fb

migrate to gemini llm

Browse files
agents/article_evaluator.py CHANGED
@@ -9,10 +9,10 @@ article_evaluator = Agent(
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
  )
 
9
  verbose=True,
10
  backstory=(
11
  "You are a Recommended Article Evaluator, you are strict in your evaluation. "
12
+ "You evaluate articles based on the user's learning profile. "
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 CHANGED
@@ -12,5 +12,5 @@ curiosity_catalyst = Agent(
12
  "for reading the articles."
13
  ),
14
  allow_delegation=False,
15
- # llm=gemini
16
  )
 
12
  "for reading the articles."
13
  ),
14
  allow_delegation=False,
15
+ llm=gemini
16
  )
agents/learning_curator.py CHANGED
@@ -14,5 +14,5 @@ learning_curator = Agent(
14
  ),
15
  allow_delegation=False,
16
  tools=[scrape_tool, search_tool],
17
- # llm=gemini
18
  )
 
14
  ),
15
  allow_delegation=False,
16
  tools=[scrape_tool, search_tool],
17
+ llm=gemini
18
  )
agents/learning_profiler.py CHANGED
@@ -6,11 +6,11 @@ learning_profiler = Agent(
6
  role="Personal Learning Profiler",
7
  goal="Make sure to create an excellent learning profile of the user based on his interests and previous reading history.",
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
  )
 
6
  role="Personal Learning Profiler",
7
  goal="Make sure to create an excellent learning profile of the user based on his interests and previous reading history.",
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 interests that the user has. "
13
  ),
14
  allow_delegation=False,
15
+ llm=gemini
16
  )
app.py CHANGED
@@ -4,13 +4,15 @@ load_dotenv()
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":
 
9
  "Agentic Design Patterns (https://www.deeplearning.ai/the-batch/how-agents-can-improve-llm-performance/)\n"
10
  "Reflection: The LLM examines its own work to come up with ways to improve it. "
11
  "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. "
12
  "Planning: The LLM comes up with, and executes, a multistep plan to achieve a goal "
13
  "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.\n\n"
 
14
  "GenAI Multi-Agent Systems (https://thenewstack.io/genai-multi-agent-systems-a-secret-weapon-for-tech-teams/)\n"
15
  "Multi-agent systems go beyond the task-oriented roles to truly super-charge development and strategy teams. "
16
  "Successful multi-agent systems act as a “digital twin” for your development team. "
@@ -20,3 +22,4 @@ result = article_recommendation_crew.kickoff(inputs={
20
  })
21
 
22
  print(result)
 
 
4
  from crew.article_suggestion import article_recommendation_crew
5
 
6
  result = article_recommendation_crew.kickoff(inputs={
7
+ "interests": "Ruby On Rails, Architecture, Go Lang",
8
  "previous_article_insights":
9
+
10
  "Agentic Design Patterns (https://www.deeplearning.ai/the-batch/how-agents-can-improve-llm-performance/)\n"
11
  "Reflection: The LLM examines its own work to come up with ways to improve it. "
12
  "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. "
13
  "Planning: The LLM comes up with, and executes, a multistep plan to achieve a goal "
14
  "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.\n\n"
15
+
16
  "GenAI Multi-Agent Systems (https://thenewstack.io/genai-multi-agent-systems-a-secret-weapon-for-tech-teams/)\n"
17
  "Multi-agent systems go beyond the task-oriented roles to truly super-charge development and strategy teams. "
18
  "Successful multi-agent systems act as a “digital twin” for your development team. "
 
22
  })
23
 
24
  print(result)
25
+ print("Usage Metrics:\n", article_recommendation_crew.usage_metrics)
crew/article_suggestion.py CHANGED
@@ -14,5 +14,13 @@ article_recommendation_crew = Crew(
14
  tasks=[learning_profile_task, article_suggestion_task, evaluation_task, article_pitch_task],
15
  verbose=True,
16
  memory=True,
17
- # manager_llm=gemini
 
 
 
 
 
 
 
 
18
  )
 
14
  tasks=[learning_profile_task, article_suggestion_task, evaluation_task, article_pitch_task],
15
  verbose=True,
16
  memory=True,
17
+ manager_llm=gemini,
18
+ embedder={
19
+ "provider": "google",
20
+ "config":{
21
+ "model": 'models/embedding-001',
22
+ "task_type": "retrieval_document",
23
+ "title": "Embeddings for Embedchain"
24
+ }
25
+ }
26
  )
llms/gemini.py CHANGED
@@ -1,3 +1,4 @@
1
  from langchain_google_genai import ChatGoogleGenerativeAI
 
2
 
3
  gemini=ChatGoogleGenerativeAI(model="gemini-1.5-flash",verbose=True)
 
1
  from langchain_google_genai import ChatGoogleGenerativeAI
2
+ import os
3
 
4
  gemini=ChatGoogleGenerativeAI(model="gemini-1.5-flash",verbose=True)
requirements.txt CHANGED
@@ -2,4 +2,4 @@ python-dotenv
2
  crewai
3
  crewai_tools
4
  langchain_community
5
- langchain-google-genai
 
2
  crewai
3
  crewai_tools
4
  langchain_community
5
+ langchain_google_genai
tasks/create_article_pitch.py CHANGED
@@ -5,14 +5,14 @@ from utils.recommended_article import RecommendedArticles
5
 
6
  article_pitch_task = Task(
7
  description=(
8
- "Create a pitch for each of the articles that have passed evaluation. "
9
  "Craft the pitch so to that it teases the article's most intriguing aspects, "
10
  "by posing questions that the article might answer or "
11
  "highlighting surprising facts to pique the user's curiosity "
12
  " to read the article for incremental learning."
13
  ),
14
  expected_output=(
15
- "Json array of all the artilces that have passed evaluation phase. Each article should have the following keys title, article_url, pitch and reason behind the recommedation"
16
  ),
17
  output_json=RecommendedArticles,
18
  tools=[scrape_tool],
 
5
 
6
  article_pitch_task = Task(
7
  description=(
8
+ "Create a pitch only for the articles that have passed evaluation and none other links. "
9
  "Craft the pitch so to that it teases the article's most intriguing aspects, "
10
  "by posing questions that the article might answer or "
11
  "highlighting surprising facts to pique the user's curiosity "
12
  " to read the article for incremental learning."
13
  ),
14
  expected_output=(
15
+ "List of all the artilces that have passed evaluation phase."
16
  ),
17
  output_json=RecommendedArticles,
18
  tools=[scrape_tool],
tasks/create_learning_profile.py CHANGED
@@ -1,16 +1,25 @@
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
  )
 
1
  from crewai import Task
2
  from agents.learning_profiler import learning_profiler
3
+ from utils.learning_profile import LearningProfile
4
 
5
  learning_profile_task = Task(
6
  description=(
7
+ # "Create a Learning profile of the user based on his following interests {interests} "
8
+ # "and based on the following articles and insights he has read in the past: \n"
9
+ # "{previous_article_insights}"
10
+ "Create a Learning profile of the user based on "
11
+ "the following articles and insights he has read in the past: \n"
12
  "{previous_article_insights}"
13
  ),
14
  expected_output=(
15
  "A structured learning profile of the user with his interests, topics he has read about "
16
+ "and any other information you feel is relavant. Be precise."
17
+ # "A structured learning profile. "
18
+ # "The learning profile should only contain a section called 'Topics of interest' and 'Insights'. "
19
+ # "It should not have any other sections such as summary or conclusion. "
20
+ # "'Insights' section should contain the insights captured by the user and they should be grouped by topic."
21
  ),
22
  agent=learning_profiler,
23
+ output_json=LearningProfile,
24
  async_execution=False
25
  )
utils/learning_profile.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pydantic import BaseModel
2
+ from typing import List
3
+
4
+
5
+ class Topic(BaseModel):
6
+ name: str
7
+ insights: List[str]
8
+
9
+
10
+ class LearningProfile(BaseModel):
11
+ topics_of_interests: List[str]
12
+ learnings: List[Topic]