Premier commit
This commit is contained in:
34
cli/init_assistant.php
Normal file
34
cli/init_assistant.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
if (PHP_SAPI != 'cli') {
|
||||
exit('PHP SAPI must be cli');
|
||||
}
|
||||
|
||||
require(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
foreach (require __DIR__ . '/../env.php' as $key => $val) {
|
||||
putenv("{$key}={$val}");
|
||||
}
|
||||
|
||||
$db = new PDO('sqlite:' . getenv('SQLITE_DB'));
|
||||
|
||||
|
||||
$query =<<<SQL
|
||||
CREATE TABLE IF NOT EXISTS "chat_assistant" (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
model VARCHAR(64) NOT NULL,
|
||||
system_prompt TEXT NOT NULL,
|
||||
temperature REAL NOT NULL DEFAULT 0,
|
||||
top_p REAL NOT NULL 0,
|
||||
"default" INTEGER NOT NULL DEFAULT 0,
|
||||
foreign key (user_id) references "user" (id) on delete cascade on update cascade
|
||||
);
|
||||
SQL;
|
||||
|
||||
if ($db->exec($query) === false) {
|
||||
$error = $db->errorInfo();
|
||||
throw new RuntimeException("Query failed with error : {$error[2]}");
|
||||
}
|
||||
|
||||
echo "Assistant table created.\n";
|
||||
Reference in New Issue
Block a user