sujeongim0402@gmail.com commited on
Commit ยท
c7ea54b
1
Parent(s): 7993f2c
edit codes
Browse files
app.py
CHANGED
|
@@ -42,28 +42,8 @@ def get_pdf_text(pdf_docs):
|
|
| 42 |
# ) # Use your specific text loader here.
|
| 43 |
# text_data = text_loader.load() # Extract text using the loader.
|
| 44 |
# return text_data # ์ถ์ถํ ํ
์คํธ๋ฅผ ๋ฐํํฉ๋๋ค.
|
| 45 |
-
def get_text_file(
|
| 46 |
-
|
| 47 |
-
txt_content = file.read() # Read the content of the TXT file
|
| 48 |
-
|
| 49 |
-
text_chunks = get_text_chunks([txt_content]) # Split the text into chunks
|
| 50 |
-
vectorstore = get_vectorstore(text_chunks) # Create a vector store from text chunks
|
| 51 |
-
|
| 52 |
-
conversation_chain = get_conversation_chain(vectorstore) # Create a conversation chain
|
| 53 |
-
|
| 54 |
-
# Assuming st.session_state.conversation is used to store conversation state
|
| 55 |
-
response = st.session_state.conversation({'question': txt_content})
|
| 56 |
-
|
| 57 |
-
# Assuming st.session_state.chat_history is used to store chat history
|
| 58 |
-
st.session_state.chat_history = response['chat_history']
|
| 59 |
-
|
| 60 |
-
for i, message in enumerate(st.session_state.chat_history):
|
| 61 |
-
if i % 2 == 0:
|
| 62 |
-
st.write(user_template.replace(
|
| 63 |
-
"{{MSG}}", message.content), unsafe_allow_html=True)
|
| 64 |
-
else:
|
| 65 |
-
st.write(bot_template.replace(
|
| 66 |
-
"{{MSG}}", message.content), unsafe_allow_html=True)
|
| 67 |
|
| 68 |
def get_csv_file(docs):
|
| 69 |
temp_dir3 = tempfile.TemporaryDirectory()
|
|
|
|
| 42 |
# ) # Use your specific text loader here.
|
| 43 |
# text_data = text_loader.load() # Extract text using the loader.
|
| 44 |
# return text_data # ์ถ์ถํ ํ
์คํธ๋ฅผ ๋ฐํํฉ๋๋ค.
|
| 45 |
+
def get_text_file(docs):
|
| 46 |
+
return [docs.getvalue()]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
def get_csv_file(docs):
|
| 49 |
temp_dir3 = tempfile.TemporaryDirectory()
|