discourse-ai/assets/javascripts/discourse/components/ai-llm-editor.gjs
Kris 18ecc843e5
UX: move templates to main LLM config tab, restyle (#813)
Restructures LLM config page so it is far clearer. 

Also corrects bugs around adding LLMs and having LLMs not editable post addition 
---------

Co-authored-by: Sam Saffron <sam.saffron@gmail.com>
2024-09-30 17:15:11 +10:00

41 lines
1.1 KiB
Text

import Component from "@glimmer/component";
import { action } from "@ember/object";
import BackButton from "discourse/components/back-button";
import AiLlmEditorForm from "./ai-llm-editor-form";
export default class AiLlmEditor extends Component {
constructor() {
super(...arguments);
if (this.args.llmTemplate) {
this.configurePreset();
}
}
@action
configurePreset() {
let [id, model] = this.args.llmTemplate.split(/-(.*)/);
if (id === "none") {
return;
}
const info = this.args.llms.resultSetMeta.presets.findBy("id", id);
const modelInfo = info.models.findBy("name", model);
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,
});
}
<template>
<BackButton
@route="adminPlugins.show.discourse-ai-llms"
@label="discourse_ai.llms.back"
/>
<AiLlmEditorForm @model={{@model}} @llms={{@llms}} />
</template>
}