Files

42 lines
920 B
JavaScript
Raw Permalink Normal View History

2024-06-28 00:59:51 +02:00
import { TrackedArray, TrackedObject } from "@ember-compat/tracked-built-ins";
2024-06-27 17:27:40 +10:00
import RestModel from "discourse/models/rest";
const CREATE_ATTRIBUTES = [
"id",
"name",
"description",
"parameters",
"script",
"summary",
"enabled",
];
export default class AiTool extends RestModel {
createProperties() {
return this.getProperties(CREATE_ATTRIBUTES);
}
updateProperties() {
return this.getProperties(CREATE_ATTRIBUTES);
}
workingCopy() {
2024-06-28 00:59:51 +02:00
const attrs = this.getProperties(CREATE_ATTRIBUTES);
attrs.parameters = new TrackedArray(
attrs.parameters?.map((p) => {
const parameter = new TrackedObject(p);
if (parameter.enum_values) {
parameter.enumValues = new TrackedArray(parameter.enum_values);
delete parameter.enum_values;
}
return parameter;
})
);
return this.store.createRecord("ai-tool", attrs);
2024-06-27 17:27:40 +10:00
}
}