hash-map commited on
Commit
c9ba4ba
·
verified ·
1 Parent(s): a3a468d

Update rag.py

Browse files
Files changed (1) hide show
  1. rag.py +7 -11
rag.py CHANGED
@@ -1,8 +1,8 @@
1
- from langchain.document_loaders import DirectoryLoader
2
- from langchain.text_splitter import RecursiveCharacterTextSplitter
3
- from langchain.embeddings import HuggingFaceEmbeddings
4
- from langchain.vectorstores import FAISS
5
- from langchain.llms import Ollama
6
 
7
  loader = DirectoryLoader('.', glob="all_dialogues.txt")
8
  docs = loader.load()
@@ -20,7 +20,7 @@ db = FAISS.load_local(
20
  allow_dangerous_deserialization=True
21
  )
22
 
23
- from langchain.retrievers import BM25Retriever, EnsembleRetriever
24
 
25
  # Vector Store Retriever
26
  vector_retriever = db.as_retriever(search_kwargs={"k": 3})
@@ -38,11 +38,7 @@ ensemble_retriever = EnsembleRetriever(
38
  # Use in ask_question()
39
 
40
 
41
- from langchain_community.llms import Ollama
42
- from langchain_core.prompts import ChatPromptTemplate
43
 
44
- from langchain_community.llms import Ollama
45
- from langchain_core.prompts import ChatPromptTemplate
46
  from langchain_community.llms import HuggingFaceHub
47
  from langchain_core.prompts import ChatPromptTemplate
48
 
@@ -84,7 +80,7 @@ def respond_rag_huggingface(
84
 
85
  return response.content
86
 
87
-
88
  # def respond_rag_ollama(
89
  # message: str,
90
  # system_message: str = "you are game of thrones measter answer the given question strictly based on the context provived.if u donot know the answer reply i dont know donot give gibberish answers ",
 
1
+ from langchain_community.document_loaders import DirectoryLoader
2
+ from langchain_community.embeddings import HuggingFaceEmbeddings
3
+ from langchain_community.vectorstores import FAISS
4
+ from langchain_community.retrievers import BM25Retriever, EnsembleRetriever
5
+ from langchain_community.llms import Ollama
6
 
7
  loader = DirectoryLoader('.', glob="all_dialogues.txt")
8
  docs = loader.load()
 
20
  allow_dangerous_deserialization=True
21
  )
22
 
23
+
24
 
25
  # Vector Store Retriever
26
  vector_retriever = db.as_retriever(search_kwargs={"k": 3})
 
38
  # Use in ask_question()
39
 
40
 
 
 
41
 
 
 
42
  from langchain_community.llms import HuggingFaceHub
43
  from langchain_core.prompts import ChatPromptTemplate
44
 
 
80
 
81
  return response.content
82
 
83
+ __all__ = ["respond_rag_huggingface"]
84
  # def respond_rag_ollama(
85
  # message: str,
86
  # system_message: str = "you are game of thrones measter answer the given question strictly based on the context provived.if u donot know the answer reply i dont know donot give gibberish answers ",