Chaeruin
commited on
Commit
Β·
079be20
1
Parent(s):
cfd7b4e
commit2
Browse files
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
emoji: π
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: purple
|
|
|
|
| 1 |
---
|
| 2 |
+
title: 9thMLchatGPT
|
| 3 |
emoji: π
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: purple
|
app.py
CHANGED
|
@@ -28,17 +28,37 @@ def get_pdf_text(pdf_docs):
|
|
| 28 |
# κ³Όμ
|
| 29 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
| 30 |
|
| 31 |
-
def get_text_file(docs):
|
| 32 |
-
pass
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
def get_csv_file(docs):
|
| 36 |
-
pass
|
| 37 |
|
| 38 |
-
def
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
|
| 42 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
| 43 |
def get_text_chunks(documents):
|
| 44 |
text_splitter = RecursiveCharacterTextSplitter(
|
|
@@ -76,6 +96,7 @@ def get_conversation_chain(vectorstore):
|
|
| 76 |
)
|
| 77 |
return conversation_chain
|
| 78 |
|
|
|
|
| 79 |
# μ¬μ©μ μ
λ ₯μ μ²λ¦¬νλ ν¨μμ
λλ€.
|
| 80 |
def handle_userinput(user_question):
|
| 81 |
# λν 체μΈμ μ¬μ©νμ¬ μ¬μ©μ μ§λ¬Έμ λν μλ΅μ μμ±ν©λλ€.
|
|
|
|
| 28 |
# κ³Όμ
|
| 29 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
| 30 |
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
def get_text_file(text_docs):
|
| 33 |
+
temp_dir = tempfile.TemporaryDirectory()
|
| 34 |
+
temp_filepath = os.path.join(temp_dir.name, text_docs.name)
|
| 35 |
+
with open(temp_filepath, "wb") as f:
|
| 36 |
+
f.write(get_text_chunks(text_docs).getvalue())
|
| 37 |
+
text_loader = TextLoader(temp_filepath)
|
| 38 |
+
text_doc = text_loader.load()
|
| 39 |
+
return text_doc
|
| 40 |
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
def get_csv_file(csv_docs):
|
| 43 |
+
temp_dir = tempfile.TemporaryDirectory()
|
| 44 |
+
temp_filepath = os.path.join(temp_dir.name, csv_docs.name)
|
| 45 |
+
with open(temp_filepath, "wb") as f:
|
| 46 |
+
f.write(csv_docs.getvalue())
|
| 47 |
+
csv_loader = CSVLoader(temp_filepath)
|
| 48 |
+
csv_doc = csv_loader.load()
|
| 49 |
+
return csv_doc
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def get_json_file(json_docs):
|
| 53 |
+
temp_dir = tempfile.TemporaryDirectory()
|
| 54 |
+
temp_filepath = os.path.join(temp_dir.name, json_docs.name)
|
| 55 |
+
with open(temp_filepath, "wb") as f:
|
| 56 |
+
f.write(json_docs.getvalue())
|
| 57 |
+
json_loader = JSONLoader(temp_filepath, jq_schema='.messages[].content', text_content=False)
|
| 58 |
+
json_doc = json_loader.load()
|
| 59 |
+
return json_doc
|
| 60 |
+
|
| 61 |
|
|
|
|
| 62 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
| 63 |
def get_text_chunks(documents):
|
| 64 |
text_splitter = RecursiveCharacterTextSplitter(
|
|
|
|
| 96 |
)
|
| 97 |
return conversation_chain
|
| 98 |
|
| 99 |
+
|
| 100 |
# μ¬μ©μ μ
λ ₯μ μ²λ¦¬νλ ν¨μμ
λλ€.
|
| 101 |
def handle_userinput(user_question):
|
| 102 |
# λν 체μΈμ μ¬μ©νμ¬ μ¬μ©μ μ§λ¬Έμ λν μλ΅μ μμ±ν©λλ€.
|