feat: optimize Foundation Models backend for on-device model#63
Merged
Conversation
- Add GenerationOptions with temperature 0.5 for consistent output - Limit chat history to 4 messages / 300 chars to fit 4,096-token window - Add tests for history truncation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The on-device 3B model strongly follows instruction language, causing English responses even for Japanese input. Introduce InstructionLanguage enum and SystemPromptProvider to select Japanese system prompts for Foundation Models while keeping English for cloud backends. - Add InstructionLanguage enum and LLMBackend.instructionLanguage - Add SystemPromptProvider with LocalizedPrompt (enforces EN/JA pairs) - Add language parameter to PasteContext.buildSystemPrompt - Fix TOCTOU: capture LLMBackend.current once per request - Extract validateChatMessage to fix function_body_length violation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GenerationOptions(temperature: 0.5)で出力の一貫性を向上InstructionLanguageenum +SystemPromptProviderで型安全にEN/JAプロンプトを管理PasteContext.buildSystemPromptにlanguage:パラメータ追加LLMBackend.currentのTOCTOU問題を修正(1回キャプチャ)isDevelopmentModeフラグで設定画面から非表示化Test plan
--strict違反ゼロisDevelopmentMode = false)🤖 Generated with Claude Code