diff --git a/backend/requirements.txt b/backend/requirements.txt index 58be9866..eb052b44 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -16,7 +16,7 @@ sphinxcontrib-mermaid==0.9.2 sphinx-book-theme==1.1.3 sphinx-copybutton==0.5.2 sphinx-external-toc==1.0.1 -pypdf==4.2.0 +pypdf==5.6.0 unstructured==0.15.1 nltk==3.9.1 huggingface_hub[cli]==0.24.6 diff --git a/backend/src/agents/retriever_graph.py b/backend/src/agents/retriever_graph.py index 44cb16e2..d664b858 100644 --- a/backend/src/agents/retriever_graph.py +++ b/backend/src/agents/retriever_graph.py @@ -133,7 +133,7 @@ def agent(self, state: AgentState) -> dict[str, list[str]]: tool_choice_chain = ( ChatPromptTemplate.from_template(rephrase_prompt_template) - | self.llm + | model | JsonOutputParser() ) response = tool_choice_chain.invoke( @@ -143,8 +143,6 @@ def agent(self, state: AgentState) -> dict[str, list[str]]: } ) - response = model.invoke(followup_question) - if response is None or response.tool_calls is None: return {"tools": []} @@ -189,7 +187,6 @@ def agent(self, state: AgentState) -> dict[str, list[str]]: def generate(self, state: AgentState) -> dict[str, Any]: query = state["messages"][-1].content context = state["context"][-1].content - print("state keys", state.keys()) ans = self.llm_chain.invoke({"context": context, "question": query}) diff --git a/backend/src/prompts/prompt_templates.py b/backend/src/prompts/prompt_templates.py index 0ffcbb15..8d326d03 100644 --- a/backend/src/prompts/prompt_templates.py +++ b/backend/src/prompts/prompt_templates.py @@ -75,8 +75,7 @@ Given the chat history, rephrase the follow-up question to be a standalone question.\ The rephrased question should include only relevant information inferred from the chat history.\ If the question is already standalone, return the same question.\ +Choose the most appropriate tools from the list of tools to answer the rephrased question.\ Return your response as a json blob with 'rephrased_question'.\ -Return your response as a JSON blob with 'rephrased_question'. - """ diff --git a/backend/src/vectorstores/faiss.py b/backend/src/vectorstores/faiss.py index 352a177c..c531a523 100644 --- a/backend/src/vectorstores/faiss.py +++ b/backend/src/vectorstores/faiss.py @@ -31,7 +31,7 @@ def __init__( ): self.embeddings_model_name = embeddings_model_name - model_kwargs = {"device": "cuda"} if use_cuda else {} + model_kwargs = {"device": "cuda"} if use_cuda else {"device": "cpu"} self.embedding_model: Union[ HuggingFaceEmbeddings, GoogleGenerativeAIEmbeddings, VertexAIEmbeddings