Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Default all changes to backporting to 2.x branch
backport 2.x:
- '*'
- '*/*'
- '*/**/*'
- '*/**/**/*'
- '*/**/**/**/*'
- '*/**/**/**/**/*'
- '*/**/**/**/**/**/*'
- '*/**/**/**/**/**/**/*'
- '*/**/**/**/**/**/**/**/*'
- '*/**/**/**/**/**/**/**/**/*'
- '.github/**/*'
# Default all changes to backporting to 3.x branch
# Currently, main is on 3.x instead of 4.x, so we don't follow this backport model until that happens
# backport 2.x:
# - '*'
# - '*/*'
# - '*/**/*'
# - '*/**/**/*'
# - '*/**/**/**/*'
# - '*/**/**/**/**/*'
# - '*/**/**/**/**/**/*'
# - '*/**/**/**/**/**/**/*'
# - '*/**/**/**/**/**/**/**/*'
# - '*/**/**/**/**/**/**/**/**/*'
# - '.github/**/*'

# Adding "github actions" label to files in .github or its subdirectories
github actions:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
### Features
### Enhancements
- Clean up / hide complex fields on agent configuration ([#796](https://github.com/opensearch-project/dashboards-flow-framework/pull/796))
- Add agent summary ([#801](https://github.com/opensearch-project/dashboards-flow-framework/pull/801))
### Bug Fixes
### Infrastructure
### Documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,129 +331,133 @@ export function AgentConfiguration(props: AgentConfigurationProps) {
</EuiFlexItem>
)}
{!isEmpty(selectedAgentId) && (
<>
<EuiFlexItem>
{configModeSelected === CONFIG_MODE.SIMPLE ? (
<EuiFlexGroup direction="row" gutterSize="s">
<EuiFlexItem>
<EuiFormRow label="Name" fullWidth>
<EuiFieldText
value={agentName}
onChange={(e) =>
props.setAgentForm({
...props.agentForm,
name: e.target.value,
})
}
placeholder="Enter agent name"
aria-label="Enter agent name"
fullWidth
compressed
maxLength={50}
/>
</EuiFormRow>
</EuiFlexItem>
<EuiFlexItem>
<EuiFormRow label="Type" isInvalid={false} fullWidth>
<EuiSelect
options={dynamicAgentTypeOptions}
value={agentType}
onChange={(e) => {
const agentFormCopy = cloneDeep(props.agentForm);
const proposedAgentType = e.target
.value as AGENT_TYPE;

// remove invalid fields if switching to flow agent
if (proposedAgentType === AGENT_TYPE.FLOW) {
delete agentFormCopy.llm;
delete agentFormCopy.parameters?._llm_interface;
delete agentFormCopy.memory;
<EuiFlexItem>
{configModeSelected === CONFIG_MODE.SIMPLE ? (
<EuiFlexGroup direction="column" gutterSize="s">
<EuiFlexItem grow={false}>
<EuiFlexGroup direction="row" gutterSize="s">
<EuiFlexItem>
<EuiFormRow label="Name" fullWidth>
<EuiFieldText
value={agentName}
onChange={(e) =>
props.setAgentForm({
...props.agentForm,
name: e.target.value,
})
}
placeholder="Enter agent name"
aria-label="Enter agent name"
fullWidth
compressed
maxLength={50}
/>
</EuiFormRow>
</EuiFlexItem>
<EuiFlexItem>
<EuiFormRow label="Type" isInvalid={false} fullWidth>
<EuiSelect
options={dynamicAgentTypeOptions}
value={agentType}
onChange={(e) => {
const agentFormCopy = cloneDeep(
props.agentForm
);
const proposedAgentType = e.target
.value as AGENT_TYPE;

props.setAgentForm({
...agentFormCopy,
type: proposedAgentType,
});
}}
aria-label="Agent type"
placeholder="Agent type"
fullWidth
compressed
hasNoInitialSelection={true}
/>
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
) : (
<SimplifiedJsonField
value={customStringify(agentFormNoId)}
onBlur={(e) => {
try {
const agentFormUpdated = JSON.parse(e);
const agentFormSanitized = sanitizeJSON(
agentFormUpdated
);
props.setAgentForm({
id: props.agentForm.id,
...agentFormSanitized,
});
setJsonError(undefined);
} catch (error) {
setJsonError(
'Invalid JSON: ' + (error as Error)?.message || ''
);
}
}}
editorHeight="800px"
isInvalid={jsonError !== undefined}
helpText="Edit the full agent configuration directly"
/>
)}
<EuiSpacer size="m" />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFormRow label="Description" fullWidth>
<EuiTextArea
value={agentDescription}
onChange={(e) =>
// remove invalid fields if switching to flow agent
if (proposedAgentType === AGENT_TYPE.FLOW) {
delete agentFormCopy.llm;
delete agentFormCopy.parameters
?._llm_interface;
delete agentFormCopy.memory;
}

props.setAgentForm({
...agentFormCopy,
type: proposedAgentType,
});
}}
aria-label="Agent type"
placeholder="Agent type"
fullWidth
compressed
hasNoInitialSelection={true}
/>
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFormRow label="Description" fullWidth>
<EuiTextArea
value={agentDescription}
onChange={(e) =>
props.setAgentForm({
...props.agentForm,
description: e.target.value,
})
}
placeholder="Enter description"
aria-label="Enter description"
rows={2}
fullWidth
compressed
/>
</EuiFormRow>
</EuiFlexItem>
{/**
* Show the agent model dropdown if applicable
*/}
<EuiFlexItem grow={false}>
<AgentLLMFields
agentType={agentType as AGENT_TYPE}
agentForm={props.agentForm}
setAgentForm={props.setAgentForm}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFormRow label="Tools" fullWidth>
<AgentTools
agentForm={props.agentForm}
setAgentForm={props.setAgentForm}
/>
</EuiFormRow>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<AgentAdvancedSettings
agentForm={props.agentForm}
setAgentForm={props.setAgentForm}
/>
</EuiFlexItem>
</EuiFlexGroup>
) : (
<SimplifiedJsonField
value={customStringify(agentFormNoId)}
onBlur={(e) => {
try {
const agentFormUpdated = JSON.parse(e);
const agentFormSanitized = sanitizeJSON(
agentFormUpdated
);
props.setAgentForm({
...props.agentForm,
description: e.target.value,
})
id: props.agentForm.id,
...agentFormSanitized,
});
setJsonError(undefined);
} catch (error) {
setJsonError(
'Invalid JSON: ' + (error as Error)?.message || ''
);
}
placeholder="Enter description"
aria-label="Enter description"
rows={2}
fullWidth
compressed
/>
</EuiFormRow>
</EuiFlexItem>
{/**
* Show the agent model dropdown if applicable
*/}
<EuiFlexItem>
<AgentLLMFields
agentType={agentType as AGENT_TYPE}
agentForm={props.agentForm}
setAgentForm={props.setAgentForm}
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiFormRow label="Tools" fullWidth>
<AgentTools
agentForm={props.agentForm}
setAgentForm={props.setAgentForm}
/>
</EuiFormRow>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<AgentAdvancedSettings
agentForm={props.agentForm}
setAgentForm={props.setAgentForm}
}}
editorHeight="800px"
isInvalid={jsonError !== undefined}
helpText="Edit the full agent configuration directly"
/>
</EuiFlexItem>
</>
)}
</EuiFlexItem>
)}
</EuiFlexGroup>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,10 @@ export function AgentTools({ agentForm, setAgentForm }: AgentToolsProps) {
});
}

const renderToolForm = (toolType: TOOL_TYPE, index: number): any => {
const toolForm = getIn(agentForm, `tools.${index}`) as Tool;
const renderToolForm = (toolType: TOOL_TYPE): any => {
const toolsForm = getIn(agentForm, 'tools', []) as Tool[];
const toolIndex = toolsForm.findIndex((tool) => tool.type === toolType);
const toolForm = getIn(agentForm, `tools.${toolIndex}`) as Tool;
switch (toolType) {
case TOOL_TYPE.QUERY_PLANNING:
const generationType =
Expand All @@ -215,7 +217,7 @@ export function AgentTools({ agentForm, setAgentForm }: AgentToolsProps) {
updateParameterValue(
'search_templates',
JSON.stringify(updatedTemplates),
index
toolIndex
);
setOpenTemplateAccordionIndex(updatedTemplates.length - 1);
};
Expand All @@ -232,7 +234,7 @@ export function AgentTools({ agentForm, setAgentForm }: AgentToolsProps) {
updateParameterValue(
'search_templates',
JSON.stringify(updatedTemplates),
index
toolIndex
);
};
const removeSearchTemplate = (templateIndex: number) => {
Expand All @@ -242,7 +244,7 @@ export function AgentTools({ agentForm, setAgentForm }: AgentToolsProps) {
updateParameterValue(
'search_templates',
JSON.stringify(updatedTemplates),
index
toolIndex
);
};

Expand Down Expand Up @@ -288,7 +290,11 @@ export function AgentTools({ agentForm, setAgentForm }: AgentToolsProps) {
}
value={selectedModelId}
onChange={(e) => {
updateParameterValue('model_id', e.target.value, index);
updateParameterValue(
'model_id',
e.target.value,
toolIndex
);
}}
aria-label="Select model"
placeholder="Select a model"
Expand Down Expand Up @@ -316,7 +322,7 @@ export function AgentTools({ agentForm, setAgentForm }: AgentToolsProps) {
options={generationTypeRadios}
idSelected={generationType}
onChange={(id) => {
updateParameterValue('generation_type', id, index);
updateParameterValue('generation_type', id, toolIndex);
}}
compressed
data-testid="generationTypeRadioGroup"
Expand Down Expand Up @@ -464,7 +470,7 @@ export function AgentTools({ agentForm, setAgentForm }: AgentToolsProps) {
<EuiFieldText
value={engine}
onChange={(e) => {
updateParameterValue('engine', e.target.value, index);
updateParameterValue('engine', e.target.value, toolIndex);
}}
aria-label="Specify the engine"
placeholder="Search engine - for example, duckduckgo"
Expand Down Expand Up @@ -573,7 +579,7 @@ export function AgentTools({ agentForm, setAgentForm }: AgentToolsProps) {
}
}}
>
{renderToolForm(toolType, index)}
{renderToolForm(toolType)}
</EuiAccordion>
<EuiSpacer size="s" />
</EuiPanel>
Expand Down
Loading
Loading