generated from discourse/discourse-plugin-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c4d9eb
commit 54cdb54
Showing
20 changed files
with
572 additions
and
75 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
admin/assets/javascripts/discourse/routes/admin-plugins-show-discourse-ai-embeddings-edit.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import DiscourseRoute from "discourse/routes/discourse"; | ||
|
||
export default class AdminPluginsShowDiscourseAiEmbeddingsEdit extends DiscourseRoute { | ||
async model(params) { | ||
const allEmbeddings = this.modelFor("adminPlugins.show.discourse-ai-embeddings"); | ||
const id = parseInt(params.id, 10); | ||
const record = allEmbeddings.findBy("id", id); | ||
record.provider_params = record.provider_params || {}; | ||
return record; | ||
} | ||
|
||
setupController(controller, model) { | ||
super.setupController(controller, model); | ||
controller.set( | ||
"allEmbeddings", | ||
this.modelFor("adminPlugins.show.discourse-ai-embeddings") | ||
); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
admin/assets/javascripts/discourse/routes/admin-plugins-show-discourse-ai-embeddings-new.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import DiscourseRoute from "discourse/routes/discourse"; | ||
|
||
export default class AdminPluginsShowDiscourseAiEmbeddingsNew extends DiscourseRoute { | ||
async model() { | ||
const record = this.store.createRecord("ai-embedding"); | ||
record.provider_params = {}; | ||
return record; | ||
} | ||
|
||
setupController(controller, model) { | ||
super.setupController(controller, model); | ||
controller.set( | ||
"allEmbeddings", | ||
this.modelFor("adminPlugins.show.discourse-ai-embeddings") | ||
); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
admin/assets/javascripts/discourse/routes/admin-plugins-show-discourse-ai-embeddings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import DiscourseRoute from "discourse/routes/discourse"; | ||
|
||
export default class DiscourseAiAiEmbeddingsRoute extends DiscourseRoute { | ||
model() { | ||
return this.store.findAll("ai-embedding"); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...ssets/javascripts/discourse/templates/admin-plugins/show/discourse-ai-embeddings/edit.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<AiEmbeddingsListEditor | ||
@embeddings={{this.allEmbeddings}} | ||
@currentEmbedding={{this.model}} | ||
/> |
1 change: 1 addition & 0 deletions
1
...sets/javascripts/discourse/templates/admin-plugins/show/discourse-ai-embeddings/index.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<AiEmbeddingsListEditor @embeddings={{this.model}} /> |
4 changes: 4 additions & 0 deletions
4
...assets/javascripts/discourse/templates/admin-plugins/show/discourse-ai-embeddings/new.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<AiEmbeddingsListEditor | ||
@embeddings={{this.allEmbeddings}} | ||
@currentEmbedding={{this.model}} | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
assets/javascripts/discourse/admin/adapters/ai-embedding.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import RestAdapter from "discourse/adapters/rest"; | ||
|
||
export default class Adapter extends RestAdapter { | ||
jsonMode = true; | ||
|
||
basePath() { | ||
return "/admin/plugins/discourse-ai/"; | ||
} | ||
|
||
pathFor(store, type, findArgs) { | ||
// removes underscores which are implemented in base | ||
let path = | ||
this.basePath(store, type, findArgs) + | ||
store.pluralize(this.apiNameFor(type)); | ||
return this.appendQueryParams(path, findArgs); | ||
} | ||
|
||
apiNameFor() { | ||
return "ai-embedding"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
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() }, | ||
}); | ||
} | ||
} |
Oops, something went wrong.