mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-02-14 15:34:42 +00:00
Previously, we stored request parameters like the OpenAI organization and Bedrock's access key and region as site settings. This change stores them in the `llm_models` table instead, letting us drop more settings while also becoming more flexible.
33 lines
669 B
JavaScript
33 lines
669 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"
|
|
);
|
|
}
|
|
|
|
updateProperties() {
|
|
const attrs = this.createProperties();
|
|
attrs.id = this.id;
|
|
|
|
return attrs;
|
|
}
|
|
|
|
async testConfig() {
|
|
return await ajax(`/admin/plugins/discourse-ai/ai-llms/test.json`, {
|
|
data: { ai_llm: this.createProperties() },
|
|
});
|
|
}
|
|
}
|