| import uuid | |
| from langchain_google_genai import ChatGoogleGenerativeAI | |
| from config import configs | |
| from agent.tools import * | |
| from agent.graph import create_agent_graph | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| class RAGAgent: | |
| def __init__(self): | |
| self.thread_id = str(uuid.uuid4()) | |
| self.llm = ChatGoogleGenerativeAI( | |
| model=configs["LLM_MODEL_NAME"], | |
| temperature=configs["TEMPERATURE"], | |
| max_tokens=configs["MAX_TOKENS"] | |
| ) | |
| vectordb = intialize_chroma_vectorstore() | |
| search_tools = [web_search_tavily, arxiv_search, wikipedia_search] | |
| self.agent_graph = create_agent_graph(self.llm, vectordb, search_tools) | |
| def get_config(self): | |
| return {"configurable": {"thread_id": self.thread_id}} | |
| def reset_thread(self): | |
| try: | |
| self.agent_graph.checkpointer.delete_thread(self.thread_id) | |
| except Exception as e: | |
| print(f"Warning: Could not delete thread {self.thread_id}: {e}") | |
| self.thread_id = str(uuid.uuid4()) | |
| if __name__ == "__main__": | |
| pass |