Merge pull request #257 from elder-plinius/master

urban_planning demo + pic + prompts
pull/260/head
Eternal Reclaimer 1 year ago committed by GitHub
commit 1aefe16065
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 KiB

@ -0,0 +1,47 @@
import os
from dotenv import load_dotenv
from swarms.models import OpenAIChat, GPT4VisionAPI
from swarms.structs import Agent, SequentialWorkflow
import swarms.prompts.urban_planning as upp
# Load environment variables
load_dotenv()
api_key = os.getenv("OPENAI_API_KEY")
stability_api_key = os.getenv("STABILITY_API_KEY")
# Initialize language model
llm = OpenAIChat(openai_api_key=api_key, temperature=0.5, max_tokens=3000)
# Initialize Vision model
vision_api = GPT4VisionAPI(api_key=api_key)
# Initialize agents for urban planning tasks
architecture_analysis_agent = Agent(llm=llm, max_loops=1, sop=upp.ARCHITECTURE_ANALYSIS_PROMPT)
infrastructure_evaluation_agent = Agent(llm=llm, max_loops=1, sop=upp.INFRASTRUCTURE_EVALUATION_PROMPT)
traffic_flow_analysis_agent = Agent(llm=llm, max_loops=1, sop=upp.TRAFFIC_FLOW_ANALYSIS_PROMPT)
environmental_impact_assessment_agent = Agent(llm=llm, max_loops=1, sop=upp.ENVIRONMENTAL_IMPACT_ASSESSMENT_PROMPT)
public_space_utilization_agent = Agent(llm=llm, max_loops=1, sop=upp.PUBLIC_SPACE_UTILIZATION_PROMPT)
socioeconomic_impact_analysis_agent = Agent(llm=llm, max_loops=1, sop=upp.SOCIOECONOMIC_IMPACT_ANALYSIS_PROMPT)
# Initialize the final planning agent
final_plan_agent = Agent(llm=llm, max_loops=1, sop=upp.FINAL_URBAN_IMPROVEMENT_PLAN_PROMPT)
# Create Sequential Workflow
workflow = SequentialWorkflow(max_loops=1)
# Add tasks to workflow with personalized prompts
workflow.add(architecture_analysis_agent, "Architecture Analysis")
workflow.add(infrastructure_evaluation_agent, "Infrastructure Evaluation")
workflow.add(traffic_flow_analysis_agent, "Traffic Flow Analysis")
workflow.add(environmental_impact_assessment_agent, "Environmental Impact Assessment")
workflow.add(public_space_utilization_agent, "Public Space Utilization")
workflow.add(socioeconomic_impact_analysis_agent, "Socioeconomic Impact Analysis")
workflow.add(final_plan_agent, "Generate the final urban improvement plan based on all previous agent's findings")
# Run the workflow for individual analysis tasks
# Execute the workflow for the final planning
workflow.run()
# Output results for each task and the final plan
for task in workflow.tasks:
print(f"Task Description: {task.description}\nResult: {task.result}\n")

@ -0,0 +1,40 @@
# urban_planning_prompts.py
# Architecture Analysis Prompt
ARCHITECTURE_ANALYSIS_PROMPT = """
Analyze the architectural styles, building designs, and construction materials visible in the urban area image provided. Provide insights on the historical influences, modern trends, and architectural diversity observed.
"""
# Infrastructure Evaluation Prompt
INFRASTRUCTURE_EVALUATION_PROMPT = """
Evaluate the infrastructure in the urban area image, focusing on roads, bridges, public transport, utilities, and communication networks. Assess their condition, capacity, and how they meet the needs of the urban population.
"""
# Traffic Flow Analysis Prompt
TRAFFIC_FLOW_ANALYSIS_PROMPT = """
Analyze the traffic flow and transportation systems visible in the urban area image. Identify key traffic routes, congestion points, and the effectiveness of public transportation in addressing urban mobility.
"""
# Environmental Impact Assessment Prompt
ENVIRONMENTAL_IMPACT_ASSESSMENT_PROMPT = """
Assess the environmental impact of the urban area shown in the image. Look for green spaces, pollution sources, and sustainability practices. Provide insights into the balance between urban development and environmental conservation.
"""
# Public Space Utilization Prompt
PUBLIC_SPACE_UTILIZATION_PROMPT = """
Evaluate the public spaces in the urban area, such as parks, squares, and recreational areas, as shown in the image. Assess their accessibility, condition, and how they contribute to the community's quality of life.
"""
# Socioeconomic Impact Analysis Prompt
SOCIOECONOMIC_IMPACT_ANALYSIS_PROMPT = """
Analyze the socioeconomic impact of the urban environment as depicted in the image. Consider factors such as housing, employment opportunities, commercial activities, and social disparities.
"""
# Final Urban Improvement Plan Prompt
FINAL_URBAN_IMPROVEMENT_PLAN_PROMPT = """
Based on the architecture analysis, infrastructure evaluation, traffic flow analysis, environmental impact assessment, public space utilization, and socioeconomic impact analysis provided by the previous agents, develop a comprehensive urban improvement plan. The plan should address key issues identified, propose practical solutions, and outline strategies to enhance the overall quality of life, sustainability, and efficiency of the urban area.
"""
# Additional or custom prompts can be added below as needed.
Loading…
Cancel
Save