Files
neonail-database/app/Models/AiSetting.php
T
HousemannandClaude Sonnet 4.6 f60221d0ef Make Ollama prompt editable in admin AI settings
- Add prompt column to ai_settings (migration)
- AiSetting: DEFAULT_PROMPT constant + getActivePrompt() (falls back to default if empty)
- ProcessNailPolishImage: reads prompt from DB instead of hardcoded
- Admin view: textarea to edit prompt, shows active prompt, reset-to-default link

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 18:11:47 +02:00

41 lines
1.4 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class AiSetting extends Model
{
protected $table = 'ai_settings';
protected $fillable = ['ollama_url', 'ollama_model', 'prompt'];
public const DEFAULT_PROMPT = <<<PROMPT
You are analyzing a nail polish or nail product bottle/container image.
Extract exactly these three fields and respond ONLY with a valid JSON object, no explanation, no markdown:
{
"name": "the full product name or color description (e.g. 'Modeling Base Calcium Neutral Pink', 'Ruby Red', 'French White')",
"number": "the product code or article number printed on the label or cap (digits, letters, hyphens only — e.g. '12392-7', '123', 'NP-05')",
"manufacturer": "the brand or company name (the logo/brand printed on the product — e.g. 'NEONAIL', 'OPI', 'essie', 'Catrice')"
}
Rules:
- manufacturer = the brand/logo name (usually prominent on the label)
- name = the descriptive product/color name (NOT the brand)
- number = numeric or alphanumeric code (NOT the color name)
- If a value is genuinely not visible, use null
PROMPT;
public function getActivePrompt(): string
{
return !empty($this->prompt) ? $this->prompt : self::DEFAULT_PROMPT;
}
public static function get(): self
{
return static::firstOrCreate([], [
'ollama_url' => 'http://192.168.30.172:11434',
'ollama_model' => 'llama3.2-vision',
]);
}
}