theRealNG commited on
Commit
60ce749
·
1 Parent(s): d52ecfc

reafctors and providing context to tasks

Browse files
README.MD CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
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`
 
1
+ ---
2
+ title: ArticleRecommender
3
+ app_file: app.py
4
+ sdk: streamlit
5
+ sdk_version: 1.35.0
6
+ ---
7
+
8
  ### Initial Setup
9
  * Install python using conda by running the following command. `conda create -p venv python==3.11 -y`
10
  * Activate conda profile `conda activate ./venv`
agents/article_evaluator.py CHANGED
@@ -1,6 +1,7 @@
1
  from crewai import Agent
2
  from llms.gpt import llm
3
  from tools.helpers import streamlit_callback
 
4
 
5
  article_evaluator = Agent(
6
  role="Recommended Article Evaluator",
@@ -16,5 +17,6 @@ article_evaluator = Agent(
16
  ),
17
  allow_delegation=False,
18
  llm=llm,
 
19
  step_callback=streamlit_callback
20
  )
 
1
  from crewai import Agent
2
  from llms.gpt import llm
3
  from tools.helpers import streamlit_callback
4
+ from tools.scrape_website import scrape_tool
5
 
6
  article_evaluator = Agent(
7
  role="Recommended Article Evaluator",
 
17
  ),
18
  allow_delegation=False,
19
  llm=llm,
20
+ tools=[scrape_tool],
21
  step_callback=streamlit_callback
22
  )
app.py CHANGED
@@ -1,16 +1,16 @@
 
 
 
1
  import json
2
  import streamlit as st
3
 
4
  import utils.settings as settings
5
 
6
  from crew.article_suggestion import article_recommendation_crew
7
- from dotenv import load_dotenv
8
  from utils.write_to_json import write_dict_to_json as write_dict_to_json
9
 
10
  settings.init()
11
 
12
- load_dotenv()
13
-
14
 
15
  def icon(emoji: str):
16
  """Shows an emoji as a Notion-style page icon."""
@@ -41,12 +41,18 @@ def main():
41
  "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. "
42
  "Planning: The LLM comes up with, and executes, a multistep plan to achieve a goal "
43
  "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"
44
- # "GenAI Multi-Agent Systems (https://thenewstack.io/genai-multi-agent-systems-a-secret-weapon-for-tech-teams/)\n"
45
  "Multi-agent systems go beyond the task-oriented roles to truly super-charge development and strategy teams. "
46
  "Successful multi-agent systems act as a “digital twin” for your development team. "
47
  "Different Approaches: 1. Centralized, with one agent in the center that collects and assimilates all the other outputs. "
48
  "2. Distributed, where there is no central controller and the agents coordinate directly with one another in an “agent swarm. "
49
- "3. Hierarchical, where agents are organized in teams or hierarchical layers.\n",
 
 
 
 
 
 
50
  height=400,
51
  )
52
  st.markdown("") # Adding a blank space here
@@ -71,8 +77,9 @@ def main():
71
 
72
  st.subheader("", anchor=False, divider="rainbow")
73
 
74
- json_data = json.loads(result)
75
- articles_list = json_data.get("articles", None)
 
76
 
77
  if articles_list is None:
78
  st.markdown("No articles found.")
@@ -81,7 +88,10 @@ def main():
81
  for article in articles_list:
82
  st.markdown(f"# {article['title']}")
83
  st.markdown(f"**URL:** [{article['url']}]({article['url']})")
84
- st.markdown(f"**Pitch:** {article['pitch']}")
 
 
 
85
  st.markdown("---")
86
 
87
 
 
1
+ from dotenv import load_dotenv
2
+ load_dotenv()
3
+
4
  import json
5
  import streamlit as st
6
 
7
  import utils.settings as settings
8
 
9
  from crew.article_suggestion import article_recommendation_crew
 
10
  from utils.write_to_json import write_dict_to_json as write_dict_to_json
11
 
12
  settings.init()
13
 
 
 
14
 
15
  def icon(emoji: str):
16
  """Shows an emoji as a Notion-style page icon."""
 
41
  "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. "
42
  "Planning: The LLM comes up with, and executes, a multistep plan to achieve a goal "
43
  "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"
44
+ "GenAI Multi-Agent Systems (https://thenewstack.io/genai-multi-agent-systems-a-secret-weapon-for-tech-teams/)\n"
45
  "Multi-agent systems go beyond the task-oriented roles to truly super-charge development and strategy teams. "
46
  "Successful multi-agent systems act as a “digital twin” for your development team. "
47
  "Different Approaches: 1. Centralized, with one agent in the center that collects and assimilates all the other outputs. "
48
  "2. Distributed, where there is no central controller and the agents coordinate directly with one another in an “agent swarm. "
49
+ "3. Hierarchical, where agents are organized in teams or hierarchical layers.\n\n"
50
+ "LLM Model Quantisation\n"
51
+ "Different Methods for Compression: Pruning, Knowledge Distiallation and Quantization."
52
+ "Quantization process represents the model weights in lower precession which is also known as downcasting."
53
+ "Quanitzatoin Error is the difference in the weights of the quantized model and the original model."
54
+ "Advantages of Quanitzation: Reduced memory footprint, increased compute and speed of inferrence."
55
+ "Disadvantages of Quantization: Less precise.\n\n",
56
  height=400,
57
  )
58
  st.markdown("") # Adding a blank space here
 
77
 
78
  st.subheader("", anchor=False, divider="rainbow")
79
 
80
+ # json_data = json.loads(result)
81
+ # articles_list = json_data.get("articles", None)
82
+ articles_list = settings.articles.values()
83
 
84
  if articles_list is None:
85
  st.markdown("No articles found.")
 
88
  for article in articles_list:
89
  st.markdown(f"# {article['title']}")
90
  st.markdown(f"**URL:** [{article['url']}]({article['url']})")
91
+ st.markdown(f"**Pitch:** {article.get('pitch', '')}")
92
+ st.markdown(f"**Evaluation Score:** {article.get('evaluation_score', '')}")
93
+ st.markdown(f"**Evaluation Reason:** {article.get('evaluation_reason', '')}")
94
+ st.markdown(f"**Reason For Recommendation:** {article.get('reason_for_recommendation', '')}")
95
  st.markdown("---")
96
 
97
 
crew/article_suggestion.py CHANGED
@@ -15,7 +15,7 @@ article_recommendation_crew = Crew(
15
  tasks=[learning_profile_task, article_suggestion_task,
16
  evaluation_task, article_pitch_task],
17
  verbose=True,
18
- memory=True,
19
  manager_llm=llm,
20
  embedder={
21
  "provider": "openai",
@@ -23,5 +23,4 @@ article_recommendation_crew = Crew(
23
  "model": 'text-embedding-3-small'
24
  }
25
  }
26
- # manager_llm=gemini_client
27
  )
 
15
  tasks=[learning_profile_task, article_suggestion_task,
16
  evaluation_task, article_pitch_task],
17
  verbose=True,
18
+ # memory=True,
19
  manager_llm=llm,
20
  embedder={
21
  "provider": "openai",
 
23
  "model": 'text-embedding-3-small'
24
  }
25
  }
 
26
  )
requirements.txt CHANGED
@@ -4,3 +4,4 @@ crewai_tools
4
  langchain_community
5
  langchain_google_genai
6
  langchain_openai
 
 
4
  langchain_community
5
  langchain_google_genai
6
  langchain_openai
7
+ streamlit
tasks/create_article_pitch.py CHANGED
@@ -10,6 +10,8 @@ from typing import List
10
 
11
  from agents.curiosity_catalyst import curiosity_catalyst
12
  from tools.scrape_website import scrape_tool
 
 
13
 
14
 
15
  class PitchedArticle(BaseModel):
@@ -23,23 +25,23 @@ class PitchedArticles(BaseModel):
23
 
24
 
25
  def callback_function(output: TaskOutput):
26
- evaluated_articles = json.loads(output.exported_output)['articles']
27
  st.markdown(evaluated_articles)
28
- # for article in evaluated_articles:
29
- # settings.articles[article['url']]['pitch'] = article['pitch']
30
  st.markdown("### Create Article Pitch is executed successfully!")
31
 
32
 
33
  article_pitch_task = Task(
34
  description=(
35
- "Create a pitch only for the articles that have passed evaluation and no other links. "
36
  "Craft the pitch so to that it teases the article's most intriguing aspects, "
37
  "by posing questions that the article might answer or "
38
  "highlighting surprising facts to pique the user's curiosity "
39
  " to read the article for incremental learning."
40
  ),
41
  expected_output=(
42
- "List of all the artilces that have passed evaluation phase along with their url and pitch statement."
43
  ),
44
  output_json=PitchedArticles,
45
  output_file="pitched_articles.json",
@@ -47,4 +49,5 @@ article_pitch_task = Task(
47
  agent=curiosity_catalyst,
48
  async_execution=False,
49
  callback=callback_function,
 
50
  )
 
10
 
11
  from agents.curiosity_catalyst import curiosity_catalyst
12
  from tools.scrape_website import scrape_tool
13
+ from tasks.create_learning_profile import learning_profile_task
14
+ from tasks.evaluate_articles import evaluation_task
15
 
16
 
17
  class PitchedArticle(BaseModel):
 
25
 
26
 
27
  def callback_function(output: TaskOutput):
28
+ evaluated_articles = json.loads(output.exported_output)
29
  st.markdown(evaluated_articles)
30
+ for article in evaluated_articles['articles']:
31
+ settings.articles[article['url']]['pitch'] = article['pitch']
32
  st.markdown("### Create Article Pitch is executed successfully!")
33
 
34
 
35
  article_pitch_task = Task(
36
  description=(
37
+ "Create a pitch only for the articles that have been evaluated and no other links. "
38
  "Craft the pitch so to that it teases the article's most intriguing aspects, "
39
  "by posing questions that the article might answer or "
40
  "highlighting surprising facts to pique the user's curiosity "
41
  " to read the article for incremental learning."
42
  ),
43
  expected_output=(
44
+ "List of all the artilces that have been evaluated phase along with their url and pitch statement and no other new urls."
45
  ),
46
  output_json=PitchedArticles,
47
  output_file="pitched_articles.json",
 
49
  agent=curiosity_catalyst,
50
  async_execution=False,
51
  callback=callback_function,
52
+ context=[learning_profile_task, evaluation_task]
53
  )
tasks/evaluate_articles.py CHANGED
@@ -9,6 +9,8 @@ from pydantic import BaseModel
9
  from typing import List
10
 
11
  from agents.article_evaluator import article_evaluator
 
 
12
 
13
 
14
  class EvaluatedArticle(BaseModel):
@@ -40,14 +42,16 @@ evaluation_task = Task(
40
  "Score the articles on the scale of 1 to 10, "
41
  "1 being doesn't provide incremental learning and "
42
  "10 being provides incremental learning to the user."
 
43
  ),
44
  expected_output=(
45
- "List of article titles along with their links, evaluation score and "
46
- "evaluation reason w.r.t to insights captured by the user."
47
  ),
48
  output_json=EvaluatedArticles,
49
  output_file="evaluated_articles.json",
50
  agent=article_evaluator,
51
  async_execution=False,
52
  callback=callback_function,
 
53
  )
 
9
  from typing import List
10
 
11
  from agents.article_evaluator import article_evaluator
12
+ from tasks.create_learning_profile import learning_profile_task
13
+ from tasks.new_article_suggestion import article_suggestion_task
14
 
15
 
16
  class EvaluatedArticle(BaseModel):
 
42
  "Score the articles on the scale of 1 to 10, "
43
  "1 being doesn't provide incremental learning and "
44
  "10 being provides incremental learning to the user."
45
+ "Evaluate only articles that have been suggested to the user and no other articles."
46
  ),
47
  expected_output=(
48
+ "List of article titles with their URLs, evaluation scores, "
49
+ "and evaluation reasons w.r.t insights captured by the user."
50
  ),
51
  output_json=EvaluatedArticles,
52
  output_file="evaluated_articles.json",
53
  agent=article_evaluator,
54
  async_execution=False,
55
  callback=callback_function,
56
+ context=[learning_profile_task, article_suggestion_task]
57
  )