Doc: code component output section (#14915)

### What problem does this PR solve?

code component output section

### Type of change

- [x] Documentation Update
This commit is contained in:
buua436
2026-05-14 13:42:40 +08:00
committed by GitHub
parent 48b4aa3e93
commit 82e06db8c3

View File

@@ -98,7 +98,49 @@ If you define output variables here, ensure they are also defined in your code i
### Output
The defined output variable(s) will be auto-populated here.
The output is split into two parts:
- **Business**: the business output defined in **Return Value**
- **System**: runtime fields that are populated automatically, such as `content`, `actual_type`, and `attachments`
For example, the following code generates a simple line chart:
```Python
def main() -> dict:
from pathlib import Path
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
artifacts_dir = Path("artifacts")
artifacts_dir.mkdir(parents=True, exist_ok=True)
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
output_path = artifacts_dir / "simple_plot.png"
plt.figure(figsize=(6, 4))
plt.plot(x, y, marker="o")
plt.title("Simple Line Chart")
plt.xlabel("X")
plt.ylabel("Y")
plt.grid(True)
plt.tight_layout()
plt.savefig(output_path)
plt.close()
return {
"result": "plot generated successfully",
"file_path": str(output_path),
}
```
![](https://raw.githubusercontent.com/infiniflow/ragflow-docs/main/images/codeexec_output1.jpg)
Business Output shows the return value you defined, while System Output shows the generated `content`, the inferred `actual_type`, and the collected `attachments`.
![](https://raw.githubusercontent.com/infiniflow/ragflow-docs/main/images/codeexec_output2.jpg)
## Troubleshooting