日本語
アウトプットファイルとテキストデータの作成と管理
- id: process_data name: process_data tool: PYTHON_SANDBOX_RUN input: - name: code value: | import json # データをここで処理 data = [ ["名前", "年齢", "都市"], ["田中", "30", "東京"], ["佐藤", "25", "大阪"] ] result = "\n".join([",".join(row) for row in data]) print(result) - id: save_report name: save_report tool: OUTPUT_FILE input: - name: content value: "{{steps.process_data.result.stdout}}" - name: filename value: "user_report.csv" - name: fileType value: "csv"
- id: collect_data name: collect_data tool: OPENAI_INVOKE config: - name: version value: gpt-4 input: - name: prompt value: | 以下のデータでJSON構造を作成してください: {{steps.previous_step.result.content}} 適切な構造で有効なJSONとしてフォーマットしてください。 - id: export_json name: export_json tool: OUTPUT_FILE input: - name: content value: "{{steps.collect_data.result.content}}" - name: filename value: "processed_data.json" - name: fileType value: "json" - id: confirm_export name: confirm_export tool: OUTPUT_TEXT input: - name: text value: "データの正常エクスポート先: {{steps.export_json.result.signed_url}}"
- id: generate_report_data name: generate_report_data tool: PYTHON_SANDBOX_RUN input: - name: code value: | import json import yaml # サンプルレポートデータ report_data = { "title": "月次売上レポート", "period": "2024年1月", "metrics": { "total_sales": 45000, "new_customers": 120, "conversion_rate": 0.15 }, "top_products": [ {"name": "商品A", "sales": 15000}, {"name": "商品B", "sales": 12000} ] } # 異なる形式を生成 json_output = json.dumps(report_data, indent=2, ensure_ascii=False) yaml_output = yaml.dump(report_data, default_flow_style=False, allow_unicode=True) print("JSON_DATA:", json_output) print("YAML_DATA:", yaml_output) - id: save_json_report name: save_json_report tool: OUTPUT_FILE input: - name: content value: "{{steps.generate_report_data.result.stdout | split('JSON_DATA: ')[1] | split('YAML_DATA:')[0] | trim}}" - name: filename value: "sales_report.json" - name: fileType value: "json" - id: save_yaml_report name: save_yaml_report tool: OUTPUT_FILE input: - name: content value: "{{steps.generate_report_data.result.stdout | split('YAML_DATA: ')[1] | trim}}" - name: filename value: "sales_report.yaml" - name: fileType value: "yaml"