mirror of
https://ghfast.top/https://github.com/discourse/discourse-ai.git
synced 2026-05-26 01:04:52 +08:00
We have a flag to signal we are shortening the embeddings of a model. Only used in Open AI's text-embedding-3-*, but we plan to use it for other services.
41 lines
917 B
JavaScript
41 lines
917 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",
|
|
"embed_prompt",
|
|
"search_prompt",
|
|
"matryoshka_dimensions"
|
|
);
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|