vinhnx90 commited on
Commit
6f96801
Β·
1 Parent(s): dece7be

Refactor app

Browse files
Files changed (2) hide show
  1. app.py +4 -4
  2. document_retriever.py +3 -1
app.py CHANGED
@@ -8,6 +8,8 @@ from calback_handler import PrintRetrievalHandler, StreamHandler
8
  from chat_profile import ChatProfileRoleEnum
9
  from document_retriever import configure_retriever
10
 
 
 
11
  st.set_page_config(
12
  page_title="InkChatGPT: Chat with Documents",
13
  page_icon="πŸ“š",
@@ -58,9 +60,7 @@ with settings_tab:
58
  msgs.add_ai_message("""
59
  Hi, your uploaded document(s) had been analyzed.
60
 
61
- Feel free to ask me any questions.
62
-
63
- For example: you can start by asking me 'What is the title of the book, and who is author!'
64
  """)
65
 
66
  with documents_tab:
@@ -83,7 +83,7 @@ with chat_tab:
83
 
84
  # Setup LLM and QA chain
85
  llm = ChatOpenAI(
86
- model_name="gpt-3.5-turbo",
87
  openai_api_key=openai_api_key,
88
  temperature=0,
89
  streaming=True,
 
8
  from chat_profile import ChatProfileRoleEnum
9
  from document_retriever import configure_retriever
10
 
11
+ LLM_MODEL = "gpt-3.5-turbo"
12
+
13
  st.set_page_config(
14
  page_title="InkChatGPT: Chat with Documents",
15
  page_icon="πŸ“š",
 
60
  msgs.add_ai_message("""
61
  Hi, your uploaded document(s) had been analyzed.
62
 
63
+ Feel free to ask me any questions. For example: you can start by asking me `'What is this book about?` or `Tell me about the content of this book!`'
 
 
64
  """)
65
 
66
  with documents_tab:
 
83
 
84
  # Setup LLM and QA chain
85
  llm = ChatOpenAI(
86
+ model_name=LLM_MODEL,
87
  openai_api_key=openai_api_key,
88
  temperature=0,
89
  streaming=True,
document_retriever.py CHANGED
@@ -9,6 +9,8 @@ from langchain_community.embeddings import HuggingFaceEmbeddings
9
  from langchain_community.vectorstores import DocArrayInMemorySearch
10
  from langchain_text_splitters import RecursiveCharacterTextSplitter
11
 
 
 
12
 
13
  @st.cache_resource(ttl="1h")
14
  def configure_retriever(files, use_compression=False):
@@ -40,7 +42,7 @@ def configure_retriever(files, use_compression=False):
40
  splits = text_splitter.split_documents(docs)
41
 
42
  # Create embeddings and store in vectordb
43
- embeddings = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")
44
  vectordb = DocArrayInMemorySearch.from_documents(splits, embeddings)
45
 
46
  # Define retriever
 
9
  from langchain_community.vectorstores import DocArrayInMemorySearch
10
  from langchain_text_splitters import RecursiveCharacterTextSplitter
11
 
12
+ EMBEDDING_MODEL = "all-MiniLM-L6-v2"
13
+
14
 
15
  @st.cache_resource(ttl="1h")
16
  def configure_retriever(files, use_compression=False):
 
42
  splits = text_splitter.split_documents(docs)
43
 
44
  # Create embeddings and store in vectordb
45
+ embeddings = HuggingFaceEmbeddings(model_name=EMBEDDING_MODEL)
46
  vectordb = DocArrayInMemorySearch.from_documents(splits, embeddings)
47
 
48
  # Define retriever