Spaces:
Running
Running
Update index.html
Browse files- index.html +15 -171
index.html
CHANGED
@@ -22,12 +22,6 @@
|
|
22 |
border-radius: 8px;
|
23 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
24 |
}
|
25 |
-
.file-input {
|
26 |
-
margin-bottom: 20px;
|
27 |
-
}
|
28 |
-
.file-input input {
|
29 |
-
margin-right: 10px;
|
30 |
-
}
|
31 |
.results {
|
32 |
margin-top: 20px;
|
33 |
}
|
@@ -46,10 +40,6 @@
|
|
46 |
<body>
|
47 |
<div class="container">
|
48 |
<h1>Jupyter Agent Interface</h1>
|
49 |
-
<div class="file-input">
|
50 |
-
<label for="file-upload">Upload ZIP File:</label>
|
51 |
-
<input type="file" id="file-upload" accept=".zip" />
|
52 |
-
</div>
|
53 |
<button id="submit-btn">Submit</button>
|
54 |
<div class="results" id="results"></div>
|
55 |
</div>
|
@@ -59,7 +49,6 @@
|
|
59 |
import { Client } from "https://cdn.jsdelivr.net/npm/@gradio/client/+esm";
|
60 |
|
61 |
// Elementos del DOM
|
62 |
-
const fileInput = document.getElementById("file-upload");
|
63 |
const submitBtn = document.getElementById("submit-btn");
|
64 |
const resultsDiv = document.getElementById("results");
|
65 |
|
@@ -67,163 +56,15 @@
|
|
67 |
const client = await Client.connect("data-agents/jupyter-agent");
|
68 |
|
69 |
// Definir los parámetros para la solicitud
|
70 |
-
const systemPrompt =
|
71 |
-
# Data Science Agent Protocol
|
72 |
-
|
73 |
You are an intelligent data science assistant with access to an IPython interpreter. Your primary goal is to solve analytical tasks through careful, iterative exploration and execution of code. You must avoid making assumptions and instead verify everything through code execution.
|
74 |
-
|
75 |
## Core Principles
|
76 |
1. Always execute code to verify assumptions
|
77 |
2. Break down complex problems into smaller steps
|
78 |
3. Learn from execution results
|
79 |
4. Maintain clear communication about your process
|
80 |
-
|
81 |
-
|
82 |
-
You have access to these pre-installed packages:
|
83 |
-
|
84 |
-
### Core Data Science
|
85 |
-
- numpy (1.26.4)
|
86 |
-
- pandas (1.5.3)
|
87 |
-
- scipy (1.12.0)
|
88 |
-
- scikit-learn (1.4.1.post1)
|
89 |
-
|
90 |
-
### Visualization
|
91 |
-
- matplotlib (3.9.2)
|
92 |
-
- seaborn (0.13.2)
|
93 |
-
- plotly (5.19.0)
|
94 |
-
- bokeh (3.3.4)
|
95 |
-
- e2b_charts (latest)
|
96 |
-
|
97 |
-
### Image & Signal Processing
|
98 |
-
- opencv-python (4.9.0.80)
|
99 |
-
- pillow (9.5.0)
|
100 |
-
- scikit-image (0.22.0)
|
101 |
-
- imageio (2.34.0)
|
102 |
-
|
103 |
-
### Text & NLP
|
104 |
-
- nltk (3.8.1)
|
105 |
-
- spacy (3.7.4)
|
106 |
-
- gensim (4.3.2)
|
107 |
-
- textblob (0.18.0)
|
108 |
-
|
109 |
-
### Audio Processing
|
110 |
-
- librosa (0.10.1)
|
111 |
-
- soundfile (0.12.1)
|
112 |
-
|
113 |
-
### File Handling
|
114 |
-
- python-docx (1.1.0)
|
115 |
-
- openpyxl (3.1.2)
|
116 |
-
- xlrd (2.0.1)
|
117 |
-
|
118 |
-
### Other Utilities
|
119 |
-
- requests (2.26.0)
|
120 |
-
- beautifulsoup4 (4.12.3)
|
121 |
-
- sympy (1.12)
|
122 |
-
- xarray (2024.2.0)
|
123 |
-
- joblib (1.3.2)
|
124 |
-
|
125 |
-
## Environment Constraints
|
126 |
-
- You cannot install new packages or libraries
|
127 |
-
- Work only with pre-installed packages in the environment
|
128 |
-
- If a solution requires a package that's not available:
|
129 |
-
1. Check if the task can be solved with base libraries
|
130 |
-
2. Propose alternative approaches using available packages
|
131 |
-
3. Inform the user if the task cannot be completed with current limitations
|
132 |
-
|
133 |
-
## Analysis Protocol
|
134 |
-
|
135 |
-
### 1. Initial Assessment
|
136 |
-
- Acknowledge the user's task and explain your high-level approach
|
137 |
-
- List any clarifying questions needed before proceeding
|
138 |
-
- Identify which available files might be relevant from: {}
|
139 |
-
- Verify which required packages are available in the environment
|
140 |
-
|
141 |
-
### 2. Data Exploration
|
142 |
-
Execute code to:
|
143 |
-
- Read and validate each relevant file
|
144 |
-
- Determine file formats (CSV, JSON, etc.)
|
145 |
-
- Check basic properties:
|
146 |
-
- Number of rows/records
|
147 |
-
- Column names and data types
|
148 |
-
- Missing values
|
149 |
-
- Basic statistical summaries
|
150 |
-
- Share key insights about the data structure
|
151 |
-
|
152 |
-
### 3. Execution Planning
|
153 |
-
- Based on the exploration results, outline specific steps to solve the task
|
154 |
-
- Break down complex operations into smaller, verifiable steps
|
155 |
-
- Identify potential challenges or edge cases
|
156 |
-
|
157 |
-
### 4. Iterative Solution Development
|
158 |
-
For each step in your plan:
|
159 |
-
- Write and execute code for that specific step
|
160 |
-
- Verify the results meet expectations
|
161 |
-
- Debug and adjust if needed
|
162 |
-
- Document any unexpected findings
|
163 |
-
- Only proceed to the next step after current step is working
|
164 |
-
|
165 |
-
### 5. Result Validation
|
166 |
-
- Verify the solution meets all requirements
|
167 |
-
- Check for edge cases
|
168 |
-
- Ensure results are reproducible
|
169 |
-
- Document any assumptions or limitations
|
170 |
-
|
171 |
-
## Error Handling Protocol
|
172 |
-
When encountering errors:
|
173 |
-
1. Show the error message
|
174 |
-
2. Analyze potential causes
|
175 |
-
3. Propose specific fixes
|
176 |
-
4. Execute modified code
|
177 |
-
5. Verify the fix worked
|
178 |
-
6. Document the solution for future reference
|
179 |
-
|
180 |
-
## Communication Guidelines
|
181 |
-
- Explain your reasoning at each step
|
182 |
-
- Share relevant execution results
|
183 |
-
- Highlight important findings or concerns
|
184 |
-
- Ask for clarification when needed
|
185 |
-
- Provide context for your decisions
|
186 |
-
|
187 |
-
## Code Execution Rules
|
188 |
-
- Execute code through the IPython interpreter directly
|
189 |
-
- Understand that the environment is stateful (like a Jupyter notebook):
|
190 |
-
- Variables and objects from previous executions persist
|
191 |
-
- Reference existing variables instead of recreating them
|
192 |
-
- Only rerun code if variables are no longer in memory or need updating
|
193 |
-
- Don't rewrite or re-execute code unnecessarily:
|
194 |
-
- Use previously computed results when available
|
195 |
-
- Only rewrite code that needs modification
|
196 |
-
- Indicate when you're using existing variables from previous steps
|
197 |
-
- Run code after each significant change
|
198 |
-
- Don't show code blocks without executing them
|
199 |
-
- Verify results before proceeding
|
200 |
-
- Keep code segments focused and manageable
|
201 |
-
|
202 |
-
## Memory Management Guidelines
|
203 |
-
- Track important variables and objects across steps
|
204 |
-
- Clear large objects when they're no longer needed
|
205 |
-
- Inform user about significant objects kept in memory
|
206 |
-
- Consider memory impact when working with large datasets:
|
207 |
-
- Avoid creating unnecessary copies of large data
|
208 |
-
- Use inplace operations when appropriate
|
209 |
-
- Clean up intermediate results that won't be needed later
|
210 |
-
|
211 |
-
## Best Practices
|
212 |
-
- Use descriptive variable names
|
213 |
-
- Use little font for numbers in graphics chart
|
214 |
-
- Include comments for complex operations
|
215 |
-
- Handle errors gracefully
|
216 |
-
- Clean up resources when done
|
217 |
-
- Document any dependencies
|
218 |
-
- Prefer base Python libraries when possible
|
219 |
-
- Verify package availability before using
|
220 |
-
- Leverage existing computations:
|
221 |
-
- Check if required data is already in memory
|
222 |
-
- Reference previous results instead of recomputing
|
223 |
-
- Document which existing variables you're using
|
224 |
-
|
225 |
-
Remember: Verification through execution is always better than assumption!
|
226 |
-
`;
|
227 |
|
228 |
const userInput = `
|
229 |
Extract the CSV file (file1) from the ZIP archive (observations), clean and filter the data to keep only the "species_guess", "latitude", and "longitude" columns, then create a new CSV with the filtered information, and finally generate and show a pie chart that displays the percentage distribution of the only main species (those with a frequency over 1%). Only show graphics until over 1%.
|
@@ -232,25 +73,28 @@ Extract the CSV file (file1) from the ZIP archive (observations), clean and filt
|
|
232 |
const maxNewTokens = 512;
|
233 |
const model = "meta-llama/Llama-3.1-70B-Instruct";
|
234 |
|
|
|
|
|
|
|
235 |
// Manejar el envío del formulario
|
236 |
submitBtn.addEventListener("click", async () => {
|
237 |
-
if (!fileInput.files.length) {
|
238 |
-
resultsDiv.innerHTML = `<p class="error">Please upload a ZIP file.</p>`;
|
239 |
-
return;
|
240 |
-
}
|
241 |
-
|
242 |
-
// Limpiar resultados anteriores
|
243 |
resultsDiv.innerHTML = "<p>Processing...</p>";
|
244 |
|
245 |
try {
|
246 |
-
//
|
247 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
const result = await client.predict("/execute_jupyter_agent", {
|
249 |
sytem_prompt: systemPrompt,
|
250 |
user_input: userInput,
|
251 |
max_new_tokens: maxNewTokens,
|
252 |
model: model,
|
253 |
-
files: [
|
254 |
});
|
255 |
|
256 |
// Mostrar los resultados
|
|
|
22 |
border-radius: 8px;
|
23 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
24 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
.results {
|
26 |
margin-top: 20px;
|
27 |
}
|
|
|
40 |
<body>
|
41 |
<div class="container">
|
42 |
<h1>Jupyter Agent Interface</h1>
|
|
|
|
|
|
|
|
|
43 |
<button id="submit-btn">Submit</button>
|
44 |
<div class="results" id="results"></div>
|
45 |
</div>
|
|
|
49 |
import { Client } from "https://cdn.jsdelivr.net/npm/@gradio/client/+esm";
|
50 |
|
51 |
// Elementos del DOM
|
|
|
52 |
const submitBtn = document.getElementById("submit-btn");
|
53 |
const resultsDiv = document.getElementById("results");
|
54 |
|
|
|
56 |
const client = await Client.connect("data-agents/jupyter-agent");
|
57 |
|
58 |
// Definir los parámetros para la solicitud
|
59 |
+
const systemPrompt = `# Data Science Agent Protocol
|
|
|
|
|
60 |
You are an intelligent data science assistant with access to an IPython interpreter. Your primary goal is to solve analytical tasks through careful, iterative exploration and execution of code. You must avoid making assumptions and instead verify everything through code execution.
|
|
|
61 |
## Core Principles
|
62 |
1. Always execute code to verify assumptions
|
63 |
2. Break down complex problems into smaller steps
|
64 |
3. Learn from execution results
|
65 |
4. Maintain clear communication about your process
|
66 |
+
... (el resto del prompt aquí) ...
|
67 |
+
Remember: Verification through execution is always better than assumption!`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
const userInput = `
|
70 |
Extract the CSV file (file1) from the ZIP archive (observations), clean and filter the data to keep only the "species_guess", "latitude", and "longitude" columns, then create a new CSV with the filtered information, and finally generate and show a pie chart that displays the percentage distribution of the only main species (those with a frequency over 1%). Only show graphics until over 1%.
|
|
|
73 |
const maxNewTokens = 512;
|
74 |
const model = "meta-llama/Llama-3.1-70B-Instruct";
|
75 |
|
76 |
+
// URL del archivo ZIP en Hugging Face
|
77 |
+
const fileUrl = "https://huggingface.co/your-username/your-space-name/resolve/main/observations.zip";
|
78 |
+
|
79 |
// Manejar el envío del formulario
|
80 |
submitBtn.addEventListener("click", async () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
resultsDiv.innerHTML = "<p>Processing...</p>";
|
82 |
|
83 |
try {
|
84 |
+
// Descargar el archivo ZIP desde Hugging Face
|
85 |
+
const response = await fetch(fileUrl);
|
86 |
+
if (!response.ok) {
|
87 |
+
throw new Error(`Failed to fetch file: ${response.statusText}`);
|
88 |
+
}
|
89 |
+
const fileBlob = await response.blob();
|
90 |
+
|
91 |
+
// Enviar la solicitud al agente Jupyter
|
92 |
const result = await client.predict("/execute_jupyter_agent", {
|
93 |
sytem_prompt: systemPrompt,
|
94 |
user_input: userInput,
|
95 |
max_new_tokens: maxNewTokens,
|
96 |
model: model,
|
97 |
+
files: [new File([fileBlob], "observations.zip")], // Convertir el blob en un objeto File
|
98 |
});
|
99 |
|
100 |
// Mostrar los resultados
|