Files
discourse-ai/assets/javascripts/discourse/admin/models/ai-embedding.js
T
Roman Rizzi f5cf1019fb FEATURE: configurable embeddings (#1049)
* Use AR model for embeddings features

* endpoints

* Embeddings CRUD UI

* Add presets. Hide a couple more settings

* system specs

* Seed embedding definition from old settings

* Generate search bit index on the fly. cleanup orphaned data

* support for seeded models

* Fix run test for new embedding

* fix selected model not set correctly
2025-01-21 12:23:19 -03:00

39 lines
841 B
JavaScript

import { ajax } from "discourse/lib/ajax";
import RestModel from "discourse/models/rest";
export default class AiEmbedding extends RestModel {
createProperties() {
return this.getProperties(
"id",
"display_name",
"dimensions",
"provider",
"tokenizer_class",
"dimensions",
"url",
"api_key",
"max_sequence_length",
"provider_params",
"pg_function"
);
}
updateProperties() {
const attrs = this.createProperties();
attrs.id = this.id;
return attrs;
}
async testConfig() {
return await ajax(`/admin/plugins/discourse-ai/ai-embeddings/test.json`, {
data: { ai_embedding: this.createProperties() },
});
}
workingCopy() {
const attrs = this.createProperties();
return this.store.createRecord("ai-embedding", attrs);
}
}