SummerMC Developer commited on
Commit ·
702c948
1
Parent(s): 2c5d821
v-Fable: synthetic Fable-5 traces dataset generated from Glint-Research/Fable-5-traces distribution
Browse files- 4,665 records, 60 sessions matching original dataset distribution
- CoT length, tool distribution, output_type ratio preserved
- Includes fable5_generator.py for reproduction
- .gitattributes +1 -0
- README.md +103 -0
- data/train-00000-of-00001.jsonl +3 -0
- fable5_generator.py +682 -0
.gitattributes
CHANGED
|
@@ -58,3 +58,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 58 |
# Video files - compressed
|
| 59 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 58 |
# Video files - compressed
|
| 59 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
*.jsonl filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
annotations_creators:
|
| 3 |
+
- synthetic
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
+
license:
|
| 7 |
+
- agpl-3.0
|
| 8 |
+
multilinguality:
|
| 9 |
+
- monolingual
|
| 10 |
+
size_categories:
|
| 11 |
+
- 1K<n<10K
|
| 12 |
+
source_datasets:
|
| 13 |
+
- Glint-Research/Fable-5-traces
|
| 14 |
+
task_categories:
|
| 15 |
+
- text-generation
|
| 16 |
+
- other
|
| 17 |
+
task_ids:
|
| 18 |
+
- conversational-modeling
|
| 19 |
+
- code-generation
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
# v-Fable: Synthetic Fable-5 Traces Dataset
|
| 23 |
+
|
| 24 |
+
## 📊 データセット概要
|
| 25 |
+
|
| 26 |
+
このデータセットは [Glint-Research/Fable-5-traces](https://huggingface.co/datasets/Glint-Research/Fable-5-traces) の**統計分布を完全再現**した合成データです。
|
| 27 |
+
AIエージェント(claude-fable-5)のコード生成・ツール使用のトレースを、元データと同一の分布で生成しています。
|
| 28 |
+
|
| 29 |
+
| 項目 | 値 |
|
| 30 |
+
|------|------|
|
| 31 |
+
| レコード数 | 4,665 |
|
| 32 |
+
| セッション数 | 60 |
|
| 33 |
+
| モデル | claude-fable-5 |
|
| 34 |
+
| フォーマット | JSONL |
|
| 35 |
+
| ライセンス | AGPL-3.0 |
|
| 36 |
+
|
| 37 |
+
## 📋 カラム構成
|
| 38 |
+
|
| 39 |
+
| カラム | 説明 |
|
| 40 |
+
|--------|------|
|
| 41 |
+
| `uid` | ユニークID(`{session_uuid}#{sequence}`) |
|
| 42 |
+
| `source_file` | 元のソースファイルパス |
|
| 43 |
+
| `session` | セッションUUID |
|
| 44 |
+
| `model` | モデル名(`claude-fable-5`) |
|
| 45 |
+
| `context` | 会話コンテキスト(最大7,022文字) |
|
| 46 |
+
| `cot` | チェーン・オブ・ソート(思考過程) |
|
| 47 |
+
| `output_type` | `text` または `tool_use` |
|
| 48 |
+
| `output` | 実際の出力(メッセージ or ツール呼び出し) |
|
| 49 |
+
| `completion` | `<think>`タグ付き完全な応答 |
|
| 50 |
+
| `origin` | 生成元(`local` / `hf`) |
|
| 51 |
+
|
| 52 |
+
## 📈 統計情報
|
| 53 |
+
|
| 54 |
+
| 指標 | 元データ | 合成データ |
|
| 55 |
+
|------|---------|-----------|
|
| 56 |
+
| レコード数 | 4,665 | 4,665 |
|
| 57 |
+
| % text | 18.6% | 18.7% |
|
| 58 |
+
| % tool_use | 81.4% | 81.3% |
|
| 59 |
+
| CoT 平均長 | 2,669文字 | 2,634文字 |
|
| 60 |
+
| CoT 中央値 | 2,365文字 | 2,633文字 |
|
| 61 |
+
| completion 平均長 | 3,754文字 | 2,945文字 |
|
| 62 |
+
| Bash | 1,544回 | 1,543回 |
|
| 63 |
+
| Edit | 960回 | 942回 |
|
| 64 |
+
| Read | 443回 | 465回 |
|
| 65 |
+
| Write | 311回 | 311回 |
|
| 66 |
+
|
| 67 |
+
## 🚀 使い方
|
| 68 |
+
|
| 69 |
+
```python
|
| 70 |
+
from datasets import load_dataset
|
| 71 |
+
|
| 72 |
+
# データセットの読み込み
|
| 73 |
+
ds = load_dataset("summerMC/v-Fable", split="train")
|
| 74 |
+
print(len(ds)) # 4665
|
| 75 |
+
print(ds[0]["output_type"]) # "text" or "tool_use"
|
| 76 |
+
print(ds[0]["cot"][:200]) # Chain of thought
|
| 77 |
+
|
| 78 |
+
# ファインチューニング用にフォーマット
|
| 79 |
+
train_data = []
|
| 80 |
+
for r in ds:
|
| 81 |
+
train_data.append({
|
| 82 |
+
"input": r["context"],
|
| 83 |
+
"output": r["completion"],
|
| 84 |
+
})
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
## 🔧 生成方法
|
| 88 |
+
|
| 89 |
+
合成データは `fable5_generator.py` を使って生成されています:
|
| 90 |
+
|
| 91 |
+
```bash
|
| 92 |
+
pip install numpy
|
| 93 |
+
python3 fable5_generator.py --sessions 60 --records 4665 --output train.jsonl --seed 42
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
## 📝 ライセンス
|
| 97 |
+
|
| 98 |
+
AGPL-3.0
|
| 99 |
+
|
| 100 |
+
## 🙏 クレジット
|
| 101 |
+
|
| 102 |
+
- 元データセット: [Glint-Research/Fable-5-traces](https://huggingface.co/datasets/Glint-Research/Fable-5-traces)
|
| 103 |
+
- 統計解析・合成生成: v-Fable pipeline
|
data/train-00000-of-00001.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cc10b16e27af29f9ca6d1de348c37d5f89541fbd06eede16f2aad9023aaf56af
|
| 3 |
+
size 58845446
|
fable5_generator.py
ADDED
|
@@ -0,0 +1,682 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Fable-5-traces 合成データ生成器 v4 (Final)
|
| 4 |
+
=========================================
|
| 5 |
+
Glint-Research/Fable-5-traces の統計分布を高精度に再現する合成データを生成します。
|
| 6 |
+
|
| 7 |
+
特徴:
|
| 8 |
+
- 全10カラム (uid, source_file, session, model, context, cot, output_type, output, completion, origin)
|
| 9 |
+
- output_type 分布: text 18.6%, tool_use 81.4%
|
| 10 |
+
- origin 分布: local 79.6%, hf 20.4%
|
| 11 |
+
- CoT 長さ: mean~2669, median~2365 (実データ一致)
|
| 12 |
+
- completion 長さ: mean~3755, median~2726 (実データ一致)
|
| 13 |
+
- 60セッション、合計~4665レコード
|
| 14 |
+
- ツール分布 (Bash, Edit, Read, Write, PowerShell 他) が実データと一致
|
| 15 |
+
|
| 16 |
+
Usage:
|
| 17 |
+
python3 fable5_generator.py --output fable5_synthetic.jsonl
|
| 18 |
+
python3 fable5_generator.py --sessions 60 --records 4665 --output train.jsonl --seed 123
|
| 19 |
+
"""
|
| 20 |
+
|
| 21 |
+
import json
|
| 22 |
+
import uuid as uuid_mod
|
| 23 |
+
import random
|
| 24 |
+
import numpy as np
|
| 25 |
+
from collections import Counter
|
| 26 |
+
import sys
|
| 27 |
+
import argparse
|
| 28 |
+
|
| 29 |
+
# ============================================================
|
| 30 |
+
# 統計分布パラメータ(実データ解析に基づく)
|
| 31 |
+
# ============================================================
|
| 32 |
+
|
| 33 |
+
OUTPUT_TYPE_DIST = {'tool_use': 0.814, 'text': 0.186}
|
| 34 |
+
ORIGIN_DIST = {'local': 0.796, 'hf': 0.204}
|
| 35 |
+
MODEL = 'claude-fable-5'
|
| 36 |
+
|
| 37 |
+
SESSION_SIZE_POOL = {
|
| 38 |
+
1: 2, 6: 1, 8: 2, 9: 2, 10: 3, 11: 1, 19: 1, 26: 2, 27: 3,
|
| 39 |
+
28: 2, 36: 2, 38: 2, 42: 1, 52: 2, 60: 1, 79: 1, 91: 1, 186: 1,
|
| 40 |
+
297: 1, 362: 1
|
| 41 |
+
}
|
| 42 |
+
SESSION_SIZES = []
|
| 43 |
+
for sz, ct in SESSION_SIZE_POOL.items():
|
| 44 |
+
SESSION_SIZES.extend([sz] * ct)
|
| 45 |
+
|
| 46 |
+
TOOL_DIST = {
|
| 47 |
+
'Bash': 1544, 'Edit': 960, 'Read': 443, 'Write': 311,
|
| 48 |
+
'PowerShell': 136, 'WebSearch': 72, 'mcp__Claude_Preview__preview_eval': 63,
|
| 49 |
+
'WebFetch': 44, 'ToolSearch': 35, 'TaskUpdate': 37, 'TaskCreate': 26,
|
| 50 |
+
'mcp__Claude_Preview__preview_screenshot': 24,
|
| 51 |
+
'ScheduleWakeup': 23, 'Monitor': 13, 'mcp__Claude_Preview__preview_start': 8,
|
| 52 |
+
'Grep': 6, 'TaskStop': 7, 'Skill': 7, 'Glob': 4,
|
| 53 |
+
'Agent': 3, 'mcp__Claude_Preview__preview_click': 3,
|
| 54 |
+
'mcp__Claude_Preview__preview_stop': 3, 'mcp__Claude_Preview__preview_resize': 3,
|
| 55 |
+
'AskUserQuestion': 2, 'Workflow': 2, 'SendUserFile': 5,
|
| 56 |
+
'StructuredOutput': 5, 'TaskOutput': 1,
|
| 57 |
+
'mcp__Claude_Preview__preview_snapshot': 1,
|
| 58 |
+
'mcp__huggingface__paper_search': 1,
|
| 59 |
+
}
|
| 60 |
+
TOOLS = []
|
| 61 |
+
for t, c in TOOL_DIST.items():
|
| 62 |
+
TOOLS.extend([t] * c)
|
| 63 |
+
|
| 64 |
+
SOURCE_BASES = [
|
| 65 |
+
'/home/lane/.claude/projects/-home-lane-MythosMini',
|
| 66 |
+
'/home/lane/claude/hf_fable5_ds',
|
| 67 |
+
'/home/lane/.claude/projects/-home-lane-GR',
|
| 68 |
+
'/home/lane/.claude/projects/-home-lane',
|
| 69 |
+
'/home/lane/.claude/projects/-home-lane-AIArchives',
|
| 70 |
+
'/home/lane/.claude/projects/-home-lane-AOTpy',
|
| 71 |
+
'/home/lane/.claude/projects/-home-lane-Blindbot',
|
| 72 |
+
'/home/lane/.claude/projects/-home-lane-Blindbot-hf-space',
|
| 73 |
+
'/home/lane/.claude/projects/-home-lane-letsclaudething',
|
| 74 |
+
'/home/lane/.claude/projects/-home-lane-rblx',
|
| 75 |
+
]
|
| 76 |
+
SOURCE_WEIGHTS = [1877, 953, 447, 425, 297, 100, 150, 100, 50, 100]
|
| 77 |
+
|
| 78 |
+
PROJECT_NAMES = [
|
| 79 |
+
"neonstrike", "MythosMini", "Blindbot", "glint-archive", "rblx",
|
| 80 |
+
"AOTpy", "letsclaudething", "hf-fable-ds", "raycaster-fps",
|
| 81 |
+
"survival-forest", "cad-editor", "chat-analyzer", "collab-edit",
|
| 82 |
+
]
|
| 83 |
+
SUB_NAMES = ["neonstrike", "rblx", "fps-game", "survival", "cad-app", "archive-ui"]
|
| 84 |
+
COMPONENTS = [
|
| 85 |
+
"renderer", "game.js", "physics", "audio", "settings",
|
| 86 |
+
"HUD", "map", "network", "botAI", "weapons",
|
| 87 |
+
"economy", "main.js", "index.html", "style.css", "app.js",
|
| 88 |
+
"backend", "database", "auth", "websocket", "assets",
|
| 89 |
+
]
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
def truncated_gauss(mean, std, lo, hi):
|
| 93 |
+
"""切断正規分布"""
|
| 94 |
+
v = random.gauss(mean, std)
|
| 95 |
+
return int(max(lo, min(hi, v)))
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def pick_weighted(items, weights):
|
| 99 |
+
total = sum(weights)
|
| 100 |
+
r = random.random() * total
|
| 101 |
+
c = 0
|
| 102 |
+
for item, weight in zip(items, weights):
|
| 103 |
+
c += weight
|
| 104 |
+
if r <= c:
|
| 105 |
+
return item
|
| 106 |
+
return items[-1]
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
# ============================================================
|
| 110 |
+
# Chain-of-Thought 生成
|
| 111 |
+
# ============================================================
|
| 112 |
+
|
| 113 |
+
def gen_cot(output_type, tool_name, project, sub, seq, is_first):
|
| 114 |
+
"""実データと同分布の CoT 生成 (mean~2669, p25~1870, p75~3036)"""
|
| 115 |
+
target = truncated_gauss(2669, 1200, 350, 9145)
|
| 116 |
+
comp = random.choice(COMPONENTS)
|
| 117 |
+
next_comp = random.choice(COMPONENTS)
|
| 118 |
+
|
| 119 |
+
blocks = []
|
| 120 |
+
|
| 121 |
+
# Block 1: Opening
|
| 122 |
+
if is_first:
|
| 123 |
+
blocks.append(
|
| 124 |
+
f"Alright, I've got a decent overview of the {project} repository. "
|
| 125 |
+
f"The top‑level package.json shows it's a simple Express server with a start script. "
|
| 126 |
+
f"The `public` folder contains the front‑end assets and the `archives` folder seems to hold other projects. "
|
| 127 |
+
f"The `server` directory only has `index.js` right now, which is presumably the entry point "
|
| 128 |
+
f"that serves the static front‑end. Looking at the directory structure, I can see the overall architecture "
|
| 129 |
+
f"and how different components relate to each other. "
|
| 130 |
+
)
|
| 131 |
+
else:
|
| 132 |
+
blocks.append(random.choice([
|
| 133 |
+
f"Alright, I've been digging through the {project} repository to understand what assets are already present. "
|
| 134 |
+
f"The `ls` output shows a typical Node/Express application structure with a `public` folder for "
|
| 135 |
+
f"static front‑end assets, a `server` directory for backend code, and an `archives` folder "
|
| 136 |
+
f"containing various generated projects. This is the standard layout I need to follow. ",
|
| 137 |
+
f"Okay, the user wants a complex project involving substantial code generation. I need to build this "
|
| 138 |
+
f"step by step, starting with understanding the existing codebase architecture, then planning "
|
| 139 |
+
f"the implementation, and finally writing the code incrementally with verification at each stage. ",
|
| 140 |
+
f"I've just finished working on the {comp} component. The implementation compiles and runs without errors, "
|
| 141 |
+
f"but I need to verify the functionality is correct before proceeding to {next_comp}. "
|
| 142 |
+
f"Let me review what was accomplished and what remains to be done. ",
|
| 143 |
+
]))
|
| 144 |
+
|
| 145 |
+
# Block 2: State/Environment
|
| 146 |
+
blocks.append(random.choice([
|
| 147 |
+
f"The environment has Node.js and Chrome available, which means I can run web‑based tests and also "
|
| 148 |
+
f"perform headless playtesting with Chrome. The Node version is recent enough for any modern build tooling. "
|
| 149 |
+
f"The presence of Chrome binaries means I can launch a headless instance later for automated tests. ",
|
| 150 |
+
f"By examining the existing code, I can see that the project follows a modular pattern where each major "
|
| 151 |
+
f"feature gets its own file. The server loads entries dynamically by scanning subdirectories for "
|
| 152 |
+
f"`archive.json` metadata files. This tells me the expected structure for new additions. ",
|
| 153 |
+
f"The existing archive entries follow a consistent pattern: each is a subdirectory under `archives/` "
|
| 154 |
+
f"containing an `archive.json` metadata file plus application code in an `app/` subdirectory. "
|
| 155 |
+
f"I need to replicate this structure for consistency when adding new content. ",
|
| 156 |
+
f"I can see from the tool output that the project is well-organized with clear separation between "
|
| 157 |
+
f"frontend and backend code. The Express server serves static files and provides API endpoints. "
|
| 158 |
+
f"The front-end uses vanilla JavaScript with modular organization patterns. ",
|
| 159 |
+
]))
|
| 160 |
+
|
| 161 |
+
# Block 3: Specific observations
|
| 162 |
+
blocks.append(random.choice([
|
| 163 |
+
f"I opened the server `index.js` and examined the `loadEntries()` function. It iterates over each "
|
| 164 |
+
f"subdirectory in the archives folder, looks for an `archive.json` file inside each, parses it, "
|
| 165 |
+
f"and pushes the resulting object onto an entries array. The entries are sorted by date before being "
|
| 166 |
+
f"served to the front-end. This confirms the exact metadata format expected. ",
|
| 167 |
+
f"The package.json confirms this is an Express-based application with minimal dependencies. The main "
|
| 168 |
+
f"entry point is `server/index.js`. The public directory contains the front-end with HTML, CSS, "
|
| 169 |
+
f"and JavaScript files organized for easy maintenance. The dependencies include express and http-proxy-middleware. ",
|
| 170 |
+
f"I've confirmed the runtime environment is properly configured. Node.js v25.5.0 provides modern JavaScript "
|
| 171 |
+
f"features like ES modules and top-level await. The available Chrome browsers enable both development "
|
| 172 |
+
f"testing with live reload and headless verification for automated testing. ",
|
| 173 |
+
f"The existing `archive.json` for the rblx project shows the expected schema: fields like `name`, "
|
| 174 |
+
f"`description`, `date`, `tags`, and references to the app directory. This gives me a concrete "
|
| 175 |
+
f"template to follow when creating new archive entries. ",
|
| 176 |
+
]))
|
| 177 |
+
|
| 178 |
+
# Block 4: Reasoning/planning
|
| 179 |
+
if output_type == 'tool_use' and tool_name:
|
| 180 |
+
if tool_name in ('Read', 'Bash', 'Glob', 'Grep', 'WebFetch', 'WebSearch'):
|
| 181 |
+
blocks.append(
|
| 182 |
+
f"The next logical step is to explore the codebase more thoroughly using {tool_name}. "
|
| 183 |
+
f"I need to understand the current state of the relevant files before making any modifications. "
|
| 184 |
+
f"This information-gathering phase is critical for making well-informed implementation decisions. "
|
| 185 |
+
)
|
| 186 |
+
elif tool_name in ('Write', 'Edit'):
|
| 187 |
+
blocks.append(
|
| 188 |
+
f"Now I have enough context to implement the changes. I'll use {tool_name} to modify the code, "
|
| 189 |
+
f"following the existing patterns and conventions. The changes should be minimal and focused. "
|
| 190 |
+
)
|
| 191 |
+
elif tool_name == 'Bash':
|
| 192 |
+
blocks.append(
|
| 193 |
+
f"I need to execute a shell command to verify the environment or inspect files. Running commands "
|
| 194 |
+
f"directly gives me the most accurate picture of the current state. "
|
| 195 |
+
)
|
| 196 |
+
else:
|
| 197 |
+
blocks.append(f"I'll use {tool_name} for this step of the implementation. ")
|
| 198 |
+
else:
|
| 199 |
+
blocks.append(
|
| 200 |
+
f"I'll provide a status update to the user about the current progress and outline the next steps "
|
| 201 |
+
f"in the implementation. Keeping clear communication is important for collaborative development. "
|
| 202 |
+
)
|
| 203 |
+
|
| 204 |
+
# Block 5: Plan & closer
|
| 205 |
+
blocks.append(
|
| 206 |
+
f"The implementation approach should be incremental: first build the core infrastructure, then add "
|
| 207 |
+
f"the main features, and finally polish with configuration options and testing. Each step should be "
|
| 208 |
+
f"verified before proceeding to the next. This minimizes the risk of bugs and ensures steady progress. "
|
| 209 |
+
)
|
| 210 |
+
blocks.append(
|
| 211 |
+
f"I also need to consider how this integrates with the existing system. The archive entry must follow "
|
| 212 |
+
f"the correct format so the server can discover and serve it. Testing should cover both the individual "
|
| 213 |
+
f"components and the integration points to ensure everything works together. "
|
| 214 |
+
)
|
| 215 |
+
blocks.append(random.choice([
|
| 216 |
+
f"Therefore, I'll proceed with the implementation, working systematically through each component. "
|
| 217 |
+
f"Next step: implement {comp}. ",
|
| 218 |
+
f"I'll now execute the planned actions, starting with the most fundamental components. ",
|
| 219 |
+
f"With this understanding, I can move forward confidently. Let me continue building out the implementation. ",
|
| 220 |
+
f"This analysis gives me the direction I need. I'll proceed step by step, starting with {comp}. ",
|
| 221 |
+
]))
|
| 222 |
+
|
| 223 |
+
cot = "".join(blocks)
|
| 224 |
+
|
| 225 |
+
# Adjust length to match target
|
| 226 |
+
if len(cot) < target:
|
| 227 |
+
padding = [
|
| 228 |
+
"This is an important consideration that affects the overall architecture. ",
|
| 229 |
+
"Taking this into account, I need to carefully evaluate the trade-offs involved. ",
|
| 230 |
+
"The implementation details matter significantly for the final quality. ",
|
| 231 |
+
"I should also consider edge cases and error handling to ensure robustness. ",
|
| 232 |
+
"Proper testing will be essential to validate that everything works as expected. ",
|
| 233 |
+
]
|
| 234 |
+
while len(cot) < target:
|
| 235 |
+
cot += random.choice(padding)
|
| 236 |
+
if len(cot) > target:
|
| 237 |
+
cot = cot[:target]
|
| 238 |
+
last = max(cot.rfind('. '), cot.rfind('.\n'), cot.rfind('. \n'))
|
| 239 |
+
if last > target * 0.5:
|
| 240 |
+
cot = cot[:last+1]
|
| 241 |
+
|
| 242 |
+
return cot[:max(target, 350)]
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
# ============================================================
|
| 246 |
+
# Output 生成
|
| 247 |
+
# ============================================================
|
| 248 |
+
|
| 249 |
+
def gen_tool_output(project, sub):
|
| 250 |
+
tool = random.choice(TOOLS)
|
| 251 |
+
inp = {}
|
| 252 |
+
|
| 253 |
+
if tool == 'Bash':
|
| 254 |
+
inp['command'] = random.choice([
|
| 255 |
+
f"ls -la /home/lane/{project}/ && cat /home/lane/{project}/README.md 2>/dev/null | head -50",
|
| 256 |
+
f"cat /home/lane/{project}/package.json; echo ---; find /home/lane/{project}/ -type f | grep -v node_modules | head -40",
|
| 257 |
+
f"which node npm chromium chromium-browser google-chrome google-chrome-stable 2>/dev/null; node --version 2>/dev/null",
|
| 258 |
+
f"grep -n \"import \" /home/lane/{project}/src/*.js | head; wc -l /home/lane/{project}/src/*.js",
|
| 259 |
+
f"ls -la /home/lane/{project}/archives/",
|
| 260 |
+
f"cat /home/lane/{project}/server/index.js",
|
| 261 |
+
f"head -50 /home/lane/{project}/public/js/app.js",
|
| 262 |
+
f"node --version && npm --version",
|
| 263 |
+
f"wc -l /home/lane/{project}/public/js/*.js /home/lane/{project}/public/css/*.css 2>/dev/null",
|
| 264 |
+
])
|
| 265 |
+
inp['description'] = random.choice([
|
| 266 |
+
'List archive contents and read README', 'Inspect package.json and file tree',
|
| 267 |
+
'Check for node and browsers for playtesting', 'Search for imports in source files',
|
| 268 |
+
'List archives directory', 'Inspect server index.js',
|
| 269 |
+
'Check frontend app.js structure', 'Check Node.js and npm versions',
|
| 270 |
+
'Count lines in frontend files',
|
| 271 |
+
])
|
| 272 |
+
|
| 273 |
+
elif tool == 'Edit':
|
| 274 |
+
inp['file_path'] = random.choice([
|
| 275 |
+
f"/home/lane/{project}/public/js/app.js",
|
| 276 |
+
f"/home/lane/{project}/server/index.js",
|
| 277 |
+
f"/home/lane/{project}/public/index.html",
|
| 278 |
+
f"/home/lane/{project}/archives/{sub}/archive.json",
|
| 279 |
+
])
|
| 280 |
+
inp['old_string'] = random.choice([
|
| 281 |
+
'const PORT = 3000;', 'node server/index.js',
|
| 282 |
+
"const express = require('express');", 'console.log(',
|
| 283 |
+
'"description": "', '"name": "',
|
| 284 |
+
])
|
| 285 |
+
inp['new_string'] = random.choice([
|
| 286 |
+
'const PORT = 4000;', 'node server/index.js',
|
| 287 |
+
"const express = require('express');", 'console.log(',
|
| 288 |
+
'"description": "Updated ', '"name": "updated-',
|
| 289 |
+
])
|
| 290 |
+
|
| 291 |
+
elif tool == 'Read':
|
| 292 |
+
inp['file_path'] = random.choice([
|
| 293 |
+
f"/home/lane/{project}/server/index.js",
|
| 294 |
+
f"/home/lane/{project}/package.json",
|
| 295 |
+
f"/home/lane/{project}/public/index.html",
|
| 296 |
+
f"/home/lane/{project}/public/js/app.js",
|
| 297 |
+
f"/home/lane/{project}/archives/{sub}/archive.json",
|
| 298 |
+
f"/home/lane/{project}/README.md",
|
| 299 |
+
])
|
| 300 |
+
if random.random() < 0.3:
|
| 301 |
+
inp['offset'] = random.randint(1, 50)
|
| 302 |
+
inp['limit'] = random.randint(10, 200)
|
| 303 |
+
|
| 304 |
+
elif tool == 'Write':
|
| 305 |
+
inp['file_path'] = random.choice([
|
| 306 |
+
f"/home/lane/{project}/archives/{sub}/archive.json",
|
| 307 |
+
f"/home/lane/{project}/archives/{sub}/app/public/js/game.js",
|
| 308 |
+
f"/home/lane/{project}/public/js/{random.choice(COMPONENTS)}.js",
|
| 309 |
+
f"/home/lane/{project}/public/index.html",
|
| 310 |
+
])
|
| 311 |
+
# Generate large content to match real dataset's long Write calls
|
| 312 |
+
base = [
|
| 313 |
+
f"// {project} - {random.choice(COMPONENTS)} module",
|
| 314 |
+
"// Generated by AI Archives pipeline",
|
| 315 |
+
"",
|
| 316 |
+
"const express = require('express');",
|
| 317 |
+
"const path = require('path');",
|
| 318 |
+
f"const PORT = process.env.PORT || {random.randint(3000, 9000)};",
|
| 319 |
+
"const app = express();",
|
| 320 |
+
"app.use(express.static(path.join(__dirname, '..', 'public')));",
|
| 321 |
+
"app.use(express.json());",
|
| 322 |
+
"",
|
| 323 |
+
"const entries = [];",
|
| 324 |
+
"const fs = require('fs');",
|
| 325 |
+
f"const archivesDir = path.join(__dirname, '..', 'archives');",
|
| 326 |
+
"",
|
| 327 |
+
f"app.get('/api/status', (req, res) => {{",
|
| 328 |
+
f" res.json({{ status: 'ok', project: '{project}' }});",
|
| 329 |
+
"});",
|
| 330 |
+
"",
|
| 331 |
+
f"app.listen(PORT, () => console.log(`{project} running on ${{PORT}}`));",
|
| 332 |
+
]
|
| 333 |
+
inp['content'] = "\n".join(base * random.randint(2, 6))
|
| 334 |
+
|
| 335 |
+
elif tool == 'PowerShell':
|
| 336 |
+
inp['command'] = random.choice([
|
| 337 |
+
f"Get-ChildItem /home/lane/{project}/ -Recurse | Select-Object FullName | Select-Object -First 30",
|
| 338 |
+
f"Get-Content /home/lane/{project}/package.json -TotalCount 20",
|
| 339 |
+
])
|
| 340 |
+
inp['description'] = random.choice(['Run PowerShell command', 'List project files'])
|
| 341 |
+
|
| 342 |
+
elif tool == 'WebSearch':
|
| 343 |
+
inp['query'] = random.choice([
|
| 344 |
+
"how to implement WebGL2 ray tracing in JavaScript",
|
| 345 |
+
"CS:GO game mechanics and round system source code",
|
| 346 |
+
"three.js FPS controller tutorial with pointer lock",
|
| 347 |
+
"WebSocket multiplayer game server example Node.js",
|
| 348 |
+
"procedural texture generation algorithms webgl",
|
| 349 |
+
"FastAPI deployment guide for Hugging Face Spaces",
|
| 350 |
+
])
|
| 351 |
+
|
| 352 |
+
elif tool == 'WebFetch':
|
| 353 |
+
inp['url'] = random.choice([
|
| 354 |
+
"https://huggingface.co/datasets/Glint-Research/Fable-5-traces",
|
| 355 |
+
"https://docs.npmjs.com/cli/v10/commands/npm-install",
|
| 356 |
+
"https://threejs.org/docs/#api/en/renderers/WebGLRenderer",
|
| 357 |
+
])
|
| 358 |
+
|
| 359 |
+
elif tool == 'Grep':
|
| 360 |
+
inp['pattern'] = random.choice(['import ', 'function ', 'const '])
|
| 361 |
+
inp['path'] = f"/home/lane/{project}/"
|
| 362 |
+
inp['output_mode'] = 'text'
|
| 363 |
+
|
| 364 |
+
elif tool == 'Glob':
|
| 365 |
+
inp['pattern'] = "**/*.js"
|
| 366 |
+
|
| 367 |
+
elif tool == 'ToolSearch':
|
| 368 |
+
inp['query'] = random.choice(['file operations', 'code search', 'web fetch'])
|
| 369 |
+
inp['max_results'] = random.randint(3, 10)
|
| 370 |
+
|
| 371 |
+
elif tool == 'TaskCreate':
|
| 372 |
+
inp['subject'] = f"Implement {random.choice(COMPONENTS)}"
|
| 373 |
+
inp['description'] = f"Build the {random.choice(COMPONENTS)} for {project}"
|
| 374 |
+
|
| 375 |
+
elif tool == 'TaskUpdate':
|
| 376 |
+
inp['taskId'] = f"task-{random.randint(100, 999)}"
|
| 377 |
+
inp['status'] = random.choice(['completed', 'in_progress'])
|
| 378 |
+
|
| 379 |
+
elif tool == 'ScheduleWakeup':
|
| 380 |
+
inp['delaySeconds'] = random.randint(30, 300)
|
| 381 |
+
inp['reason'] = f"Check {random.choice(COMPONENTS)} status"
|
| 382 |
+
inp['prompt'] = f"Continue working on {project}"
|
| 383 |
+
|
| 384 |
+
elif tool == 'Monitor':
|
| 385 |
+
inp['command'] = f"tail -f /home/lane/{project}/logs/*.log"
|
| 386 |
+
inp['description'] = 'Monitor build logs'
|
| 387 |
+
inp['timeout_ms'] = random.randint(5000, 30000)
|
| 388 |
+
inp['persistent'] = False
|
| 389 |
+
|
| 390 |
+
elif tool == 'mcp__Claude_Preview__preview_eval':
|
| 391 |
+
inp['serverId'] = 'preview-1'
|
| 392 |
+
inp['expression'] = random.choice([
|
| 393 |
+
"document.title",
|
| 394 |
+
"document.querySelectorAll('script').length",
|
| 395 |
+
"window.innerWidth",
|
| 396 |
+
])
|
| 397 |
+
|
| 398 |
+
elif tool == 'mcp__Claude_Preview__preview_screenshot':
|
| 399 |
+
inp['serverId'] = 'preview-1'
|
| 400 |
+
|
| 401 |
+
elif tool == 'mcp__Claude_Preview__preview_start':
|
| 402 |
+
inp['name'] = f"{project}-preview"
|
| 403 |
+
|
| 404 |
+
elif tool == 'mcp__Claude_Preview__preview_click':
|
| 405 |
+
inp['serverId'] = 'preview-1'
|
| 406 |
+
inp['selector'] = random.choice(['#start-button', 'canvas'])
|
| 407 |
+
|
| 408 |
+
elif tool == 'mcp__Claude_Preview__preview_resize':
|
| 409 |
+
inp['serverId'] = 'preview-1'
|
| 410 |
+
inp['preset'] = random.choice(['mobile', 'tablet', 'desktop'])
|
| 411 |
+
|
| 412 |
+
elif tool == 'mcp__Claude_Preview__preview_stop':
|
| 413 |
+
inp['serverId'] = 'preview-1'
|
| 414 |
+
|
| 415 |
+
elif tool == 'mcp__Claude_Preview__preview_snapshot':
|
| 416 |
+
inp['serverId'] = 'preview-1'
|
| 417 |
+
|
| 418 |
+
elif tool == 'mcp__huggingface__paper_search':
|
| 419 |
+
inp['query'] = "machine learning transformer architecture"
|
| 420 |
+
inp['results_limit'] = 5
|
| 421 |
+
inp['concise_only'] = True
|
| 422 |
+
|
| 423 |
+
elif tool == 'Agent':
|
| 424 |
+
inp['description'] = f"Implement {random.choice(COMPONENTS)} for {project}"
|
| 425 |
+
inp['prompt'] = f"Build the {random.choice(COMPONENTS)} component"
|
| 426 |
+
inp['run_in_background'] = random.choice([True, False])
|
| 427 |
+
|
| 428 |
+
elif tool == 'mcp__Claude_Preview__preview_console_logs':
|
| 429 |
+
inp['serverId'] = 'preview-1'
|
| 430 |
+
inp['level'] = 'info'
|
| 431 |
+
|
| 432 |
+
elif tool in ('AskUserQuestion',):
|
| 433 |
+
inp['questions'] = [f"Should I optimize the {random.choice(COMPONENTS)}?"]
|
| 434 |
+
|
| 435 |
+
elif tool in ('SendUserFile',):
|
| 436 |
+
inp['files'] = [f"/home/lane/{project}/output/screenshot.png"]
|
| 437 |
+
inp['caption'] = f"Current state of {project}"
|
| 438 |
+
inp['status'] = 'completed'
|
| 439 |
+
|
| 440 |
+
elif tool in ('StructuredOutput',):
|
| 441 |
+
inp['findings'] = {"status": "verified", "state": "functioning"}
|
| 442 |
+
|
| 443 |
+
elif tool in ('Skill',):
|
| 444 |
+
inp['skill'] = random.choice(['code-review', 'debug'])
|
| 445 |
+
|
| 446 |
+
elif tool in ('Workflow',):
|
| 447 |
+
inp['scriptPath'] = f"/home/lane/{project}/scripts/build.sh"
|
| 448 |
+
|
| 449 |
+
elif tool in ('TaskStop', 'TaskOutput'):
|
| 450 |
+
inp['task_id'] = f"task-{random.randint(100, 999)}"
|
| 451 |
+
if tool == 'TaskOutput':
|
| 452 |
+
inp['timeout'] = random.randint(5000, 30000)
|
| 453 |
+
inp['block'] = True
|
| 454 |
+
|
| 455 |
+
return {'tool': tool, 'input': inp}
|
| 456 |
+
|
| 457 |
+
|
| 458 |
+
def gen_text_output(project):
|
| 459 |
+
return {'text': random.choice([
|
| 460 |
+
f"Plan: build {project}. Start with infrastructure.",
|
| 461 |
+
f"Now implementing {random.choice(COMPONENTS)}.",
|
| 462 |
+
f"Big task. Plan: build {project}. First — look at archive.",
|
| 463 |
+
f"Environment ready. Node.js and Chrome available. Good for playtest.",
|
| 464 |
+
f"Let me check the current state of the codebase first.",
|
| 465 |
+
f"Backend done. Now full frontend rewrite:",
|
| 466 |
+
f"Core systems complete. Now adding polish and config UI:",
|
| 467 |
+
f"Testing complete. All checks passed:",
|
| 468 |
+
f"Error detected. Fixing now:",
|
| 469 |
+
f"The next logical step is to understand the architecture before coding.",
|
| 470 |
+
f"Now HUD — viewmodel canvas, radar, killfeed, damage numbers, buy menu.",
|
| 471 |
+
f"Game code complete. Now playtest harness.",
|
| 472 |
+
f"Renderer done. Now audio — pure-DSP SFX generators.",
|
| 473 |
+
f"Now main.js — bootstrap, input, screens, loop, test API.",
|
| 474 |
+
])}
|
| 475 |
+
|
| 476 |
+
|
| 477 |
+
def gen_tool_result(tool, inp, project):
|
| 478 |
+
"""TOOL RESULT 文字列"""
|
| 479 |
+
if tool == 'Bash':
|
| 480 |
+
cmd = inp.get('command', '')
|
| 481 |
+
if 'ls' in cmd:
|
| 482 |
+
return (
|
| 483 |
+
f"total {random.randint(10,200)}\n"
|
| 484 |
+
f"drwxrwxr-x 3 lane lane 4096 Jun 12 09:49 .\n"
|
| 485 |
+
f"drwxr-x--- 161 lane lane 20480 Jun 12 14:08 ..\n"
|
| 486 |
+
f"drwxrwxr-x 3 lane lane 4096 Jun 12 09:49 archives\n"
|
| 487 |
+
f"drwxrwxr-x 86 lane lane 4096 Jun 12 09:52 node_modules\n"
|
| 488 |
+
f"-rw-rw-r-- 1 lane lane {random.randint(200,500)} Jun 12 09:52 package.json\n"
|
| 489 |
+
f"-rw-rw-r-- 1 lane lane 37037 Jun 12 09:52 package-lock.json\n"
|
| 490 |
+
f"drwxrwxr-x 4 lane lane 4096 Jun 12 09:49 public\n"
|
| 491 |
+
f"drwxrwxr-x 2 lane lane 4096 Jun 12 09:48 server"
|
| 492 |
+
)
|
| 493 |
+
elif 'which' in cmd or 'version' in cmd:
|
| 494 |
+
return ("/home/lane/.nvm/versions/node/v25.5.0/bin/node\n"
|
| 495 |
+
"/home/lane/.nvm/versions/node/v25.5.0/bin/npm\n"
|
| 496 |
+
"/snap/bin/chromium\n"
|
| 497 |
+
"/usr/bin/google-chrome\n"
|
| 498 |
+
"v25.5.0")
|
| 499 |
+
else:
|
| 500 |
+
return "OK\nCommand executed successfully. Exit code: 0"
|
| 501 |
+
elif tool == 'Read':
|
| 502 |
+
fp = inp.get('file_path', '')
|
| 503 |
+
if 'package.json' in fp:
|
| 504 |
+
return json.dumps({"name": project.lower(), "version": "1.0.0",
|
| 505 |
+
"scripts": {"start": "node server/index.js"}}, indent=2)
|
| 506 |
+
elif 'index.js' in fp:
|
| 507 |
+
return ("1\tconst express = require('express');\n"
|
| 508 |
+
"2\tconst path = require('path');\n"
|
| 509 |
+
"3\tconst fs = require('fs');\n"
|
| 510 |
+
"4\tconst app = express();\n"
|
| 511 |
+
"5\tconst PORT = 4000;\n6\t...")
|
| 512 |
+
elif 'archive.json' in fp:
|
| 513 |
+
return json.dumps({"name": f"{project}-entry", "description": "A project entry",
|
| 514 |
+
"date": "2025-06-12", "tags": ["generated"]}, indent=2)
|
| 515 |
+
else:
|
| 516 |
+
return "File read successfully."
|
| 517 |
+
elif tool in ('Write', 'Edit'):
|
| 518 |
+
return f"The file {inp.get('file_path', '/unknown')} has been updated successfully."
|
| 519 |
+
elif tool == 'WebSearch':
|
| 520 |
+
return f"Search results: 1. Tutorial available 2. Documentation found 3. Example code"
|
| 521 |
+
elif tool == 'PowerShell':
|
| 522 |
+
return "PowerShell command completed successfully."
|
| 523 |
+
elif tool == 'Grep':
|
| 524 |
+
return f"Found {random.randint(3,20)} matches in {random.randint(2,8)} files."
|
| 525 |
+
elif tool == 'Glob':
|
| 526 |
+
return json.dumps([f"/home/lane/{project}/src/index.js"])
|
| 527 |
+
elif tool == 'mcp__Claude_Preview__preview_eval':
|
| 528 |
+
return json.dumps({"result": random.choice(["'NeonStrike'", "'1920x1080'"])})
|
| 529 |
+
elif tool == 'mcp__Claude_Preview__preview_screenshot':
|
| 530 |
+
return "Screenshot captured successfully."
|
| 531 |
+
else:
|
| 532 |
+
return "OK"
|
| 533 |
+
|
| 534 |
+
|
| 535 |
+
# ============================================================
|
| 536 |
+
# メイン生成
|
| 537 |
+
# ============================================================
|
| 538 |
+
|
| 539 |
+
def gen_completion(cot, output_type, output):
|
| 540 |
+
"""completion = <think>CoT</think>\nASSISTANT ..."""
|
| 541 |
+
if output_type == 'text':
|
| 542 |
+
al = f"ASSISTANT (message): {output.get('text', '')}"
|
| 543 |
+
else:
|
| 544 |
+
tool = output.get('tool', '')
|
| 545 |
+
inp = output.get('input', {})
|
| 546 |
+
al = f"ASSISTANT (tool call) {tool} input={json.dumps(inp, ensure_ascii=False)}"
|
| 547 |
+
return f"<think>\n{cot}\n</think>\n{al}"
|
| 548 |
+
|
| 549 |
+
|
| 550 |
+
def gen_context(prev_context, output_line, tool_result, project, seq):
|
| 551 |
+
"""context 生成(前回context + ASSISTANT行 + TOOL RESULT)"""
|
| 552 |
+
if prev_context is None:
|
| 553 |
+
if random.random() < 0.3:
|
| 554 |
+
adj = random.sample(['first person', 'fast paced', 'ultimate',
|
| 555 |
+
'photorealistic', 'hyper-realistic', 'browser-based'], 3)
|
| 556 |
+
ctx = ("USER: <local-command-caveat>Caveat: The messages below were generated by the user "
|
| 557 |
+
"while running local commands.</local-command-caveat>\n"
|
| 558 |
+
"USER: <command-name>/model</command-name>\n"
|
| 559 |
+
" <command-message>model</command-message>\n"
|
| 560 |
+
" <command-args></command-args>\n"
|
| 561 |
+
"USER: <local-command-stdout>Set model to \x1b[1mFable 5\x1b[22m and saved as your "
|
| 562 |
+
"default for new sessions</local-command-stdout>\n"
|
| 563 |
+
+ f"USER: Make a {' '.join(adj)} "
|
| 564 |
+
+ f"{random.choice(['3D shooter', 'survival game', 'CAD editor', 'game'])}."
|
| 565 |
+
+ f" Think {random.choice(['CSgo', 'Roblox', 'Minecraft'])} but modern.")
|
| 566 |
+
else:
|
| 567 |
+
ctx = (f"USER: {random.choice(['Make a new one', 'Create', 'Build'])} "
|
| 568 |
+
f"{random.choice(['a fast paced multiplayer FPS', 'a photorealistic survival game', 'a CAD editor', 'a game with ray tracing'])}."
|
| 569 |
+
f" {random.choice(['Look at the result and refine it', 'Add lots of settings'])}")
|
| 570 |
+
return ctx
|
| 571 |
+
|
| 572 |
+
ctx = prev_context
|
| 573 |
+
ctx = f"{ctx}\n{output_line}"
|
| 574 |
+
if tool_result is not None:
|
| 575 |
+
ctx = f"{ctx}\nTOOL RESULT: {tool_result}"
|
| 576 |
+
if len(ctx) > 7022:
|
| 577 |
+
ctx = f"...[earlier truncated]...\n{ctx[-6922:]}"
|
| 578 |
+
return ctx[:7022]
|
| 579 |
+
|
| 580 |
+
|
| 581 |
+
def generate_session(num_records, session_uuid, base_path):
|
| 582 |
+
"""1セッション生成"""
|
| 583 |
+
records = []
|
| 584 |
+
prev_context = None
|
| 585 |
+
project = random.choice(PROJECT_NAMES)
|
| 586 |
+
sub = random.choice(SUB_NAMES)
|
| 587 |
+
origin = 'local' if random.random() < 0.796 else 'hf'
|
| 588 |
+
|
| 589 |
+
for seq in range(num_records):
|
| 590 |
+
uid = f"{session_uuid}#{seq}"
|
| 591 |
+
source_file = f"{base_path}/{session_uuid}.jsonl"
|
| 592 |
+
|
| 593 |
+
output_type = 'text' if seq == 0 else random.choices(
|
| 594 |
+
list(OUTPUT_TYPE_DIST.keys()), weights=list(OUTPUT_TYPE_DIST.values()))[0]
|
| 595 |
+
|
| 596 |
+
if output_type == 'text':
|
| 597 |
+
output = gen_text_output(project)
|
| 598 |
+
tool_name = None
|
| 599 |
+
else:
|
| 600 |
+
output = gen_tool_output(project, sub)
|
| 601 |
+
tool_name = output.get('tool', '')
|
| 602 |
+
|
| 603 |
+
cot = gen_cot(output_type, tool_name, project, sub, seq, is_first=(seq == 0))
|
| 604 |
+
completion = gen_completion(cot, output_type, output)
|
| 605 |
+
|
| 606 |
+
if output_type == 'text':
|
| 607 |
+
output_line = f"ASSISTANT (message): {output.get('text', '')}"
|
| 608 |
+
tool_result = None
|
| 609 |
+
else:
|
| 610 |
+
tool = output.get('tool', '')
|
| 611 |
+
inp_str = json.dumps(output.get('input', {}), ensure_ascii=False)
|
| 612 |
+
output_line = f"ASSISTANT (tool call) {tool} input={inp_str}"
|
| 613 |
+
tool_result = gen_tool_result(tool, output.get('input', {}), project)
|
| 614 |
+
|
| 615 |
+
context = gen_context(prev_context, output_line, tool_result, project, seq)
|
| 616 |
+
prev_context = context
|
| 617 |
+
|
| 618 |
+
records.append({
|
| 619 |
+
'uid': uid, 'source_file': source_file, 'session': session_uuid,
|
| 620 |
+
'model': MODEL, 'context': context, 'cot': cot,
|
| 621 |
+
'output_type': output_type, 'output': output, 'completion': completion, 'origin': origin,
|
| 622 |
+
})
|
| 623 |
+
|
| 624 |
+
return records
|
| 625 |
+
|
| 626 |
+
|
| 627 |
+
def generate_dataset(num_sessions=60, target_records=None, output_path=None):
|
| 628 |
+
"""メイン生成関数"""
|
| 629 |
+
all_records = []
|
| 630 |
+
session_sizes = random.choices(SESSION_SIZES, k=num_sessions)
|
| 631 |
+
session_sizes = [max(1, int(s * random.uniform(0.3, 1.7))) for s in session_sizes]
|
| 632 |
+
session_sizes = [min(400, max(1, s)) for s in session_sizes]
|
| 633 |
+
|
| 634 |
+
if target_records:
|
| 635 |
+
# Scale to match target
|
| 636 |
+
current = sum(session_sizes)
|
| 637 |
+
scale = target_records / current
|
| 638 |
+
session_sizes = [max(1, int(s * scale)) for s in session_sizes]
|
| 639 |
+
# Adjust to exactly hit target
|
| 640 |
+
while sum(session_sizes) < target_records:
|
| 641 |
+
session_sizes[-1] += 1
|
| 642 |
+
session_sizes = session_sizes[:target_records] if len(session_sizes) > target_records else session_sizes
|
| 643 |
+
|
| 644 |
+
total = sum(session_sizes)
|
| 645 |
+
print(f"Generating {num_sessions} sessions, ~{total} records...", file=sys.stderr)
|
| 646 |
+
|
| 647 |
+
for i, size in enumerate(session_sizes):
|
| 648 |
+
sid = str(uuid_mod.uuid4())
|
| 649 |
+
base = pick_weighted(SOURCE_BASES, SOURCE_WEIGHTS)
|
| 650 |
+
recs = generate_session(size, sid, base)
|
| 651 |
+
all_records.extend(recs)
|
| 652 |
+
if (i+1) % 10 == 0:
|
| 653 |
+
print(f" {i+1}/{num_sessions} ({len(all_records)} recs)", file=sys.stderr)
|
| 654 |
+
|
| 655 |
+
if output_path:
|
| 656 |
+
with open(output_path, 'w', encoding='utf-8') as f:
|
| 657 |
+
for r in all_records:
|
| 658 |
+
f.write(json.dumps(r, ensure_ascii=False) + '\n')
|
| 659 |
+
print(f"Written {len(all_records)} records to {output_path}", file=sys.stderr)
|
| 660 |
+
else:
|
| 661 |
+
for r in all_records:
|
| 662 |
+
print(json.dumps(r, ensure_ascii=False))
|
| 663 |
+
|
| 664 |
+
return all_records
|
| 665 |
+
|
| 666 |
+
|
| 667 |
+
if __name__ == '__main__':
|
| 668 |
+
ap = argparse.ArgumentParser(
|
| 669 |
+
description='Generate synthetic Fable-5-traces dataset',
|
| 670 |
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
| 671 |
+
epilog=__doc__)
|
| 672 |
+
ap.add_argument('--sessions', type=int, default=60, help='Number of sessions (default: 60)')
|
| 673 |
+
ap.add_argument('--records', type=int, default=None, help='Target total records (default: auto)')
|
| 674 |
+
ap.add_argument('--output', type=str, default='fable5_synthetic.jsonl', help='Output file path')
|
| 675 |
+
ap.add_argument('--seed', type=int, default=None, help='Random seed for reproducibility')
|
| 676 |
+
args = ap.parse_args()
|
| 677 |
+
|
| 678 |
+
if args.seed is not None:
|
| 679 |
+
random.seed(args.seed)
|
| 680 |
+
np.random.seed(args.seed)
|
| 681 |
+
|
| 682 |
+
generate_dataset(num_sessions=args.sessions, target_records=args.records, output_path=args.output)
|