russkiyximik commited on
Commit
398bff1
·
1 Parent(s): 39555ce

context 1

Browse files
Files changed (1) hide show
  1. mycoder/app.py +7 -5
mycoder/app.py CHANGED
@@ -5,18 +5,20 @@ from mycoder.src.inner.main import run
5
  st.title("MyCoder Demo")
6
  st.write("This is a demo application for the MyCoder crew.")
7
 
 
 
 
8
  uploaded_file = st.file_uploader("Upload a CSV file", type="csv")
9
- temp_file_path = None
10
  if uploaded_file is not None:
11
  import tempfile
12
  with tempfile.NamedTemporaryFile(mode='wb', delete=False, suffix=".csv") as temp_file:
13
  temp_file.write(uploaded_file.getvalue())
14
- temp_file_path = temp_file.name
15
 
16
- st.success(f"File uploaded and saved as {temp_file_path}")
17
 
18
  st.write(f"Make sure to specify the correct file name in your query, " \
19
- f"e.g. {temp_file_path or 'Iris.csv'}")
20
  question = st.text_input("Enter your query:")
21
 
22
  if st.button("Run MyCoder Crew"):
@@ -26,5 +28,5 @@ if st.button("Run MyCoder Crew"):
26
  with open("output/code_and_output.md", "r") as f:
27
  code_and_output = f.read()
28
  st.markdown(code_and_output)
29
-
30
  st.image("output/plot.png", caption="Generated Figure")
 
5
  st.title("MyCoder Demo")
6
  st.write("This is a demo application for the MyCoder crew.")
7
 
8
+ if "temp_file_path" not in st.session_state: # Ensures temp_file_path is only set once
9
+ st.session_state.temp_file_path = None
10
+
11
  uploaded_file = st.file_uploader("Upload a CSV file", type="csv")
 
12
  if uploaded_file is not None:
13
  import tempfile
14
  with tempfile.NamedTemporaryFile(mode='wb', delete=False, suffix=".csv") as temp_file:
15
  temp_file.write(uploaded_file.getvalue())
16
+ st.session_state.temp_file_path = temp_file.name
17
 
18
+ st.success(f"File uploaded and saved as {st.session_state.temp_file_path}")
19
 
20
  st.write(f"Make sure to specify the correct file name in your query, " \
21
+ f"e.g. {st.session_state.temp_file_path or 'Iris.csv'}")
22
  question = st.text_input("Enter your query:")
23
 
24
  if st.button("Run MyCoder Crew"):
 
28
  with open("output/code_and_output.md", "r") as f:
29
  code_and_output = f.read()
30
  st.markdown(code_and_output)
31
+
32
  st.image("output/plot.png", caption="Generated Figure")