2024-05-13 11:46:42 -04:00
|
|
|
import Component from "@glimmer/component";
|
|
|
|
import { action } from "@ember/object";
|
2024-05-16 13:28:57 -04:00
|
|
|
import BackButton from "discourse/components/back-button";
|
2024-06-21 03:32:15 -04:00
|
|
|
import AiLlmEditorForm from "./ai-llm-editor-form";
|
2024-05-13 11:46:42 -04:00
|
|
|
|
|
|
|
export default class AiLlmEditor extends Component {
|
2024-09-30 03:15:11 -04:00
|
|
|
constructor() {
|
|
|
|
super(...arguments);
|
|
|
|
if (this.args.llmTemplate) {
|
|
|
|
this.configurePreset();
|
|
|
|
}
|
2024-05-13 11:46:42 -04:00
|
|
|
}
|
|
|
|
|
2024-05-21 12:35:50 -04:00
|
|
|
@action
|
2024-06-21 03:32:15 -04:00
|
|
|
configurePreset() {
|
2024-09-30 03:15:11 -04:00
|
|
|
let [id, model] = this.args.llmTemplate.split(/-(.*)/);
|
2024-06-21 03:32:15 -04:00
|
|
|
if (id === "none") {
|
|
|
|
return;
|
2024-05-21 12:35:50 -04:00
|
|
|
}
|
|
|
|
|
2024-06-21 03:32:15 -04:00
|
|
|
const info = this.args.llms.resultSetMeta.presets.findBy("id", id);
|
|
|
|
const modelInfo = info.models.findBy("name", model);
|
2024-05-21 12:35:50 -04:00
|
|
|
|
2024-06-21 03:32:15 -04:00
|
|
|
this.args.model.setProperties({
|
|
|
|
max_prompt_tokens: modelInfo.tokens,
|
|
|
|
tokenizer: info.tokenizer,
|
|
|
|
url: modelInfo.endpoint || info.endpoint,
|
|
|
|
display_name: modelInfo.display_name,
|
|
|
|
name: modelInfo.name,
|
|
|
|
provider: info.provider,
|
2024-05-27 15:44:08 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-05-13 11:46:42 -04:00
|
|
|
<template>
|
2024-05-16 13:28:57 -04:00
|
|
|
<BackButton
|
|
|
|
@route="adminPlugins.show.discourse-ai-llms"
|
|
|
|
@label="discourse_ai.llms.back"
|
|
|
|
/>
|
2024-09-30 03:15:11 -04:00
|
|
|
<AiLlmEditorForm @model={{@model}} @llms={{@llms}} />
|
2024-05-13 11:46:42 -04:00
|
|
|
</template>
|
|
|
|
}
|