genaitiwari commited on
Commit
6040b2c
·
1 Parent(s): 6197856

fixed image and search ttol

Browse files
README.md CHANGED
@@ -91,6 +91,12 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
91
  ![crewaidemo](image.png)
92
  ![alt text](image-1.png)
93
 
 
 
 
 
 
 
94
 
95
 
96
  ---
 
91
  ![crewaidemo](image.png)
92
  ![alt text](image-1.png)
93
 
94
+ ### Multiagent with SearchTool - DuckDuckGo
95
+ ![alt text](image-3.png)
96
+
97
+ ### MultiAgent with Image
98
+ ![alt text](image-2.png)
99
+
100
 
101
 
102
  ---
app.py CHANGED
@@ -73,7 +73,7 @@ if __name__ == "__main__":
73
 
74
  # agents
75
  obj_crewai_agents = CrewAIAgents(llm=llm)
76
- lst_agents = obj_crewai_agents.gen_with_crewai_agents(image_generate=SupportingTools.image_generate,search_tool=search_tool)
77
 
78
  # Define tasks for each agent
79
  obj_crewai_tasks = CrewAITasks(llm=llm,prompt=prompt,lst_agents=lst_agents)
@@ -109,15 +109,15 @@ if __name__ == "__main__":
109
  obj_crewai_tasks = CrewAITasks(llm=llm,prompt=prompt,lst_agents=lst_agents)
110
  lst_tasks = obj_crewai_tasks.create_tasks_image_gen()
111
 
112
- # Set up the crew and process tasks hierarchically
113
  project_crew = Crew(
114
- tasks=lst_tasks,
115
- agents=lst_agents,
116
- process=Process.hierarchical,
117
  manager_llm=llm,
118
  manager_callbacks=[CustomHandler("Crew Manager")]
119
  )
120
- final = project_crew.kickoff()
121
 
122
 
123
  # Display the final result
 
73
 
74
  # agents
75
  obj_crewai_agents = CrewAIAgents(llm=llm)
76
+ lst_agents = obj_crewai_agents.gen_with_crewai_agents(search_tool=search_tool)
77
 
78
  # Define tasks for each agent
79
  obj_crewai_tasks = CrewAITasks(llm=llm,prompt=prompt,lst_agents=lst_agents)
 
109
  obj_crewai_tasks = CrewAITasks(llm=llm,prompt=prompt,lst_agents=lst_agents)
110
  lst_tasks = obj_crewai_tasks.create_tasks_image_gen()
111
 
112
+ # Set up the crew and process tasks
113
  project_crew = Crew(
114
+ tasks=[lst_tasks[1]],
115
+ agents=[lst_agents[1]],
116
+ process=Process.sequential,
117
  manager_llm=llm,
118
  manager_callbacks=[CustomHandler("Crew Manager")]
119
  )
120
+ final = project_crew.kickoff({'input':prompt})
121
 
122
 
123
  # Display the final result
image-2.png ADDED
image-3.png ADDED
images/MultiAgent_with_image.png ADDED
outputs/content_creator.md CHANGED
@@ -1,49 +1,33 @@
1
- ```diff
2
- Title: Unleashing the Potential of Agriculture in India: A Comprehensive Overview
3
-
4
- Introduction:
5
-
6
- India, a land rich in cultural heritage and diversity, is also home to an agriculture sector that has the potential to revolutionize its economy and the lives of its people. This comprehensive overview explores the current state of agriculture in India, the challenges it faces, and the opportunities that lie ahead.
7
-
8
- Section 1: The Current State of Agriculture in India
9
-
10
- 1.1 Overview of Indian Agriculture
11
-
12
- Indian agriculture is a significant contributor to the country's economy, providing employment to over 50% of the population and accounting for around 17-18% of the Gross Domestic Product (GDP). The sector is characterized by small and marginal farmers, with over 86% of the farmlands owned by these farmers.
13
-
14
- 1.2 Major Crops and Production
15
-
16
- India is the world's largest producer of various crops, such as milk, pulses, spices, and tea. The country also ranks second in the production of rice, wheat, sugarcane, fruits, and vegetables.
17
-
18
- Section 2: Challenges Facing Indian Agriculture
19
-
20
- 2.1 Climate Change and Its Impact
21
-
22
- Climate change has emerged as a significant challenge for Indian agriculture, with changing weather patterns affecting crop yields and threatening food security.
23
-
24
- 2.2 Water Scarcity and Inefficient Irrigation
25
-
26
- Water scarcity and inefficient irrigation practices are major issues that need immediate attention. With groundwater levels depleting rapidly, there is a pressing need to adopt sustainable irrigation methods.
27
-
28
- 2.3 Lack of Modern Technology and Infrastructure
29
-
30
- The agriculture sector in India lacks modern technology and infrastructure, which hampers its growth and productivity. The adoption of advanced technology and modern farming practices can significantly improve the sector's performance.
31
-
32
- Section 3: Opportunities for Indian Agriculture
33
-
34
- 3.1 Harnessing the Power of Technology
35
-
36
- The adoption of technology can transform Indian agriculture by improving efficiency, reducing waste, and increasing crop yields. From precision farming to drones and artificial intelligence, technology has the potential to revolutionize the sector.
37
-
38
- 3.2 Organic Farming and Exports
39
-
40
- Organic farming is gaining popularity in India, both domestically and internationally. With a growing demand for organic products, India can tap into this market and increase its agricultural exports.
41
-
42
- 3.3 Focus on Value-Added Processing and Branding
43
-
44
- Value-added processing and branding of agricultural products can provide a significant boost to the sector. By focusing on quality, packaging, and marketing, farmers can increase their income and contribute to the growth of the economy.
45
-
46
- Conclusion:
47
-
48
- The agriculture sector in India holds immense potential, and addressing the challenges it faces is crucial for the country's overall development. By harnessing the power of technology, focusing on organic farming and exports, and investing in value-added processing and branding, India can transform its agriculture sector and improve the lives of its people.
49
- ```
 
1
+ ### Title: 2024 Budget Overview
2
+
3
+ ### Introduction:
4
+ - Brief overview of the 2024 budget, including its purpose and key objectives.
5
+
6
+ ### Total Expenditure:
7
+ - Projected at ₹ 48,20,512 crore
8
+
9
+ ### Fiscal Deficit:
10
+ - Estimated at 4.9% of the GDP for the current financial year
11
+ - Aims to reduce it to below 4.5% in 2024
12
+
13
+ ### Revenue Sources:
14
+ - Majority of revenue comes from tax-related sources
15
+ - Other Revenues (1%): Non-debt capital receipts
16
+
17
+ ### Expenditure Categories:
18
+ - The largest share of government spending is directed at:
19
+ - States' share of tax duties (21% of total expenditure)
20
+ - Interest payments (19% of total expenditure)
21
+ - Other Expenditures (9%):
22
+ - Defense Budget Increases By 4.79% Under 'Atmanirbhar Bharat' Initiative
23
+
24
+ ### Additional Information:
25
+ - The Union Budget 2024-25 will be presented by Finance Minister Nirmala Sitharaman on July 23.
26
+ - This will be the seventh consecutive budget presented by Sitharaman.
27
+ - The budget is an account of the government's income and expenditure for the upcoming fiscal year.
28
+
29
+ ### Conclusion:
30
+ - Summary of the key points and categories of the 2024 budget, including total expenditure, fiscal deficit, revenue sources, and expenditure categories.
31
+ - Discussion of the budget's significance and potential impact on the economy.
32
+ - Call-to-action encouraging readers to stay informed about the 2024 budget and its implementation.
33
+ - Closing remarks emphasizing the importance of the 2024 budget in shaping the country's financial future.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/agents/agents.py CHANGED
@@ -30,7 +30,10 @@ class CustomHandler(BaseCallbackHandler):
30
  st.write("**********")
31
  st.write(self.agent_name)
32
  st.write("**********")
33
- chat_message(self.agent_name).write(f"{self.agent_name } : {output}")
 
 
 
34
 
35
  class CrewAIAgents:
36
  def __init__(self,llm):
@@ -229,8 +232,8 @@ class CrewAIAgents:
229
  # step_callback=lambda step: step_callback(
230
  # agent_output=step, agent_name="Visual Content creator Agent")
231
  llm=self.llm,
232
- max_iter=4,
233
- callbacks=[CustomHandler("Visual Creator")]
234
  )
235
  return [content_creator_agent,visual_content_creator_agent]
236
 
 
30
  st.write("**********")
31
  st.write(self.agent_name)
32
  st.write("**********")
33
+ if self.agent_name == 'Visual Content Creator':
34
+ chat_message(self.agent_name).image(f"{self.agent_name } : {output}")
35
+ else :
36
+ chat_message(self.agent_name).markdown(f"{self.agent_name } : {output}")
37
 
38
  class CrewAIAgents:
39
  def __init__(self,llm):
 
232
  # step_callback=lambda step: step_callback(
233
  # agent_output=step, agent_name="Visual Content creator Agent")
234
  llm=self.llm,
235
+ #max_iter=4,
236
+ callbacks=[CustomHandler("Visual Content Creator")]
237
  )
238
  return [content_creator_agent,visual_content_creator_agent]
239
 
src/llmconfig/groqllm.py CHANGED
@@ -12,7 +12,9 @@ class GroqLLM:
12
 
13
  def groq_llm_config(self):
14
  groq = ChatGroq(
15
- temperature=0.5,
 
 
16
  model= self.user_controls_input["selected_model"],
17
  api_key="" # Optional if not set as an environment variable
18
  )
 
12
 
13
  def groq_llm_config(self):
14
  groq = ChatGroq(
15
+ max_tokens=4000,
16
+ max_retries=3,
17
+ temperature=0.7,
18
  model= self.user_controls_input["selected_model"],
19
  api_key="" # Optional if not set as an environment variable
20
  )
src/supportingtools/tools.py CHANGED
@@ -32,8 +32,11 @@ class SupportingTools:
32
  return image
33
 
34
  @tool("Image Generate Tool")
35
- def image_generate(self,context: str):
36
- """This is Image generate tool"""
 
 
 
37
  API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
38
  hugginface_api_key = os.getenv("HUGGINGFACE_API_KEY")
39
  headers = {"Authorization": f"Bearer {hugginface_api_key}"}
@@ -42,11 +45,14 @@ class SupportingTools:
42
  response = requests.post(API_URL, headers=headers, json=payload)
43
  return response.content
44
  image_bytes = query({
45
- "inputs": context,
46
  })
47
- name = context.split(" ")[0]
48
  image = Image.open(io.BytesIO(image_bytes)).resize((1024, 1024))
49
  image.save(f"./outputs/generate_{name}.jpg")
 
 
 
50
  return image
51
 
52
 
 
32
  return image
33
 
34
  @tool("Image Generate Tool")
35
+ def image_generate(prompt: str):
36
+ """
37
+ Args:
38
+ prompt (str): the prompt string return from the classification agent is the argument prompt in the functiom generat image tool.
39
+ """
40
  API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
41
  hugginface_api_key = os.getenv("HUGGINGFACE_API_KEY")
42
  headers = {"Authorization": f"Bearer {hugginface_api_key}"}
 
45
  response = requests.post(API_URL, headers=headers, json=payload)
46
  return response.content
47
  image_bytes = query({
48
+ "inputs": prompt,
49
  })
50
+ name = prompt.split(" ")[0]
51
  image = Image.open(io.BytesIO(image_bytes)).resize((1024, 1024))
52
  image.save(f"./outputs/generate_{name}.jpg")
53
+ import streamlit as st
54
+ st.write("************ # IMAGE GEN # ********")
55
+ st.image(image)
56
  return image
57
 
58
 
src/task/tasks.py CHANGED
@@ -103,7 +103,7 @@ class CrewAITasks:
103
  description="""
104
  The role involves optimizing content for search engines by analyzing, recommending improvements, and monitoring performance, ultimately aiming to enhance content discoverability online and improve its ranking on search engine results pages.
105
  """,
106
- agent=self.lst_agents[4], # seo_analyst_agent,
107
  expected_output="""
108
  Apply SEO best practices to the generated content. This may involve:
109
  - Keyword optimization.
@@ -119,7 +119,7 @@ class CrewAITasks:
119
  description="""
120
  The Editorial Assistant plays a pivotal role in guaranteeing that published content is error-free, stylistically appropriate, and prepared to meet the publication's standards and expectations.
121
  """,
122
- agent=self.lst_agents[5] , # editorial_assistant_agent,
123
  expected_output="""
124
  The expected output is high-quality content that is polished, accurate, and in line with the publication's editorial standards, ensuring a positive reader experience and maintaining the publication's reputation for excellence.
125
  """,
@@ -174,8 +174,8 @@ class CrewAITasks:
174
  """,
175
  agent=self.lst_agents[1],
176
  #context=[content_creator_task],
177
- expected_output=f"""Generate a High Resolution image in .png or .jpg file image based on the {self.topic} and return it in images folder and append it in output_file="images/gen_*""",
178
- output_file="outputs/img_creator.png"
179
 
180
  )
181
 
 
103
  description="""
104
  The role involves optimizing content for search engines by analyzing, recommending improvements, and monitoring performance, ultimately aiming to enhance content discoverability online and improve its ranking on search engine results pages.
105
  """,
106
+ agent=self.lst_agents[3], # seo_analyst_agent,
107
  expected_output="""
108
  Apply SEO best practices to the generated content. This may involve:
109
  - Keyword optimization.
 
119
  description="""
120
  The Editorial Assistant plays a pivotal role in guaranteeing that published content is error-free, stylistically appropriate, and prepared to meet the publication's standards and expectations.
121
  """,
122
+ agent=self.lst_agents[4] , # editorial_assistant_agent,
123
  expected_output="""
124
  The expected output is high-quality content that is polished, accurate, and in line with the publication's editorial standards, ensuring a positive reader experience and maintaining the publication's reputation for excellence.
125
  """,
 
174
  """,
175
  agent=self.lst_agents[1],
176
  #context=[content_creator_task],
177
+ expected_output=f"""Generate a High Resolution image in .png or .jpg file image based on the {self.topic} and return it in images folder and append it in output_file="./images/gen_*""",
178
+ output_file="./outputs/img_creator.png"
179
 
180
  )
181