Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,14 +9,55 @@ from Gradio_UI import GradioUI
|
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
15 |
Args:
|
16 |
-
|
17 |
-
|
|
|
|
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -55,7 +96,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
55 |
|
56 |
agent = CodeAgent(
|
57 |
model=model,
|
58 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
59 |
max_steps=6,
|
60 |
verbosity_level=1,
|
61 |
grammar=None,
|
|
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
+
from smolagents import tool
|
13 |
+
|
14 |
+
@tool
|
15 |
+
def generate_data_science_steps(process: str) -> str:
|
16 |
+
"""A tool that generates concise step-by-step instructions for a given data science process.
|
17 |
+
|
18 |
Args:
|
19 |
+
process: The name of the data science process (e.g., "Data Cleaning", "Feature Engineering", "Model Training").
|
20 |
+
|
21 |
+
Returns:
|
22 |
+
A concise list of steps for executing the specified process.
|
23 |
"""
|
24 |
+
steps_dict = {
|
25 |
+
"data cleaning": [
|
26 |
+
"1. Load the dataset.",
|
27 |
+
"2. Handle missing values (impute or remove).",
|
28 |
+
"3. Remove duplicates.",
|
29 |
+
"4. Fix inconsistent data types.",
|
30 |
+
"5. Normalize/standardize data if needed."
|
31 |
+
],
|
32 |
+
"feature engineering": [
|
33 |
+
"1. Identify relevant features.",
|
34 |
+
"2. Create new features from existing data.",
|
35 |
+
"3. Encode categorical variables.",
|
36 |
+
"4. Scale numerical features.",
|
37 |
+
"5. Select the most important features."
|
38 |
+
],
|
39 |
+
"model training": [
|
40 |
+
"1. Split data into train/test sets.",
|
41 |
+
"2. Choose an appropriate algorithm.",
|
42 |
+
"3. Train the model on training data.",
|
43 |
+
"4. Evaluate using validation data.",
|
44 |
+
"5. Tune hyperparameters for better performance."
|
45 |
+
],
|
46 |
+
"data visualization": [
|
47 |
+
"1. Choose the right visualization type.",
|
48 |
+
"2. Load and preprocess data.",
|
49 |
+
"3. Use libraries like Matplotlib or Seaborn.",
|
50 |
+
"4. Label axes and titles for clarity.",
|
51 |
+
"5. Interpret insights from the visuals."
|
52 |
+
]
|
53 |
+
}
|
54 |
+
|
55 |
+
process = process.lower()
|
56 |
+
if process in steps_dict:
|
57 |
+
return "\n".join(steps_dict[process])
|
58 |
+
else:
|
59 |
+
return f"Sorry, I don't have predefined steps for '{process}'. Try another data science process."
|
60 |
+
|
61 |
|
62 |
@tool
|
63 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
96 |
|
97 |
agent = CodeAgent(
|
98 |
model=model,
|
99 |
+
tools=[final_answer,generate_data_science_steps], ## add your tools here (don't remove final answer)
|
100 |
max_steps=6,
|
101 |
verbosity_level=1,
|
102 |
grammar=None,
|