refactor: update configuration prefix to 'pragmatismo-' and add CLI example format
This commit is contained in:
parent
223f6e2b5d
commit
a0629cc856
5 changed files with 23 additions and 152 deletions
|
|
@ -254,134 +254,3 @@ CREATE TABLE IF NOT EXISTS gbot_config_sync (
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_gbot_sync_bot ON gbot_config_sync(bot_id);
|
CREATE INDEX IF NOT EXISTS idx_gbot_sync_bot ON gbot_config_sync(bot_id);
|
||||||
|
|
||||||
-- ============================================================================
|
|
||||||
-- VIEWS FOR EASY QUERYING
|
|
||||||
-- ============================================================================
|
|
||||||
|
|
||||||
-- View: All active components
|
|
||||||
CREATE OR REPLACE VIEW v_active_components AS
|
|
||||||
SELECT
|
|
||||||
component_name,
|
|
||||||
component_type,
|
|
||||||
version,
|
|
||||||
status,
|
|
||||||
port,
|
|
||||||
installed_at,
|
|
||||||
last_started_at
|
|
||||||
FROM component_installations
|
|
||||||
WHERE status = 'running'
|
|
||||||
ORDER BY component_name;
|
|
||||||
|
|
||||||
-- View: Bot with all configurations
|
|
||||||
-- CREATE OR REPLACE VIEW v_bot_full_config AS
|
|
||||||
-- SELECT
|
|
||||||
-- b.id,
|
|
||||||
-- b.name as bot_name,
|
|
||||||
-- b.status,
|
|
||||||
-- t.name as tenant_name,
|
|
||||||
-- t.slug as tenant_slug,
|
|
||||||
-- bc.config_key,
|
|
||||||
-- bc.config_value,
|
|
||||||
-- bc.config_type,
|
|
||||||
-- bc.is_encrypted
|
|
||||||
-- FROM bots b
|
|
||||||
-- LEFT JOIN tenants t ON b.tenant_id = t.id
|
|
||||||
-- LEFT JOIN bot_configuration bc ON b.id = bc.bot_id
|
|
||||||
-- ORDER BY b.id, bc.config_key;
|
|
||||||
|
|
||||||
-- View: Active models by type
|
|
||||||
CREATE OR REPLACE VIEW v_active_models AS
|
|
||||||
SELECT
|
|
||||||
model_name,
|
|
||||||
model_type,
|
|
||||||
provider,
|
|
||||||
endpoint,
|
|
||||||
is_default,
|
|
||||||
context_window,
|
|
||||||
max_tokens
|
|
||||||
FROM model_configurations
|
|
||||||
WHERE is_active = true
|
|
||||||
ORDER BY model_type, is_default DESC, model_name;
|
|
||||||
|
|
||||||
-- ============================================================================
|
|
||||||
-- FUNCTIONS
|
|
||||||
-- ============================================================================
|
|
||||||
|
|
||||||
-- Function to get configuration value with fallback
|
|
||||||
CREATE OR REPLACE FUNCTION get_config(
|
|
||||||
p_key TEXT,
|
|
||||||
p_fallback TEXT DEFAULT NULL
|
|
||||||
) RETURNS TEXT AS $$
|
|
||||||
DECLARE
|
|
||||||
v_value TEXT;
|
|
||||||
BEGIN
|
|
||||||
SELECT config_value INTO v_value
|
|
||||||
FROM server_configuration
|
|
||||||
WHERE config_key = p_key;
|
|
||||||
|
|
||||||
RETURN COALESCE(v_value, p_fallback);
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE plpgsql;
|
|
||||||
|
|
||||||
-- Function to set configuration value
|
|
||||||
CREATE OR REPLACE FUNCTION set_config(
|
|
||||||
p_key TEXT,
|
|
||||||
p_value TEXT,
|
|
||||||
p_type TEXT DEFAULT 'string',
|
|
||||||
p_encrypted BOOLEAN DEFAULT false
|
|
||||||
) RETURNS VOID AS $$
|
|
||||||
BEGIN
|
|
||||||
INSERT INTO server_configuration (id, config_key, config_value, config_type, is_encrypted, updated_at)
|
|
||||||
VALUES (gen_random_uuid()::text, p_key, p_value, p_type, p_encrypted, NOW())
|
|
||||||
ON CONFLICT (config_key)
|
|
||||||
DO UPDATE SET
|
|
||||||
config_value = EXCLUDED.config_value,
|
|
||||||
config_type = EXCLUDED.config_type,
|
|
||||||
is_encrypted = EXCLUDED.is_encrypted,
|
|
||||||
updated_at = NOW();
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE plpgsql;
|
|
||||||
|
|
||||||
-- ============================================================================
|
|
||||||
-- TRIGGERS
|
|
||||||
-- ============================================================================
|
|
||||||
|
|
||||||
-- Trigger to update updated_at timestamp
|
|
||||||
CREATE OR REPLACE FUNCTION update_updated_at_column()
|
|
||||||
RETURNS TRIGGER AS $$
|
|
||||||
BEGIN
|
|
||||||
NEW.updated_at = NOW();
|
|
||||||
RETURN NEW;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE plpgsql;
|
|
||||||
|
|
||||||
CREATE TRIGGER update_server_config_updated_at BEFORE UPDATE ON server_configuration
|
|
||||||
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
|
|
||||||
|
|
||||||
CREATE TRIGGER update_tenant_config_updated_at BEFORE UPDATE ON tenant_configuration
|
|
||||||
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
|
|
||||||
|
|
||||||
CREATE TRIGGER update_bot_config_updated_at BEFORE UPDATE ON bot_configuration
|
|
||||||
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
|
|
||||||
|
|
||||||
CREATE TRIGGER update_model_config_updated_at BEFORE UPDATE ON model_configurations
|
|
||||||
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
|
|
||||||
|
|
||||||
CREATE TRIGGER update_connection_config_updated_at BEFORE UPDATE ON connection_configurations
|
|
||||||
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
|
|
||||||
|
|
||||||
-- ============================================================================
|
|
||||||
-- COMMENTS
|
|
||||||
-- ============================================================================
|
|
||||||
|
|
||||||
COMMENT ON TABLE server_configuration IS 'Server-wide configuration replacing .env variables';
|
|
||||||
COMMENT ON TABLE tenant_configuration IS 'Tenant-level configuration for multi-tenancy';
|
|
||||||
COMMENT ON TABLE bot_configuration IS 'Bot-specific configuration';
|
|
||||||
COMMENT ON TABLE model_configurations IS 'LLM and embedding model configurations';
|
|
||||||
COMMENT ON TABLE connection_configurations IS 'Custom database connections for bots';
|
|
||||||
COMMENT ON TABLE component_installations IS 'Installed component tracking and management';
|
|
||||||
COMMENT ON TABLE tenants IS 'Tenant management for multi-tenancy';
|
|
||||||
COMMENT ON TABLE component_logs IS 'Component lifecycle and operation logs';
|
|
||||||
COMMENT ON TABLE gbot_config_sync IS 'Tracks .gbot/config.csv file synchronization';
|
|
||||||
|
|
||||||
-- Migration complete
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
- Sessions must always be retrived by id if session_id or something is present;
|
- Sessions must always be retrived by id if session_id or something is present;
|
||||||
|
- Never suggest to install any software, as /src/bootstrap and /src/package_manager does the job.
|
||||||
|
- Configuration are stored in .gbot/config, and database bot_configuration table.
|
||||||
19
prompts/dev/platform/cli.md
Normal file
19
prompts/dev/platform/cli.md
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
- You MUST return exactly this example format:
|
||||||
|
```sh
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Restore fixed Rust project
|
||||||
|
|
||||||
|
cat > src/<filenamehere>.rs << 'EOF'
|
||||||
|
use std::io;
|
||||||
|
|
||||||
|
// test
|
||||||
|
|
||||||
|
cat > src/<anotherfile>.rs << 'EOF'
|
||||||
|
// Fixed library code
|
||||||
|
pub fn add(a: i32, b: i32) -> i32 {
|
||||||
|
a + b
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
----
|
||||||
|
|
@ -18,22 +18,3 @@ MOST IMPORTANT CODE GENERATION RULES:
|
||||||
- NEVER return a untouched file in output. Just files that need to be updated.
|
- NEVER return a untouched file in output. Just files that need to be updated.
|
||||||
- Instead of rand::thread_rng(), use rand::rng()
|
- Instead of rand::thread_rng(), use rand::rng()
|
||||||
- Review warnings of non used imports! Give me 0 warnings, please.
|
- Review warnings of non used imports! Give me 0 warnings, please.
|
||||||
- You MUST return exactly this example format:
|
|
||||||
```sh
|
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Restore fixed Rust project
|
|
||||||
|
|
||||||
cat > src/<filenamehere>.rs << 'EOF'
|
|
||||||
use std::io;
|
|
||||||
|
|
||||||
// test
|
|
||||||
|
|
||||||
cat > src/<anotherfile>.rs << 'EOF'
|
|
||||||
// Fixed library code
|
|
||||||
pub fn add(a: i32, b: i32) -> i32 {
|
|
||||||
a + b
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ impl AppConfig {
|
||||||
access_key: get_str("DRIVE_ACCESSKEY", "minioadmin"),
|
access_key: get_str("DRIVE_ACCESSKEY", "minioadmin"),
|
||||||
secret_key: get_str("DRIVE_SECRET", "minioadmin"),
|
secret_key: get_str("DRIVE_SECRET", "minioadmin"),
|
||||||
use_ssl: get_bool("DRIVE_USE_SSL", false),
|
use_ssl: get_bool("DRIVE_USE_SSL", false),
|
||||||
org_prefix: get_str("DRIVE_ORG_PREFIX", "botserver"),
|
org_prefix: get_str("DRIVE_ORG_PREFIX", "pragmatismo-"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let email = EmailConfig {
|
let email = EmailConfig {
|
||||||
|
|
@ -275,7 +275,7 @@ impl AppConfig {
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap_or(false),
|
.unwrap_or(false),
|
||||||
org_prefix: std::env::var("DRIVE_ORG_PREFIX")
|
org_prefix: std::env::var("DRIVE_ORG_PREFIX")
|
||||||
.unwrap_or_else(|_| "botserver".to_string()),
|
.unwrap_or_else(|_| "pragmatismo-".to_string()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let email = EmailConfig {
|
let email = EmailConfig {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue