You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: optuna_dashboard/llm/prompt_templates/_generate_plotly_graph.py
+58Lines changed: 58 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -159,6 +159,44 @@
159
159
Return ONLY the final title string.
160
160
"""# noqa: E501
161
161
162
+
_RE_GENERATE_PLOTLY_GRAPH_PROMPT_TEMPLATE="""Please rewrite a JavaScript function that, given the Study object named `study`, returns an array of Plotly trace objects (PlotData[]) to visualize the user's request. Apply the user's modification request to the previously generated function while preserving all unaffected behavior.
163
+
164
+
Requirements:
165
+
1. Input: a variable `study` of type Study (see definitions below). Do not redefine `study`.
166
+
2. Output: an array (e.g. `[trace1, trace2, ...]`) of Plotly trace objects (each object corresponds to a Plotly `data` item). Do NOT include the layout object, only data traces.
167
+
3. The function must be a pure function: it must not modify `study` or any trials inside it.
168
+
4. No network requests, no DOM access, no external I/O, no eval, no Function constructor.
169
+
5. Handle missing or incomplete trials safely: skip trials where required values are undefined (e.g. failed trials without `values`).
170
+
6. Ensure arrays `x` and `y` are the same length for each trace. Filter out undefined entries first.
171
+
7. Avoid extremely large custom objects; keep each trace under ~5000 points (if more, sample evenly).
172
+
8. Return only JavaScript function code; no surrounding code fences or commentary.
173
+
174
+
Study / Trial type definitions (for reference):
175
+
{study_definition_in_typescript}
176
+
177
+
====== Instructions Finished ======
178
+
179
+
Context:
180
+
181
+
Previously generated function:
182
+
------
183
+
{previous_function}
184
+
------
185
+
186
+
Your task:
187
+
Using the context above, return a valid JavaScript function code as is (note: do not wrap your output using code blocks such as ```javascript``` ).
188
+
At the very top of the function, include a brief comment summarizing how you applied the modification and any reasonable assumptions you had to make.
189
+
If the modification request is ambiguous, make a reasonable assumption and note it in a code comment at the top of the function.
0 commit comments