mahynski commited on
Commit
1ab5fce
1 Parent(s): 973a0fb

testing llamaparse

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import tempfile
 
2
  import streamlit as st
3
 
4
  from llama_index.llms.gemini import Gemini
@@ -102,13 +103,18 @@ with st.sidebar:
102
 
103
  if uploaded_file is not None:
104
  # Parse the file
105
- # temp_dir = tempfile.TemporaryDirectory()
106
  parser = LlamaParse(
107
  api_key=parse_token, # can also be set in your env as LLAMA_CLOUD_API_KEY
108
  result_type="text" # "markdown" and "text" are available
109
  )
110
- # parsed_document = parser.load_data(uploaded_file)
111
- # temp_dir.cleanup()
 
 
 
 
 
112
 
113
  col1, col2 = st.columns(2)
114
 
 
1
  import tempfile
2
+ import os
3
  import streamlit as st
4
 
5
  from llama_index.llms.gemini import Gemini
 
103
 
104
  if uploaded_file is not None:
105
  # Parse the file
106
+ temp_dir = tempfile.TemporaryDirectory()
107
  parser = LlamaParse(
108
  api_key=parse_token, # can also be set in your env as LLAMA_CLOUD_API_KEY
109
  result_type="text" # "markdown" and "text" are available
110
  )
111
+
112
+ filename = os.path.join('./', uploaded_file.name)
113
+ with open(filename, "wb") as f:
114
+ f.write(uploaded_file.getvalue())
115
+
116
+ parsed_document = parser.load_data(filename)
117
+ temp_dir.cleanup()
118
 
119
  col1, col2 = st.columns(2)
120