diff options
| author | tanaka takashi <isazaka@gmail.com> | 2026-09-12 21:19:16 +0900 |
|---|---|---|
| committer | tanaka takashi <isazaka@gmail.com> | 2026-09-12 21:19:16 +0900 |
| commit | 796251e5b0da524584c9e81b8ad6e1dcc0931aa3 (patch) | |
| tree | 783d55ee9c557ebed5bdd32d99366f22f3fc1139 /.github/instructions/python.instructions.md | |
| parent | 4f3f548b1b55d4c7477250fc3373b3bd6d0d397f (diff) | |
base prompt結合機能を追加
config.tomlの[prompt]でpositive/negativeのbase promptファイルを指定し、
MCP経由でLLMから渡されたプロンプトと結合してpipelineへ渡す機能を追加する。
プロンプトファイルは<root>/prompts/<file>に固定し、TOMLにはファイル名のみ
指定する。モデルパスと同じ方針でパストラバーサルを拒否する。
結合方式:
- positive: base_positive, user_positive の順でカンマ区切り
- negative: base_negative\nuser_negative の順で改行区切り
- baseが空の場合はuserプロンプトのみ(後方互換)
- [prompt]省略時はbase promptなし(後方互換)
結合場所はschema.pyのTextToImageRequest.create()に集約し、GuidedImageRequest
とInpaintImageRequestは内部でTextToImageRequest.create()を呼ぶため1箇所の
変更で3ツールすべてに適用される。MCP Tool入力にはbase promptを公開しない。
変更内容:
- config.py: PromptConfig dataclass、AppConfig.promptフィールド、
_read_promptヘルパー、load_configの[prompt]読込・validation追加。
positive_file/negative_fileはファイル名のみ受け付け、<root>/prompts/へ解決
- schema.py: _combineヘルパー、TextToImageRequest.create()に
base_positive/base_negative引数追加、GuidedImageRequest.create()と
InpaintImageRequest.create()から転送
- tools/generate_image.py: service.config.promptからbaseを取りcreate()へ渡す
- tools/generate_guided_image.py: 同上
- tools/inpaint_image.py: 同上
- tests/conftest.py: app_config fixtureにprompt=PromptConfig()追加
- tests/test_config.py: [prompt]の正常系・異常系テスト追加
(省略時空、ファイル読込、パストラバーサル拒否、ファイル不存在、positiveのみ)
- tests/test_schema.py: 結合ロジックのテスト追加
(base両方、positiveのみ、negativeのみ、base空、guided/inpaint転送)
- doc/config.md: §10 [prompt]セクション追記、設定項目一覧表・ディレクトリ構成・
全設定例更新、既存セクション番号を§11〜§13へ繰り下げ
- config.example.toml: [prompt]コメント例追記
- doc/Specifications.md: モデル構成表にBase prompt行追加、推奨ディレクトリに
prompts/追記、設定例更新
- doc/Design.md: 設定オブジェクトにPromptConfig追記、モデルパス解決表に
prompts/追加
- doc/mcp.md: §2.1にbase prompt結合の記載追記
- README.md: [prompt]設定例と結合規則の説明追記
検証:
- ruff format/check、pyright 0 errors、pytest 61 passed
- 実GPU・実モデルでstreamable-http経由generate_imageでbase prompt結合を確認
positive='masterpiece, best quality, ..., sharp focus, a small red cube on a white table'
negative='low quality, ..., jpeg artifacts\nnoise'
base前置・user後置の結合順序が仕様通り機能することをサーバログで検証済み
Diffstat (limited to '.github/instructions/python.instructions.md')
0 files changed, 0 insertions, 0 deletions
