import sys
# sys.path.append("../..")
sys.path.append("/home/czr/Agent-Driver/")
from agentdriver.memory.memory_agent import MemoryAgent
from agentdriver.perception.perception_agent import PerceptionAgent
from agentdriver.reasoning.reasoning_agent import ReasoningAgent
from agentdriver.llm_core.api_keys import OPENAI_ORG, OPENAI_API_KEY
from RAG.evolution.embedding_GA_search import add_zeros_to_numbers
import openai
openai.organization = OPENAI_ORG
openai.api_key = OPENAI_API_KEY

from pathlib import Path

data_path = Path('/home/czr/Agent-Driver/data/')

token = "0a0d6b8c2e884134a3b48df43d54c36a"
# token = "0a8dee95c4ac4ac59a43af56da6e589f"
# token = "5e6c874d0a034ab88e2da0e9eab75c87"
# token = "3fc868d0c6984ae6855406f386d4fc69"

perception_agent = PerceptionAgent(token=token, split="val", data_path=data_path, verbose=True)
ego_prompts, perception_prompts, working_memory = perception_agent.run()


ego_prompts = ego_prompts
perception_prompts = perception_prompts#[:-1] + "Notice: BE SAFE!\n"
print("perception_prompts", perception_prompts)

query = add_zeros_to_numbers(ego_prompts+perception_prompts, 3)
print("query", query)
input()

memory_agent = MemoryAgent(data_path=data_path, verbose=True, compare_perception=True)
commonsense_mem, experience_mem = memory_agent.run(working_memory)

reasoning_agent = ReasoningAgent(verbose=True)
reasoning = reasoning_agent.run(perception_agent.data_dict, query, working_memory)