Adds a comprehensive quota management system for LLM models that allows: - Setting per-group (applied per user in the group) token and usage limits with configurable durations - Tracking and enforcing token/usage limits across user groups - Quota reset periods (hourly, daily, weekly, or custom) - Admin UI for managing quotas with real-time updates This system provides granular control over LLM API usage by allowing admins to define limits on both total tokens and number of requests per group. Supports multiple concurrent quotas per model and automatically handles quota resets. Co-authored-by: Keegan George <[email protected]>
34 lines
732 B
JavaScript
34 lines
732 B
JavaScript
import { ajax } from "discourse/lib/ajax";
|
|
import RestModel from "discourse/models/rest";
|
|
|
|
export default class AiLlm extends RestModel {
|
|
createProperties() {
|
|
return this.getProperties(
|
|
"id",
|
|
"display_name",
|
|
"name",
|
|
"provider",
|
|
"tokenizer",
|
|
"max_prompt_tokens",
|
|
"url",
|
|
"api_key",
|
|
"enabled_chat_bot",
|
|
"provider_params",
|
|
"vision_enabled"
|
|
);
|
|
}
|
|
|
|
updateProperties() {
|
|
const attrs = this.createProperties();
|
|
attrs.id = this.id;
|
|
attrs.llm_quotas = this.llm_quotas;
|
|
return attrs;
|
|
}
|
|
|
|
async testConfig() {
|
|
return await ajax(`/admin/plugins/discourse-ai/ai-llms/test.json`, {
|
|
data: { ai_llm: this.createProperties() },
|
|
});
|
|
}
|
|
}
|