Spaces:
Runtime error
Runtime error
Commit
·
7f9e142
1
Parent(s):
bb33f0e
Update app.py
Browse files
app.py
CHANGED
@@ -91,15 +91,18 @@ class SemanticSearch:
|
|
91 |
def load_recommender(paths, start_page=1):
|
92 |
global recommender
|
93 |
all_texts = []
|
|
|
94 |
|
95 |
for path in paths:
|
96 |
texts = pdf_to_text(path, start_page=start_page)
|
97 |
all_texts.extend(texts)
|
|
|
98 |
|
99 |
-
chunks = text_to_chunks(all_texts, start_page=start_page)
|
100 |
recommender.fit(chunks)
|
101 |
return 'Corpus Loaded.'
|
102 |
|
|
|
103 |
|
104 |
def generate_text(openAI_key, prompt, engine="text-davinci-003"):
|
105 |
openai.api_key = openAI_key
|
|
|
91 |
def load_recommender(paths, start_page=1):
|
92 |
global recommender
|
93 |
all_texts = []
|
94 |
+
file_names = []
|
95 |
|
96 |
for path in paths:
|
97 |
texts = pdf_to_text(path, start_page=start_page)
|
98 |
all_texts.extend(texts)
|
99 |
+
file_names.append(os.path.basename(path))
|
100 |
|
101 |
+
chunks = text_to_chunks(all_texts, file_names, start_page=start_page)
|
102 |
recommender.fit(chunks)
|
103 |
return 'Corpus Loaded.'
|
104 |
|
105 |
+
|
106 |
|
107 |
def generate_text(openAI_key, prompt, engine="text-davinci-003"):
|
108 |
openai.api_key = openAI_key
|