32 lines
1.1 KiB
PHP
32 lines
1.1 KiB
PHP
<?php
|
|
// WEVIA Prompt API — retourne le system prompt compact
|
|
// Usage: GET /api/wevia-prompt.php → system prompt
|
|
// Usage: GET /api/wevia-prompt.php?format=json → JSON
|
|
header('Content-Type: text/plain; charset=utf-8');
|
|
header('Cache-Control: public, max-age=300'); // cache 5min
|
|
|
|
$VAULT = '/opt/obsidian-vault';
|
|
$prompt_file = $VAULT . '/doctrines/000-system-prompt.md';
|
|
$digest_file = $VAULT . '/doctrines/000-DIGEST-COMPACT.md';
|
|
|
|
// Lire le prompt principal
|
|
$prompt = file_exists($prompt_file) ? file_get_contents($prompt_file) : '';
|
|
|
|
// Ajouter le digest compact si format=full
|
|
if (isset($_GET['format']) && $_GET['format'] === 'full') {
|
|
$digest = file_exists($digest_file) ? file_get_contents($digest_file) : '';
|
|
$prompt .= "\n\n" . $digest;
|
|
}
|
|
|
|
if (isset($_GET['format']) && $_GET['format'] === 'json') {
|
|
header('Content-Type: application/json');
|
|
echo json_encode([
|
|
'prompt' => $prompt,
|
|
'tokens' => intval(strlen($prompt) / 4),
|
|
'file' => 'doctrines/000-system-prompt.md',
|
|
'editable' => '/vault-manager.html → doctrines → 000-system-prompt'
|
|
]);
|
|
} else {
|
|
echo $prompt;
|
|
}
|