markytools commited on
Commit
413cb20
·
1 Parent(s): 874fc5b
Files changed (1) hide show
  1. app.py +26 -16
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import streamlit as st
 
2
 
3
  radioButtonList = ["E-commerce CSV (https://www.kaggle.com/datasets/mervemenekse/ecommerce-dataset)",
4
  "Upload my own CSV",
@@ -28,29 +29,38 @@ isCustomURL = genre==radioButtonList[4]
28
  title = st.text_input('Enter your own URL', 'https://shorturl.at/csCK3', disabled=not isCustomURL)
29
  st.write('The current movie title is', title)
30
 
31
- isCustomPDF = genre==radioButtonList[2]
32
- uploaded_file = st.file_uploader("Upload your own PDF here", disabled=not isCustomPDF)
33
  if uploaded_file is not None:
34
- # To read file as bytes:
35
- bytes_data = uploaded_file.getvalue()
36
- st.write(bytes_data)
37
 
38
- # To convert to a string based IO:
39
- stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
40
- st.write(stringio)
41
 
42
- # To read file as string:
43
- string_data = stringio.read()
44
- st.write(string_data)
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
- # Can be used wherever a "file-like" object is accepted:
47
- dataframe = pd.read_csv(uploaded_file)
48
- st.write(dataframe)
 
49
 
50
  title = st.text_input(f'Ask me anything about this {pdfCSVURLText}', 'Type here', disabled=not isCustomURL)
51
  chatWithPDFButton = "CLICK HERE TO START CHATTING"
52
- st.button(chatWithPDFButton, type="primary")
53
- if st.button(chatWithPDFButton):
54
  pass
55
  else:
56
  pass
 
1
  import streamlit as st
2
+ from tempfile import NamedTemporaryFile
3
 
4
  radioButtonList = ["E-commerce CSV (https://www.kaggle.com/datasets/mervemenekse/ecommerce-dataset)",
5
  "Upload my own CSV",
 
29
  title = st.text_input('Enter your own URL', 'https://shorturl.at/csCK3', disabled=not isCustomURL)
30
  st.write('The current movie title is', title)
31
 
32
+ isCustomPDF = genre==radioButtonList[1] or genre==radioButtonList[2]
33
+ uploaded_file = st.file_uploader("Upload your own {pdfCSVURLText} here", type=pdfCSVURLText.lower(), disabled=not isCustomPDF)
34
  if uploaded_file is not None:
35
+ with NamedTemporaryFile(dir='.', suffix='.csv') as f:
36
+ f.write(uploaded_file.getbuffer())
37
+ st.write('The current uploaded file is', f.name)
38
 
 
 
 
39
 
40
+ # # To read file as bytes:
41
+ # bytes_data = uploaded_file.getvalue()
42
+ # st.write(bytes_data)
43
+ #
44
+ # # To convert to a string based IO:
45
+ # stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
46
+ # st.write(stringio)
47
+ #
48
+ # # To read file as string:
49
+ # string_data = stringio.read()
50
+ # st.write(string_data)
51
+ #
52
+ # # Can be used wherever a "file-like" object is accepted:
53
+ # dataframe = pd.read_csv(uploaded_file)
54
+ # st.write(dataframe)
55
 
56
+ if genre==radioButtonList[0]:
57
+ enableChatBox = True
58
+ elif genre==radioButtonList[1]:
59
+ enableChatBox = True
60
 
61
  title = st.text_input(f'Ask me anything about this {pdfCSVURLText}', 'Type here', disabled=not isCustomURL)
62
  chatWithPDFButton = "CLICK HERE TO START CHATTING"
63
+ if st.button(chatWithPDFButton, type="primary"):
 
64
  pass
65
  else:
66
  pass