mirror of
https://ghfast.top/https://github.com/discourse/discourse-ai.git
synced 2026-07-15 11:27:11 +08:00
This update adds metrics for estimated spending in AI usage. To make use of it, admins must add cost details to the LLM config page (input, output, and cached input costs per 1M tokens). After doing so, the metrics will appear in the AI usage dashboard as the AI plugin is used.
28 lines
813 B
JavaScript
28 lines
813 B
JavaScript
import DiscourseRoute from "discourse/routes/discourse";
|
|
|
|
export default class AdminPluginsShowDiscourseAiLlmsEdit extends DiscourseRoute {
|
|
async model(params) {
|
|
const id = parseInt(params.id, 10);
|
|
|
|
if (id < 0) {
|
|
// You shouldn't be able to access the edit page
|
|
// if the model is seeded
|
|
return this.router.transitionTo(
|
|
"adminPlugins.show.discourse-ai-llms.index"
|
|
);
|
|
}
|
|
|
|
const allLlms = this.modelFor("adminPlugins.show.discourse-ai-llms");
|
|
const record = allLlms.findBy("id", id);
|
|
record.provider_params = record.provider_params || {};
|
|
return record;
|
|
}
|
|
|
|
setupController(controller, model) {
|
|
super.setupController(controller, model);
|
|
controller.set(
|
|
"allLlms",
|
|
this.modelFor("adminPlugins.show.discourse-ai-llms")
|
|
);
|
|
}
|
|
}
|