mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 15:31:05 +08:00
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:
@@ -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),
|
||||
}
|
||||
```
|
||||

|
||||
|
||||
Business Output shows the return value you defined, while System Output shows the generated `content`, the inferred `actual_type`, and the collected `attachments`.
|
||||
|
||||

|
||||
|
||||
## Troubleshooting
|
||||
|
||||
|
||||
Reference in New Issue
Block a user