MVPilgrim commited on
Commit
e9fa6de
·
1 Parent(s): f38ba8b
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -96,6 +96,7 @@ if 'client' not in st.session_state:
96
  )
97
  )
98
  client.connect()
 
99
  else:
100
  client = st.session_state.client
101
 
@@ -103,8 +104,8 @@ else:
103
  #######################################################
104
  # Read each text input file, parse it into a document,
105
  # chunk it, collect chunks and document name.
106
- logger.info("#### Read and chunk input text files.")
107
  if not client.collections.exists("Documents") or not client.collections.exists("Documents") :
 
108
  for filename in os.listdir(pathString):
109
  logger.info(filename)
110
  path = Path(pathString + "/" + filename)
@@ -144,8 +145,8 @@ if not client.collections.exists("Documents") or not client.collections.exists("
144
  # Create database webpage and chunks collections.
145
  #wpCollection = createWebpageCollection()
146
  #wpChunkCollection = createChunksCollection()
147
- logger.info("#### createWebpageCollection() entered.")
148
  if not client.collections.exists("Documents"):
 
149
  #client.collections.delete("Documents")
150
  class_obj = {
151
  "class": "Documents",
@@ -195,8 +196,9 @@ if not client.collections.exists("Documents"):
195
  }
196
  wpCollection = client.collections.create_from_dict(class_obj)
197
 
198
- logger.info("#### createChunksCollection() entered.")
199
  if not client.collections.exists("Chunks"):
 
200
  #client.collections.delete("Chunks")
201
  class_obj = {
202
  "class": "Chunks",
@@ -330,6 +332,7 @@ else:
330
  llm = st.session_state.llm
331
 
332
  def getRagData(promptText):
 
333
  ###############################################################################
334
  # Initial the the sentence transformer and encode the query prompt.
335
  logger.info(f"#### Encode text query prompt to create vectors. {text}")
@@ -418,7 +421,7 @@ def runLLM(prompt):
418
  return(result)
419
 
420
  def setPrompt(pprompt,ragFlag):
421
- print("\n### setPrompt() entered. ragFlag: ",ragFlag)
422
  if ragFlag:
423
  ragPrompt = getRagData(pprompt)
424
  userPrompt = pprompt + "\n" + ragPrompt
 
96
  )
97
  )
98
  client.connect()
99
+ st.session_state.client = client
100
  else:
101
  client = st.session_state.client
102
 
 
104
  #######################################################
105
  # Read each text input file, parse it into a document,
106
  # chunk it, collect chunks and document name.
 
107
  if not client.collections.exists("Documents") or not client.collections.exists("Documents") :
108
+ logger.info("#### Read and chunk input text files.")
109
  for filename in os.listdir(pathString):
110
  logger.info(filename)
111
  path = Path(pathString + "/" + filename)
 
145
  # Create database webpage and chunks collections.
146
  #wpCollection = createWebpageCollection()
147
  #wpChunkCollection = createChunksCollection()
 
148
  if not client.collections.exists("Documents"):
149
+ logger.info("#### createWebpageCollection() entered.")
150
  #client.collections.delete("Documents")
151
  class_obj = {
152
  "class": "Documents",
 
196
  }
197
  wpCollection = client.collections.create_from_dict(class_obj)
198
 
199
+
200
  if not client.collections.exists("Chunks"):
201
+ logger.info("#### createChunksCollection() entered.")
202
  #client.collections.delete("Chunks")
203
  class_obj = {
204
  "class": "Chunks",
 
332
  llm = st.session_state.llm
333
 
334
  def getRagData(promptText):
335
+ logger.info("#### getRagData() entered.")
336
  ###############################################################################
337
  # Initial the the sentence transformer and encode the query prompt.
338
  logger.info(f"#### Encode text query prompt to create vectors. {text}")
 
421
  return(result)
422
 
423
  def setPrompt(pprompt,ragFlag):
424
+ logger(f"\n### setPrompt() entered. ragFlag: {ragFlag}")
425
  if ragFlag:
426
  ragPrompt = getRagData(pprompt)
427
  userPrompt = pprompt + "\n" + ragPrompt