mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-06-25 00:52:14 +00:00
FIX: when tool options are added they should be available (#1406)
Fixes a regression where tool option editor was not showing all tools
This commit is contained in:
parent
c885e5697f
commit
b3d78a6a10
@ -33,6 +33,19 @@ export default class AiPersonaToolOptions extends Component {
|
|||||||
return toolOptions ? Object.keys(toolOptions) : [];
|
return toolOptions ? Object.keys(toolOptions) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
toolOptionKeys(toolId) {
|
||||||
|
// this is important, some tools may not have all options defined (for example if a tool option is added)
|
||||||
|
const metadata = this.toolsMetadata[toolId];
|
||||||
|
if (!metadata) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// a bit more verbose for clarity of our selection
|
||||||
|
const availableOptions = Object.keys(metadata).filter((k) => k !== "name");
|
||||||
|
return availableOptions;
|
||||||
|
}
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
{{#if this.showToolOptions}}
|
{{#if this.showToolOptions}}
|
||||||
<@form.Container
|
<@form.Container
|
||||||
@ -51,8 +64,8 @@ export default class AiPersonaToolOptions extends Component {
|
|||||||
<div class="ai-persona-editor__tool-options-name">
|
<div class="ai-persona-editor__tool-options-name">
|
||||||
{{toolMeta.name}}
|
{{toolMeta.name}}
|
||||||
</div>
|
</div>
|
||||||
<toolObj.Object @name={{toolId}} as |optionsObj optionData|>
|
<toolObj.Object @name={{toolId}} as |optionsObj|>
|
||||||
{{#each (this.formObjectKeys optionData) as |optionName|}}
|
{{#each (this.toolOptionKeys toolId) as |optionName|}}
|
||||||
{{#let (get toolMeta optionName) as |optionMeta|}}
|
{{#let (get toolMeta optionName) as |optionMeta|}}
|
||||||
<optionsObj.Field
|
<optionsObj.Field
|
||||||
@name={{optionName}}
|
@name={{optionName}}
|
||||||
|
@ -51,6 +51,15 @@ RSpec.describe "Admin AI persona configuration", type: :system, js: true do
|
|||||||
|
|
||||||
expected_tools = [["Read", { "read_private" => nil }, true], ["ListCategories", {}, true]]
|
expected_tools = [["Read", { "read_private" => nil }, true], ["ListCategories", {}, true]]
|
||||||
expect(persona.tools).to contain_exactly(*expected_tools)
|
expect(persona.tools).to contain_exactly(*expected_tools)
|
||||||
|
|
||||||
|
# lets also test upgrades here... particularly one options was deleted and another added
|
||||||
|
# this ensurse that we can still edit the tool correctly and all options are present
|
||||||
|
persona.update!(tools: [["Read", { "got_deleted" => true }]])
|
||||||
|
|
||||||
|
visit "/admin/plugins/discourse-ai/ai-personas/#{persona_id}/edit"
|
||||||
|
|
||||||
|
expect(page).to have_selector("input[name='toolOptions.Read.read_private']")
|
||||||
|
expect(page).not_to have_selector("input[name='toolOptions.Read.got_deleted']")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "will not allow deletion or editing of system personas" do
|
it "will not allow deletion or editing of system personas" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user