AI stage 1: rebuild AI Providers and AI Models in the standard list pattern with ready-made provider kinds (OpenAI, Anthropic, Azure OpenAI, Gemini, Mistral, Groq, OpenRouter, Ollama, LM Studio, OpenAI-compatible), Test that lists a provider's models, Save anyway for a provider that doesn't answer, a first model offered when adding the first provider, the API key no longer shown, from-to audit lines, and delete confirms that say what goes and what stops; model window with suggested models, use case notes and Try it; new AI Usage page logging each request by feature, user, client, model, tokens, time and failure, with totals, views and filters, pruned with the audit log; passwords, keys, 2FA links and card numbers taken out before sending and put back in the answer, on by default per provider; new Use AI role permission; Reword shown only when set up and allowed, placed first in the toolbar, with its own instructions, undo in one step and a fixed endpoint on admin pages; ticket summary and template drafts purified; Settings overview warns while AI requests keep failing; database 3.3.8 adds provider kind and redact, ai_usage and module_ai

This commit is contained in:
johnnyq
2026-10-20 17:45:00 -04:00
parent 8d3fbcb2ab
commit 80cdc4de41
25 changed files with 2557 additions and 695 deletions

37
db.sql
View File

@@ -96,14 +96,47 @@ DROP TABLE IF EXISTS `ai_providers`;
CREATE TABLE `ai_providers` (
`ai_provider_id` int(11) NOT NULL AUTO_INCREMENT,
`ai_provider_name` varchar(200) NOT NULL,
`ai_provider_api_url` varchar(200) NOT NULL,
`ai_provider_api_key` varchar(200) DEFAULT NULL,
`ai_provider_kind` varchar(50) NOT NULL DEFAULT 'custom',
`ai_provider_api_url` varchar(500) NOT NULL,
`ai_provider_api_key` varchar(500) DEFAULT NULL,
`ai_provider_redact` tinyint(1) NOT NULL DEFAULT 1,
`ai_provider_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`ai_provider_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
PRIMARY KEY (`ai_provider_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `ai_usage`
--
DROP TABLE IF EXISTS `ai_usage`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `ai_usage` (
`ai_usage_id` int(11) NOT NULL AUTO_INCREMENT,
`ai_usage_feature` varchar(50) NOT NULL,
`ai_usage_use_case` varchar(50) DEFAULT NULL,
`ai_usage_provider_id` int(11) NOT NULL DEFAULT 0,
`ai_usage_provider_name` varchar(200) DEFAULT NULL,
`ai_usage_model_id` int(11) NOT NULL DEFAULT 0,
`ai_usage_model` varchar(200) DEFAULT NULL,
`ai_usage_user_id` int(11) NOT NULL DEFAULT 0,
`ai_usage_client_id` int(11) NOT NULL DEFAULT 0,
`ai_usage_tokens_in` int(11) NOT NULL DEFAULT 0,
`ai_usage_tokens_out` int(11) NOT NULL DEFAULT 0,
`ai_usage_ms` int(11) NOT NULL DEFAULT 0,
`ai_usage_redacted` int(11) NOT NULL DEFAULT 0,
`ai_usage_ok` tinyint(1) NOT NULL DEFAULT 1,
`ai_usage_error` varchar(255) DEFAULT NULL,
`ai_usage_created_at` datetime NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`ai_usage_id`),
KEY `ai_usage_created_at` (`ai_usage_created_at`),
KEY `ai_usage_provider_id` (`ai_usage_provider_id`),
KEY `ai_usage_model_id` (`ai_usage_model_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `api_key_usage`
--