Update app.py
Browse filesAdded temporary file
app.py
CHANGED
@@ -12,6 +12,23 @@ import matplotlib.pyplot as plt
|
|
12 |
import glob
|
13 |
from dotenv import load_dotenv
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
# load the .env file
|
16 |
load_dotenv()
|
17 |
# Set up Groq API key
|
@@ -63,6 +80,7 @@ def main():
|
|
63 |
# Process uploaded file
|
64 |
if uploaded_file:
|
65 |
try:
|
|
|
66 |
df = pd.read_csv(uploaded_file)
|
67 |
st.write("Data successfully uploaded:")
|
68 |
st.dataframe(df.head())
|
@@ -305,7 +323,7 @@ def initialize_agents(llm,file_name):
|
|
305 |
),
|
306 |
"Starter_Code_Generator_Agent": Agent(
|
307 |
role='Starter_Code_Generator_Agent',
|
308 |
-
goal=f"Generate starter Python code for the project. Always give dataset name as {file_name}",
|
309 |
backstory="Code wizard for generating starter code templates.",
|
310 |
verbose=True,
|
311 |
allow_delegation=False,
|
|
|
12 |
import glob
|
13 |
from dotenv import load_dotenv
|
14 |
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
|
19 |
+
TEMP_DIR = "temp_files"
|
20 |
+
|
21 |
+
# Ensure the temporary directory exists
|
22 |
+
if not os.path.exists(TEMP_DIR):
|
23 |
+
os.makedirs(TEMP_DIR)
|
24 |
+
|
25 |
+
# Function to save uploaded file
|
26 |
+
def save_uploaded_file(uploaded_file):
|
27 |
+
file_path = os.path.join(TEMP_DIR, uploaded_file.name)
|
28 |
+
with open(file_path, 'wb') as f:
|
29 |
+
f.write(uploaded_file.getbuffer())
|
30 |
+
return file_path
|
31 |
+
|
32 |
# load the .env file
|
33 |
load_dotenv()
|
34 |
# Set up Groq API key
|
|
|
80 |
# Process uploaded file
|
81 |
if uploaded_file:
|
82 |
try:
|
83 |
+
file_path = save_uploaded_file(uploaded_file)
|
84 |
df = pd.read_csv(uploaded_file)
|
85 |
st.write("Data successfully uploaded:")
|
86 |
st.dataframe(df.head())
|
|
|
323 |
),
|
324 |
"Starter_Code_Generator_Agent": Agent(
|
325 |
role='Starter_Code_Generator_Agent',
|
326 |
+
goal=f"Generate starter Python code for the project. Always give dataset name as 'temp_files/{file_name}",
|
327 |
backstory="Code wizard for generating starter code templates.",
|
328 |
verbose=True,
|
329 |
allow_delegation=False,
|