discourse-ai/assets/javascripts/discourse/components/ai-llm-editor.gjs

42 lines
1.1 KiB
Plaintext
Raw Normal View History

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();
}
}
2024-05-21 12:35:50 -04:00
@action
configurePreset() {
let [id, model] = this.args.llmTemplate.split(/-(.*)/);
if (id === "none") {
return;
2024-05-21 12:35:50 -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
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>
}