Spaces:
Runtime error
Runtime error
fix path
Browse files
app.py
CHANGED
@@ -79,7 +79,6 @@ def pdf_to_text(files_src, start_page=1, end_page=None):
|
|
79 |
|
80 |
def text_to_chunks(texts, word_length=150, start_page=1):
|
81 |
text_toks = [t.split(' ') for t in texts]
|
82 |
-
page_nums = []
|
83 |
chunks = []
|
84 |
|
85 |
for idx, words in enumerate(text_toks):
|
@@ -103,8 +102,6 @@ def embedding(model, files_src, batch=1000):
|
|
103 |
if os.path.isfile(embeddings_file):
|
104 |
embeddings = np.load(embeddings_file)
|
105 |
return embeddings, chunks
|
106 |
-
# texts = pdf_to_text(files_src)
|
107 |
-
# chunks = text_to_chunks(texts)
|
108 |
data = chunks
|
109 |
embeddings = []
|
110 |
for i in range(0, len(data), batch):
|
@@ -133,7 +130,6 @@ def predict(
|
|
133 |
files=None
|
134 |
):
|
135 |
old_inputs = None
|
136 |
-
display_reference = []
|
137 |
if files:
|
138 |
old_inputs = inputs
|
139 |
emb_model = hub.load('https://tfhub.dev/google/universal-sentence-encoder/4')
|
@@ -169,7 +165,6 @@ def predict(
|
|
169 |
temperature=temperature,
|
170 |
)
|
171 |
message = completions.choices[0].text
|
172 |
-
# print(message)
|
173 |
if old_inputs is not None:
|
174 |
history[-1] = old_inputs
|
175 |
chatbot[-1] = (chatbot[-1][0], message + display_reference)
|
@@ -177,7 +172,7 @@ def predict(
|
|
177 |
|
178 |
|
179 |
# Create theme
|
180 |
-
with open("
|
181 |
customCSS = f.read()
|
182 |
beautiful_theme = gr.themes.Soft(
|
183 |
primary_hue=gr.themes.Color(
|
|
|
79 |
|
80 |
def text_to_chunks(texts, word_length=150, start_page=1):
|
81 |
text_toks = [t.split(' ') for t in texts]
|
|
|
82 |
chunks = []
|
83 |
|
84 |
for idx, words in enumerate(text_toks):
|
|
|
102 |
if os.path.isfile(embeddings_file):
|
103 |
embeddings = np.load(embeddings_file)
|
104 |
return embeddings, chunks
|
|
|
|
|
105 |
data = chunks
|
106 |
embeddings = []
|
107 |
for i in range(0, len(data), batch):
|
|
|
130 |
files=None
|
131 |
):
|
132 |
old_inputs = None
|
|
|
133 |
if files:
|
134 |
old_inputs = inputs
|
135 |
emb_model = hub.load('https://tfhub.dev/google/universal-sentence-encoder/4')
|
|
|
165 |
temperature=temperature,
|
166 |
)
|
167 |
message = completions.choices[0].text
|
|
|
168 |
if old_inputs is not None:
|
169 |
history[-1] = old_inputs
|
170 |
chatbot[-1] = (chatbot[-1][0], message + display_reference)
|
|
|
172 |
|
173 |
|
174 |
# Create theme
|
175 |
+
with open("custom.css", "r", encoding="utf-8") as f:
|
176 |
customCSS = f.read()
|
177 |
beautiful_theme = gr.themes.Soft(
|
178 |
primary_hue=gr.themes.Color(
|