TomData commited on
Commit
8c21df3
·
1 Parent(s): 192315d

update keywordsearch with static db

Browse files
Files changed (1) hide show
  1. src/chatbot.py +4 -1
src/chatbot.py CHANGED
@@ -1,6 +1,7 @@
1
  from langchain_core.prompts import ChatPromptTemplate
2
  from langchain_community.llms.huggingface_hub import HuggingFaceHub
3
  from langchain_community.embeddings import HuggingFaceEmbeddings
 
4
 
5
  from src.vectordatabase import RAG, get_vectorstore
6
  import pandas as pd
@@ -11,6 +12,8 @@ import pandas as pd
11
 
12
  # Define important variables
13
  embeddings = HuggingFaceEmbeddings(model_name="paraphrase-multilingual-MiniLM-L12-v2") # Remove embedding input parameter from functions?
 
 
14
  llm = HuggingFaceHub(
15
  # ToDo: Try different models here
16
  repo_id="mistralai/Mixtral-8x7B-Instruct-v0.1",
@@ -109,7 +112,7 @@ def chatbot(message, history, db_inputs, prompt_language, llm=llm):
109
  return response
110
 
111
 
112
- def keyword_search(db, query, n=10, embeddings=embeddings, method='ss', party_filter='All'):
113
  """
114
  Retrieve speech contents based on keywords using a specified method.
115
 
 
1
  from langchain_core.prompts import ChatPromptTemplate
2
  from langchain_community.llms.huggingface_hub import HuggingFaceHub
3
  from langchain_community.embeddings import HuggingFaceEmbeddings
4
+ from langchain_community.vectorstores import FAISS
5
 
6
  from src.vectordatabase import RAG, get_vectorstore
7
  import pandas as pd
 
12
 
13
  # Define important variables
14
  embeddings = HuggingFaceEmbeddings(model_name="paraphrase-multilingual-MiniLM-L12-v2") # Remove embedding input parameter from functions?
15
+ db_all = FAISS.load_local(folder_path="./src/FAISS", index_name="speeches_1949_09_12",
16
+ embeddings=embeddings, allow_dangerous_deserialization=True)
17
  llm = HuggingFaceHub(
18
  # ToDo: Try different models here
19
  repo_id="mistralai/Mixtral-8x7B-Instruct-v0.1",
 
112
  return response
113
 
114
 
115
+ def keyword_search(query, db=db_all, n=10, embeddings=embeddings, method='ss', party_filter='All'):
116
  """
117
  Retrieve speech contents based on keywords using a specified method.
118