
思い付きを構造に作り変える方法
AIを利用して、構造化したデータを特定フォーマットで生成する方法を試行していますが、実行までには処理が必要です。アイデアは構造化されていないことが多いため、それらを再利用可能なデータへと変換する手法として、現在このアプローチを試行しています。
```cbon
#!cbon-process
## Schema
@note(アイディア)
class Idea {
@note(タイトル)
optional string title;
@note(カテゴリ)
optional string category;
@note(要約)
required string summary;
}
class Request {
@note(入力されたテキスト)
optional string prompt;
@note(タスク)
required string task;
@note(スニペット)
required array<string> snippets;
const task
| @(prompt)を@(snippets)を参考にテキスト出力を行ってください。
| 要約は3行にまとめてください。
,
const snippets array<string> {
| Idea {
| title: "ここにタイトルを入力",
| category: "ここにカテゴリを入力",
| summary:
| | ここに要約を入力
| | 要約は3行で入力
| | 内容が長くなる場合はその説明を別のオブジェクトを生成して分割
| ,
,
}
}
process createObjectFromPrompt(Request) return(array<Idea>) format Cbon;
schema createObjectFromPrompt;
## Data / Execution
createObjectFromPrompt(Request {})
```これをAIに構造化モデルとしてアイデアを末尾に追加して入力し、次の画像の手順で特定フォーマットのデータを作成します。

Ideaは実際に利用したい構造へと作り変えて利用します。例えば、スキーマをレシピ作成用に次のように改変します。
range Positive<int> { (0, inf) };
range Positive<decimal> { (0.0, inf) };
@note(料理のレシピ)
class Recipe {
@note(レシピ名)
required string title;
@note(分量)
required Positive<int | decimal> servings;
@note(材料)
required array<Ingredient> ingredients;
@note(手順)
required array<string> steps;
@note(助言)
optional string tips;
@note(分量に単位を表す接辞を追加)
suffix servings "人前";
}
@note(材料)
class Ingredient {
@note(材料名)
required string item;
@note(分量)
required string amount;
}
class Request {
@note(入力されたテキスト)
optional string prompt;
@note(タスク)
required string task;
@note(スニペット)
required array<string> snippets;
const task
| @(prompt)を@(snippets)を参考にテキスト出力を行ってください。
| 手順や助言を簡潔にまとめてください。
,
const snippets array<string> {
| Recipe {
| title: "ここにタイトルを入力",
| servings: 1,
| ingredients: array<Ingredient> {
| // Ingredientを任意の回数挿入
| },
| steps: array<string> {
| // ここに3行にまとめた手順を任意の回数挿入
| },
| tips:
| | ここに助言を入力
| | 助言は3行で入力
| ,
| }
,
| Ingredient {
| item: "ここに材料名を入力",
| amount: "ここに数量を単位付きで入力",
| }
,
}
}
process createObjectFromPrompt(Request) return(array<Recipe>) format Cbon;
schema createObjectFromPrompt;これにより、断片的なアイデアからでも、定義したスキーマに沿った構造化データを即座に生成することが可能になります。