Files

38 lines
849 B
JavaScript
Raw Permalink Normal View History

2024-05-21 13:35:50 -03:00
import { ajax } from "discourse/lib/ajax";
2024-05-13 12:46:42 -03:00
import RestModel from "discourse/models/rest";
export default class AiLlm extends RestModel {
createProperties() {
return this.getProperties(
"id",
2024-05-13 12:46:42 -03:00
"display_name",
"name",
"provider",
"tokenizer",
"max_prompt_tokens",
"max_output_tokens",
"url",
"api_key",
"enabled_chat_bot",
"provider_params",
"vision_enabled",
"input_cost",
"cached_input_cost",
"output_cost"
2024-05-13 12:46:42 -03:00
);
}
updateProperties() {
const attrs = this.createProperties();
attrs.id = this.id;
2025-01-14 15:54:09 +11:00
attrs.llm_quotas = this.llm_quotas;
2024-05-13 12:46:42 -03:00
return attrs;
}
2024-05-21 13:35:50 -03:00
async testConfig(llmConfig) {
return await ajax("/admin/plugins/discourse-ai/ai-llms/test.json", {
data: { ai_llm: llmConfig ?? this.createProperties() },
2024-05-21 13:35:50 -03:00
});
}
2024-05-13 12:46:42 -03:00
}