This is the snapshot the production landing site (nibiru-framework.com) is deployed from. Brings together the recent splash + docs migration to the v4 "Cosmos" design system, the new in-framework AI module, and the framework groundwork that backs the framework-reference extraction. What lands: - docs/: Astro + Starlight site with the v4 dark cosmic palette, GalaxyHero canvas constellation, Mission Control chat (wired to /api/oracle → api.neuronetz.ai via providers.mjs Ollama), 5-panel MMVC stage (Model · AI · Module · Controller · View), translated EN/DE/JA/ES/FR content, PWA + sitemap + llms.txt + Umami analytics. - docs/design-system/: canonical mockup bundle (source/index-v2.html for splash, source/docs-system.html + preview/ for docs, SPEC.md, tokens). - docs/scripts/extraction/framework-reference-v2.md: deep framework reference (~1.6k lines, file:line citations, every public factory and idiom — basis for the LoRA training corpus. - application/module/ai/: AI module with chat / embed / RAG / agent plugins, plus pdoQuery / httpGet / fileRead tools and Modelfile + smoke-test in training/. - application/module/users/: user / ACL / form-factory traits used as the reference plugin pattern for the framework docs. - application/settings/config/database/: schema + seed migrations including the AI module tables (200–203). - Form factory + autogenerator changes the framework-reference-v2 covers. Production secrets stay out: docs/.env, settings.production.ini and ai.production.ini are all gitignored (.example files are in tree). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
86 lines
3.1 KiB
PHP
86 lines
3.1 KiB
PHP
<?php
|
|
/**
|
|
* Smoke-test the AI module against the configured Ollama server.
|
|
* Defaults to localhost:11434; override via OLLAMA_BASE_URL env var.
|
|
*
|
|
* Run from the project root:
|
|
* php application/module/ai/training/smoke-test.php
|
|
*/
|
|
|
|
namespace {
|
|
require_once __DIR__ . '/../plugins/ollama.php';
|
|
require_once __DIR__ . '/../plugins/chat.php';
|
|
require_once __DIR__ . '/../plugins/embed.php';
|
|
|
|
use Nibiru\Module\Ai\Plugins\Chat;
|
|
use Nibiru\Module\Ai\Plugins\Embed;
|
|
use Nibiru\Module\Ai\Plugins\Ollama;
|
|
|
|
// Stand-in config. In real use this is loaded from settings/ai.ini via the
|
|
// Registry. Override the URL via the OLLAMA_BASE_URL env var when testing
|
|
// against a non-default Ollama instance.
|
|
$cfg = (object) [
|
|
'ollama_base_url' => getenv('OLLAMA_BASE_URL') ?: 'http://localhost:11434',
|
|
'ollama_timeout' => 60,
|
|
'ollama_retries' => 1,
|
|
'chat_model' => getenv('OLLAMA_CHAT_MODEL') ?: 'qwen2.5-coder:14b',
|
|
'chat_fallback_model' => 'qwen2.5-coder:14b',
|
|
'chat_system_prompt' => 'You are a Nibiru framework expert. Be concise.',
|
|
'chat_temperature' => 0.3,
|
|
'chat_max_tokens' => 200,
|
|
'embed_model' => getenv('OLLAMA_EMBED_MODEL') ?: 'nomic-embed-text',
|
|
];
|
|
|
|
echo "=== Ollama at ", $cfg->ollama_base_url, " ===\n";
|
|
$ollama = new Ollama($cfg);
|
|
try {
|
|
$models = $ollama->listModels();
|
|
$names = array_column($models['models'] ?? [], 'name');
|
|
echo " found ", count($names), " models\n";
|
|
echo " qwen2.5-coder:14b: ",
|
|
in_array('qwen2.5-coder:14b', $names, true) ? "yes" : "NO",
|
|
"\n";
|
|
} catch (\Throwable $e) {
|
|
echo " FAILED: ", $e->getMessage(), "\n";
|
|
exit(1);
|
|
}
|
|
|
|
echo "\n=== Chat::ask ===\n";
|
|
$chat = new Chat($cfg);
|
|
try {
|
|
$reply = $chat->ask('In one sentence, what does Form::create() do in Nibiru?');
|
|
echo " reply: ", trim($reply), "\n";
|
|
} catch (\Throwable $e) {
|
|
echo " FAILED: ", $e->getMessage(), "\n";
|
|
}
|
|
|
|
echo "\n=== Multi-turn chat ===\n";
|
|
$chat2 = new Chat($cfg);
|
|
try {
|
|
$chat2->user('Name three Nibiru singletons.');
|
|
$r1 = $chat2->complete();
|
|
echo " r1: ", trim($r1), "\n";
|
|
$chat2->user('And what does the second one do?');
|
|
$r2 = $chat2->complete();
|
|
echo " r2: ", trim($r2), "\n";
|
|
} catch (\Throwable $e) {
|
|
echo " FAILED: ", $e->getMessage(), "\n";
|
|
}
|
|
|
|
echo "\n=== Embed::cosine ===\n";
|
|
try {
|
|
$embed = new Embed($cfg);
|
|
$a = $embed->one('controller');
|
|
$b = $embed->one('module');
|
|
$c = $embed->one('hummingbird');
|
|
echo " dim(controller) = ", count($a), "\n";
|
|
echo " cos(controller, module) = ", number_format(Embed::cosine($a, $b), 3), "\n";
|
|
echo " cos(controller, hummingbird) = ", number_format(Embed::cosine($a, $c), 3), "\n";
|
|
} catch (\Throwable $e) {
|
|
echo " FAILED: ", $e->getMessage(), "\n";
|
|
echo " (expected if nomic-embed-text isn't pulled)\n";
|
|
}
|
|
|
|
echo "\nSmoke test done.\n";
|
|
}
|