[CODE QUALITY]

revert-250-master
Kye 1 year ago
parent 4ae4170fe7
commit 4f0aa944cc

@ -10,33 +10,67 @@ 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)
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)
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)
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(
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")
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
@ -44,4 +78,7 @@ 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")
print(
f"Task Description: {task.description}\nResult:"
f" {task.result}\n"
)

@ -36,15 +36,17 @@ def search_api(query: str, description: str):
@tool
def weather_api(query: str,):
def weather_api(
query: str,
):
"""_summary_
Args:
query (str): _description_
"""
print(f"Getting the weather for {query}")
@tool
def rapid_api(query: str):
"""_summary_
@ -54,6 +56,7 @@ def rapid_api(query: str):
"""
print(f"Getting the weather for {query}")
# Get the API key from the environment
api_key = os.environ.get("OPENAI_API_KEY")

@ -19,7 +19,6 @@ Take a deep breath.
"""
def autonomous_agent_prompt_v2(
tools_prompt: str = DYNAMICAL_TOOL_USAGE,
dynamic_stop_prompt: str = DYNAMIC_STOP_PROMPT,
@ -42,7 +41,6 @@ def autonomous_agent_prompt_v2(
"""
def agent_system_prompt_2_v2(name: str):
AGENT_SYSTEM_PROMPT_2_v2 = f"""
You are {name}, an elite autonomous agent designed for unparalleled versatility and adaptability in an autonomous loop structure.
@ -65,10 +63,6 @@ def agent_system_prompt_2_v2(name: str):
return AGENT_SYSTEM_PROMPT_2_v2
# ORIGINAL PROMPTS
FLOW_SYSTEM_PROMPT = """
You are an autonomous agent granted autonomy in a autonomous loop structure.
@ -139,4 +133,3 @@ AGENT_SYSTEM_PROMPT_3 = """
You will have internal dialogues with yourself and or interact with the user to aid in these tasks.
Your responses should be coherent, contextually relevant, and tailored to the task at hand.
"""

@ -34,11 +34,6 @@ commands: {
"""
########### FEW SHOT EXAMPLES ################
SCENARIOS = """
commands: {

@ -36,5 +36,4 @@ Based on the architecture analysis, infrastructure evaluation, traffic flow anal
"""
# Additional or custom prompts can be added below as needed.

Loading…
Cancel
Save