import os
from collections import deque
from typing import Dict, List, Optional, Any

from langchain import LLMChain, OpenAI, PromptTemplate
from langchain.embeddings import OpenAIEmbeddings
from langchain.llms import BaseLLM
from langchain.vectorstores.base import VectorStore
from pydantic import BaseModel, Field
from langchain.chains.base import Chain
from langchain.experimental import BabyAGI

from langchain.embeddings import OpenAIEmbeddings
from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores.redis import Redis

from langchain.agents import ZeroShotAgent, Tool, AgentExecutor
from langchain import OpenAI, SerpAPIWrapper, LLMChain

REDIS_HOST = os.getenv("REDIS_HOST")
REDIS_PORT = os.getenv("REDIS_PORT")


class OSNAPPlannerAgent:
    todo_prompt = PromptTemplate.from_template(
        "You are a planner who is an expert at coming up with a todo list for a given objective. Come up with a todo list for this objective: {objective}"
    )

    def __init__(self, agent_registry, tool_registry) -> None:
        self.embeddings_model = OpenAIEmbeddings()
        self.vectorstore = Redis.from_documents(
            self.embeddings_model,
            redis_url=f"{REDIS_HOST}:{REDIS_PORT}",
            index_name="link",
        )
        self.todo_chain = LLMChain(llm=OpenAI(temperature=0), prompt=self.todo_prompt)
