Update utils.py
Browse files
utils.py
CHANGED
@@ -31,7 +31,7 @@ from pygments.formatters import HtmlFormatter
|
|
31 |
|
32 |
from langchain.chains import LLMChain, RetrievalQA
|
33 |
from langgraph.graph import END, StateGraph
|
34 |
-
from
|
35 |
from langchain_community.document_loaders import PyPDFLoader, WebBaseLoader, UnstructuredWordDocumentLoader, DirectoryLoader
|
36 |
from langchain.document_loaders.blob_loaders.youtube_audio import YoutubeAudioLoader
|
37 |
from langchain.document_loaders.generic import GenericLoader
|
@@ -44,7 +44,7 @@ from langchain_community.tools import DuckDuckGoSearchRun
|
|
44 |
from langchain.retrievers.tavily_search_api import TavilySearchAPIRetriever
|
45 |
from typing import Dict, TypedDict
|
46 |
from langchain_core.messages import BaseMessage
|
47 |
-
from
|
48 |
from langchain.prompts import PromptTemplate
|
49 |
|
50 |
|
@@ -380,6 +380,8 @@ def rag_chain(llm, prompt, retriever):
|
|
380 |
relevant_docs=[]
|
381 |
filtered_docs=[]
|
382 |
relevant_docs = retriever.get_relevant_documents(prompt)
|
|
|
|
|
383 |
if (len(relevant_docs)>0):
|
384 |
filtered_docs = grade_documents_direct(prompt, relevant_docs)
|
385 |
|
@@ -389,6 +391,8 @@ def rag_chain(llm, prompt, retriever):
|
|
389 |
neu_prompt = transform_query_direct(prompt)
|
390 |
relevant_docs = retriever.get_relevant_documents(neu_prompt)
|
391 |
if (len(relevant_docs)>0):
|
|
|
|
|
392 |
filtered_docs = grade_documents_direct(relevant_docs)
|
393 |
|
394 |
if (len(filtered_docs)>0):
|
|
|
31 |
|
32 |
from langchain.chains import LLMChain, RetrievalQA
|
33 |
from langgraph.graph import END, StateGraph
|
34 |
+
from langchain_openai import ChatOpenAI
|
35 |
from langchain_community.document_loaders import PyPDFLoader, WebBaseLoader, UnstructuredWordDocumentLoader, DirectoryLoader
|
36 |
from langchain.document_loaders.blob_loaders.youtube_audio import YoutubeAudioLoader
|
37 |
from langchain.document_loaders.generic import GenericLoader
|
|
|
44 |
from langchain.retrievers.tavily_search_api import TavilySearchAPIRetriever
|
45 |
from typing import Dict, TypedDict
|
46 |
from langchain_core.messages import BaseMessage
|
47 |
+
from langchain_openai import OpenAIEmbeddings
|
48 |
from langchain.prompts import PromptTemplate
|
49 |
|
50 |
|
|
|
380 |
relevant_docs=[]
|
381 |
filtered_docs=[]
|
382 |
relevant_docs = retriever.get_relevant_documents(prompt)
|
383 |
+
print("releant docs1......................")
|
384 |
+
print(relevant_docs)
|
385 |
if (len(relevant_docs)>0):
|
386 |
filtered_docs = grade_documents_direct(prompt, relevant_docs)
|
387 |
|
|
|
391 |
neu_prompt = transform_query_direct(prompt)
|
392 |
relevant_docs = retriever.get_relevant_documents(neu_prompt)
|
393 |
if (len(relevant_docs)>0):
|
394 |
+
print("releant docs2......................")
|
395 |
+
print(relevant_docs)
|
396 |
filtered_docs = grade_documents_direct(relevant_docs)
|
397 |
|
398 |
if (len(filtered_docs)>0):
|