Manage plots
create_offline_markdown(original_text, plot_filenames)
Rewrites image links in the Markdown report for offline portability.
The live API serves images via endpoints (e.g., /api/v1/plots/...).
However, when saving the report to MLflow or zip files, these links need
to be relative filesystem paths (e.g., plots/...) to render correctly
without a running server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
original_text
|
str
|
The Markdown text with API URLs. |
required |
plot_filenames
|
list[str]
|
List of valid plot filenames to verify/replace. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The Markdown text with updated image paths. |
Source code in api/src/services/manage_plots.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
extract_plots_from_result(result)
Parses the Agent's execution trace to identify generated plot files.
Since the LLM calls a plotting tool, the filename is returned within a
ToolReturnPart message. This function scans the history to extract these
filenames reliably, rather than relying on the LLM's final text description.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
AgentRunResult
|
The result object returned by |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: A list of unique filenames (e.g., |
list[str]
|
in the tool execution outputs. |
Source code in api/src/services/manage_plots.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |