Prathamesh1420 commited on
Commit
36d2a7c
1 Parent(s): 6152cc0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -46
app.py CHANGED
@@ -6,22 +6,20 @@ import os
6
 
7
  from langchain_community.llms import HuggingFaceHub
8
 
 
 
9
  llm = HuggingFaceHub(
10
  repo_id="HuggingFaceH4/zephyr-7b-beta",
11
- huggingfacehub_api_token= os.getenv('HF_API_KEY'),
12
  task="text-generation",
 
13
  )
 
14
  # Define Agents
15
  planner = Agent(
16
  role="Content Planner",
17
  goal="Plan engaging and factually accurate content on {topic}",
18
- backstory="You're working on planning a blog article "
19
- "about the topic: {topic}."
20
- "You collect information that helps the "
21
- "audience learn something "
22
- "and make informed decisions. "
23
- "Your work is the basis for "
24
- "the Content Writer to write an article on this topic.",
25
  llm=llm,
26
  allow_delegation=False,
27
  verbose=True
@@ -30,8 +28,7 @@ planner = Agent(
30
  writer = Agent(
31
  role="Content Writer",
32
  goal="Write a compelling and well-structured blog post on {topic}.",
33
- backstory="You're a writer who uses the content plan to create a detailed blog post. "
34
- "Ensure it aligns with SEO best practices and the brand's voice.",
35
  llm=llm,
36
  allow_delegation=False,
37
  verbose=True
@@ -40,14 +37,7 @@ writer = Agent(
40
  editor = Agent(
41
  role="Editor",
42
  goal="Edit a given blog post to align with the writing style of the organization.",
43
- backstory="You are an editor who receives a blog post "
44
- "from the Content Writer. "
45
- "Your goal is to review the blog post "
46
- "to ensure that it follows journalistic best practices,"
47
- "provides balanced viewpoints "
48
- "when providing opinions or assertions, "
49
- "and also avoids major controversial topics "
50
- "or opinions when possible.",
51
  llm=llm,
52
  allow_delegation=False,
53
  verbose=True
@@ -56,46 +46,31 @@ editor = Agent(
56
  # Define Tasks
57
  plan = Task(
58
  description=(
59
- "1. Prioritize the latest trends, key players, "
60
- "and noteworthy news on {topic}.\n"
61
- "2. Identify the target audience, considering "
62
- "their interests and pain points.\n"
63
- "3. Develop a detailed content outline including "
64
- "an introduction, key points, and a call to action.\n"
65
  "4. Include SEO keywords and relevant data or sources."
66
  ),
67
- expected_output="A comprehensive content plan document "
68
- "with an outline, audience analysis, "
69
- "SEO keywords, and resources.",
70
  agent=planner,
71
  )
72
 
73
  write = Task(
74
  description=(
75
- "1. Use the content plan to craft a compelling "
76
- "blog post on {topic}.\n"
77
  "2. Incorporate SEO keywords naturally.\n"
78
- "3. Sections/Subtitles are properly named "
79
- "in an engaging manner.\n"
80
- "4. Ensure the post is structured with an "
81
- "engaging introduction, insightful body, "
82
- "and a summarizing conclusion.\n"
83
- "5. Proofread for grammatical errors and "
84
- "alignment with the brand's voice.\n"
85
  ),
86
- expected_output="A well-written blog post "
87
- "in markdown format, ready for publication, "
88
- "each section should have 2 or 3 paragraphs.",
89
  agent=writer,
90
  )
91
 
92
  edit = Task(
93
- description=("Proofread the given blog post for "
94
- "grammatical errors and "
95
- "alignment with the brand's voice."),
96
- expected_output="A well-written blog post in markdown format, "
97
- "ready for publication, "
98
- "each section should have 2 or 3 paragraphs.",
99
  agent=editor
100
  )
101
 
@@ -125,4 +100,4 @@ def main():
125
  st.error("Please enter a topic.")
126
 
127
  if __name__ == "__main__":
128
- main()
 
6
 
7
  from langchain_community.llms import HuggingFaceHub
8
 
9
+ load_dotenv()
10
+
11
  llm = HuggingFaceHub(
12
  repo_id="HuggingFaceH4/zephyr-7b-beta",
13
+ huggingfacehub_api_token=os.getenv('HF_API_KEY'),
14
  task="text-generation",
15
+ max_length=2048 # Increase max_length for more detailed output
16
  )
17
+
18
  # Define Agents
19
  planner = Agent(
20
  role="Content Planner",
21
  goal="Plan engaging and factually accurate content on {topic}",
22
+ backstory="You're working on planning a blog article about the topic: {topic}. You collect information that helps the audience learn something and make informed decisions. Your work is the basis for the Content Writer to write an article on this topic.",
 
 
 
 
 
 
23
  llm=llm,
24
  allow_delegation=False,
25
  verbose=True
 
28
  writer = Agent(
29
  role="Content Writer",
30
  goal="Write a compelling and well-structured blog post on {topic}.",
31
+ backstory="You're a writer who uses the content plan to create a detailed blog post. Ensure it aligns with SEO best practices and the brand's voice.",
 
32
  llm=llm,
33
  allow_delegation=False,
34
  verbose=True
 
37
  editor = Agent(
38
  role="Editor",
39
  goal="Edit a given blog post to align with the writing style of the organization.",
40
+ backstory="You are an editor who receives a blog post from the Content Writer. Your goal is to review the blog post to ensure that it follows journalistic best practices, provides balanced viewpoints when providing opinions or assertions, and also avoids major controversial topics or opinions when possible.",
 
 
 
 
 
 
 
41
  llm=llm,
42
  allow_delegation=False,
43
  verbose=True
 
46
  # Define Tasks
47
  plan = Task(
48
  description=(
49
+ "1. Prioritize the latest trends, key players, and noteworthy news on {topic}.\n"
50
+ "2. Identify the target audience, considering their interests and pain points.\n"
51
+ "3. Develop a detailed content outline including an introduction, key points, and a call to action.\n"
 
 
 
52
  "4. Include SEO keywords and relevant data or sources."
53
  ),
54
+ expected_output="A comprehensive content plan document with an outline, audience analysis, SEO keywords, and resources.",
 
 
55
  agent=planner,
56
  )
57
 
58
  write = Task(
59
  description=(
60
+ "1. Use the content plan to craft a compelling blog post on {topic}.\n"
 
61
  "2. Incorporate SEO keywords naturally.\n"
62
+ "3. Sections/Subtitles are properly named in an engaging manner.\n"
63
+ "4. Ensure the post is structured with an engaging introduction, insightful body, and a summarizing conclusion.\n"
64
+ "5. Proofread for grammatical errors and alignment with the brand's voice.\n"
65
+ "6. Each section should have 2 or 3 paragraphs."
 
 
 
66
  ),
67
+ expected_output="A well-written blog post in markdown format, ready for publication.",
 
 
68
  agent=writer,
69
  )
70
 
71
  edit = Task(
72
+ description=("Proofread the given blog post for grammatical errors and alignment with the brand's voice."),
73
+ expected_output="A polished and error-free blog post in markdown format, ready for publication.",
 
 
 
 
74
  agent=editor
75
  )
76
 
 
100
  st.error("Please enter a topic.")
101
 
102
  if __name__ == "__main__":
103
+ main()