Spaces:
Sleeping
Sleeping
Commit ·
6040b2c
1
Parent(s): 6197856
fixed image and search ttol
Browse files- README.md +6 -0
- app.py +6 -6
- image-2.png +0 -0
- image-3.png +0 -0
- images/MultiAgent_with_image.png +0 -0
- outputs/content_creator.md +33 -49
- src/agents/agents.py +6 -3
- src/llmconfig/groqllm.py +3 -1
- src/supportingtools/tools.py +10 -4
- src/task/tasks.py +4 -4
README.md
CHANGED
|
@@ -91,6 +91,12 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
| 91 |

|
| 92 |

|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
|
| 96 |
---
|
|
|
|
| 91 |

|
| 92 |

|
| 93 |
|
| 94 |
+
### Multiagent with SearchTool - DuckDuckGo
|
| 95 |
+

|
| 96 |
+
|
| 97 |
+
### MultiAgent with Image
|
| 98 |
+

|
| 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(
|
| 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
|
| 113 |
project_crew = Crew(
|
| 114 |
-
tasks=lst_tasks,
|
| 115 |
-
agents=lst_agents,
|
| 116 |
-
process=Process.
|
| 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 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
|
|
|
|
|
|
| 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(
|
| 36 |
-
"""
|
|
|
|
|
|
|
|
|
|
| 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":
|
| 46 |
})
|
| 47 |
-
name =
|
| 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[
|
| 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[
|
| 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 |
|