Chris4K commited on
Commit
04011d9
1 Parent(s): de477cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -32
app.py CHANGED
@@ -17,38 +17,7 @@ def load_model():
17
 
18
 
19
  return model
20
- ###################################################
21
 
22
-
23
- from langchain.text_splitter import RecursiveCharacterTextSplitter
24
-
25
- class QQQSplitter(RecursiveCharacterTextSplitter):
26
- def __init__(self):
27
- super().__init__()
28
-
29
- def split(self, text: str) -> List[str]:
30
- """
31
- Splits the given text whenever there is a "qqq" sequence.
32
- """
33
- parts = []
34
- current_part = ""
35
-
36
- for char in text:
37
- if char == "q":
38
- if len(current_part) > 0 and current_part[-1] == "q":
39
- # Found a "qqq" sequence, split!
40
- parts.append(current_part[:-1])
41
- current_part = ""
42
- else:
43
- current_part += char
44
- else:
45
- current_part += char
46
-
47
- parts.append(current_part)
48
- return parts
49
-
50
-
51
- ######################################
52
  ##################################################
53
  ## vs chat
54
  ##################################################
@@ -117,7 +86,7 @@ def load_txt(path="./a.cv.ckaller.2024.txt"):
117
  #####
118
 
119
 
120
- text_splitter = QQQSplitter(HuggingFaceBgeEmbeddings())
121
 
122
  document_chunks = text_splitter.create_documents([state_of_the_union])
123
  print(document_chunks[0].page_content)
 
17
 
18
 
19
  return model
 
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  ##################################################
22
  ## vs chat
23
  ##################################################
 
86
  #####
87
 
88
 
89
+ text_splitter = SemanticChunker(HuggingFaceBgeEmbeddings())
90
 
91
  document_chunks = text_splitter.create_documents([state_of_the_union])
92
  print(document_chunks[0].page_content)