了解。
ここでは Gemini を “AI 実行エンジン(CPU)” として使う場合の、最適化された AI パイプラインプロンプト(完全版) を提示する。
これは Flask バックエンドから Gemini を呼び出すための正式な I/O 仕様で、
あなたの OS レイヤー構造・胆(core intent)語彙体系・責務分離思想に完全準拠している。
しかも Claude が設計し、Cline が実装し、Gemini が実行するという三層構造に最適化してある。
🚀 高校数学 個人学習 OS:Gemini 用 AI パイプラインプロンプト(最適化版)
以下は Flask → Gemini API に渡すための正式プロンプト。
すべて 構造化 JSON 入出力で、OS の意味レイヤーと完全に一致する。
🧩 1. OCR(画像 → テキスト)
目的
PNG から数式を含むテキストを抽出する。
意味推論はしない。純粋な視覚→言語変換。
Gemini プロンプト(OCR)
You are an OCR engine specialized in mathematical expressions.
Extract all readable text and mathematical expressions from the image.
Return ONLY JSON in the following format:
{
"ocr_text": "<string>"
}
入力
{
"image_path": "path/to/image.png"
}
出力
{
"ocr_text": "..."
}
🧩 2. 構造化(テキスト → 数式構造 / 分野 / タイプ)
目的
OCR テキストを数学 OS の構造に変換する。
まだ「胆」は抽出しない。
Gemini プロンプト(構造化)
You are a mathematical structure analyzer.
Given OCR text, extract the mathematical structure without solving the problem.
Return ONLY JSON:
{
"domain": "<string>", // 例: 微分, 積分, 確率
"type": "<string>", // 例: 合成関数, 置換積分
"expression": "<LaTeX>",
"metadata": {
"variables": [...],
"conditions": [...],
"notes": "..."
}
}
入力
{
"ocr_text": "..."
}
🧩 3. 胆抽出(core intent)
目的
構造化された問題から 胆(core intent) を抽出する。
語彙体系(core_intents.json)を参照して分類する。
Gemini プロンプト(胆抽出)
You are a core-intent extractor for high school mathematics.
Using the provided structure and the official core_intent vocabulary,
identify the core intent and required operations.
Return ONLY JSON:
{
"core_intent": "<string>",
"key_operations": ["...", "..."],
"typical_mistakes": ["...", "..."]
}
入力
{
"expression": "...",
"metadata": {...},
"vocab": { ... } // core_intents.json をそのまま渡す
}
🧩 4. 類題生成(core intent → 10問)
目的
胆(core intent)と operations を使って、
構造的に正しい類題を 10 問生成する。
Gemini プロンプト(類題生成)
You are a math problem generator.
Generate 10 problems that share the same core intent and operations.
Do NOT solve the problems.
Return ONLY JSON:
{
"problems": [
{ "text": "..." },
...
]
}
入力
{
"core_intent": "合成関数の微分",
"key_operations": [
"外側の関数を見つける",
"内側の関数を見つける",
"外側を微分する",
"内側をそのまま残す",
"内側を微分する",
"掛け合わせる"
]
}
🧩 5. 解答ステップ生成(問題 → ステップ列)
目的
問題文を、OS の「操作単位(step)」に分解する。
Gemini プロンプト(ステップ生成)
You are a math solution step generator.
Break the problem into minimal reasoning steps.
Each step must be atomic and correspond to a single mathematical operation.
Return ONLY JSON:
{
"steps": [
{
"step_index": 1,
"step_text": "..."
},
...
]
}
入力
{
"text": "..."
}
🧩 6. 深掘り(未納得ステップ → 補助説明 or 補助問題)
目的
ユーザが「未納得」としたステップを深掘りする。
Gemini プロンプト(深掘り)
You are a math tutor.
Given a step the user did not understand, generate a deeper explanation
AND an optional simpler sub-problem.
Return ONLY JSON:
{
"explanation": "...",
"sub_problem": "..."
}
入力
{
"step_text": "..."
}
🔥 このパイプラインが “最適化版” である理由
✔ OS レイヤーと完全一致
- OCR
- 構造化
- 胆抽出
- 類題生成
- ステップ生成
- 深掘り
すべてが 責務分離 されている。
✔ Claude が設計し、Cline が実装し、Gemini が実行する構造
- Claude → プロンプト設計・コード生成
- Cline → Flask 実装・ファイル生成
- Gemini → AI 計算処理
三者が OS の三層構造として噛み合う。
✔ JSON I/O が固定されているため、壊れない
Gemini の出力が壊れない限り、
Flask → DB → UI の流れが安定する。
🎉 次に進むならどれにする?
- Flask 側の AI 呼び出しコード(services 層) を作る
- Gemini プロンプトを core intent 語彙体系と完全連動 させる
- 深掘りモードの 弱点抽出ロジック を OS 化する
- Cline 用の Flask + Gemini 一括生成プロンプト(最終版) を作る
どれを進めたいか教えてほしい。