Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -64,7 +64,7 @@ def langchain_document_loader():
|
|
64 |
Files can be in txt, pdf, CSV or docx format.
|
65 |
"""
|
66 |
current_dir = os.getcwd()
|
67 |
-
TMP_DIR =
|
68 |
|
69 |
documents = []
|
70 |
|
@@ -75,7 +75,7 @@ def langchain_document_loader():
|
|
75 |
documents.extend(txt_loader.load())
|
76 |
"""
|
77 |
pdf_loader = DirectoryLoader(
|
78 |
-
|
79 |
)
|
80 |
documents.extend(pdf_loader.load())
|
81 |
"""
|
@@ -84,14 +84,16 @@ def langchain_document_loader():
|
|
84 |
loader_kwargs={"encoding":"utf8"}
|
85 |
)
|
86 |
documents.extend(csv_loader.load())
|
87 |
-
|
88 |
doc_loader = DirectoryLoader(
|
89 |
-
TMP_DIR.as_posix(),
|
|
|
90 |
glob="**/*.docx",
|
91 |
loader_cls=Docx2txtLoader,
|
92 |
show_progress=True,
|
93 |
)
|
94 |
documents.extend(doc_loader.load())
|
|
|
95 |
return documents
|
96 |
|
97 |
langchain_document_loader()
|
@@ -409,18 +411,18 @@ def answer_template(language="english"):
|
|
409 |
to the `LLM` wihch will answer"""
|
410 |
|
411 |
template = f"""Answer the question at the end, using only the following context (delimited by <context></context>).
|
412 |
-
Your answer must be in the language at the end.
|
413 |
-
|
414 |
-
<context>
|
415 |
-
{{chat_history}}
|
416 |
-
|
417 |
-
{{context}}
|
418 |
-
</context>
|
419 |
-
|
420 |
-
Question: {{question}}
|
421 |
-
|
422 |
-
|
423 |
-
"""
|
424 |
return template
|
425 |
|
426 |
|
|
|
64 |
Files can be in txt, pdf, CSV or docx format.
|
65 |
"""
|
66 |
current_dir = os.getcwd()
|
67 |
+
#TMP_DIR = current_dir
|
68 |
|
69 |
documents = []
|
70 |
|
|
|
75 |
documents.extend(txt_loader.load())
|
76 |
"""
|
77 |
pdf_loader = DirectoryLoader(
|
78 |
+
current_dir, glob="*.pdf", loader_cls=PyPDFLoader, show_progress=True
|
79 |
)
|
80 |
documents.extend(pdf_loader.load())
|
81 |
"""
|
|
|
84 |
loader_kwargs={"encoding":"utf8"}
|
85 |
)
|
86 |
documents.extend(csv_loader.load())
|
87 |
+
|
88 |
doc_loader = DirectoryLoader(
|
89 |
+
#TMP_DIR.as_posix(),
|
90 |
+
current_dir,
|
91 |
glob="**/*.docx",
|
92 |
loader_cls=Docx2txtLoader,
|
93 |
show_progress=True,
|
94 |
)
|
95 |
documents.extend(doc_loader.load())
|
96 |
+
"""
|
97 |
return documents
|
98 |
|
99 |
langchain_document_loader()
|
|
|
411 |
to the `LLM` wihch will answer"""
|
412 |
|
413 |
template = f"""Answer the question at the end, using only the following context (delimited by <context></context>).
|
414 |
+
Your answer must be in the language at the end.
|
415 |
+
|
416 |
+
<context>
|
417 |
+
{{chat_history}}
|
418 |
+
|
419 |
+
{{context}}
|
420 |
+
</context>
|
421 |
+
|
422 |
+
Question: {{question}}
|
423 |
+
|
424 |
+
|
425 |
+
"""
|
426 |
return template
|
427 |
|
428 |
|