Skip to content

Commit

Permalink
Merge pull request #378 from l3vels/fix/agent-flow
Browse files Browse the repository at this point in the history
Fix/agent flow
  • Loading branch information
Chkhikvadze authored Dec 12, 2023
2 parents 5d7d4ae + 618def9 commit aeef084
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 23 deletions.
8 changes: 5 additions & 3 deletions apps/ui/src/components/TextareaFormik/TextareaFormik.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type TextareaProps = {
value: string
fieldName: string
triggerResize?: number
minHeight?: number
}

const TextareaFormik = ({
Expand All @@ -19,6 +20,7 @@ const TextareaFormik = ({
value,
fieldName,
triggerResize,
minHeight,
...props
}: TextareaProps) => {
const textareaRef = useRef(null as any)
Expand All @@ -41,7 +43,7 @@ const TextareaFormik = ({
}, [value, triggerResize])

return (
<StyledTextareaWrapper>
<StyledTextareaWrapper minHeight={minHeight}>
<TypographyPrimary value={label} type={Typography.types.LABEL} size={Typography.sizes.md} />
<Textarea
ref={textareaRef}
Expand All @@ -59,7 +61,7 @@ const TextareaFormik = ({

export default TextareaFormik

const StyledTextareaWrapper = styled.div`
const StyledTextareaWrapper = styled.div<{ minHeight?: number }>`
font: var(--font-general-label);
line-height: 22px;
font-size: 10px;
Expand All @@ -78,7 +80,7 @@ const StyledTextareaWrapper = styled.div`
}
}
textarea {
min-height: 200px;
min-height: ${({ minHeight }) => (minHeight ? `${minHeight}px` : '200px')};
max-height: calc(100vh - 400px);
}
`
3 changes: 2 additions & 1 deletion apps/ui/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -357,5 +357,6 @@
"groups": "$t(group)s",
"integrations": "$t(integration)s",
"models": "$t(model)s",
"type": "Type"
"type": "Type",
"task": "Task"
}
18 changes: 12 additions & 6 deletions apps/ui/src/pages/Agents/AgentForm/AgentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { StyledFormRoot, StyledFormInputWrapper } from 'styles/formStyles.css'
import TextareaFormik from 'components/TextareaFormik'
import { useLocation, useNavigate } from 'react-router-dom'
import RadioButton from 'share-ui/components/RadioButton/RadioButton'
import AgentRunners from './components/AgentRunners'
import AgentRunners, { StyledRunnerFieldsWrapper } from './components/AgentRunners'

type AgentFormProps = {
formik: any
Expand Down Expand Up @@ -434,11 +434,17 @@ const AgentForm = ({ formik, isVoice = true }: AgentFormProps) => {
<TypographyPrimary
value={`Sentiment Analysis`}
type={Typography.types.LABEL}
size={Typography.sizes.md}
size={Typography.sizes.lg}
/>

<StyledCombinedFields>
<FormikTextField label='Task' name={`agent_sentiment_analyzer.task`} />
<StyledRunnerFieldsWrapper>
<TextareaFormik
setFieldValue={setFieldValue}
label={t('task')}
value={agent_sentiment_analyzer.task}
fieldName={'agent_sentiment_analyzer.task'}
minHeight={90}
/>

<AgentDropdown
label={t('Runner')}
Expand All @@ -447,7 +453,7 @@ const AgentForm = ({ formik, isVoice = true }: AgentFormProps) => {
setFieldValue={setFieldValue}
options={agentOptions}
/>
</StyledCombinedFields>
</StyledRunnerFieldsWrapper>

{/* <AgentDropdown
label={'Call Sentiment Analyzer'}
Expand Down Expand Up @@ -524,7 +530,7 @@ const StyledInputWrapper = styled.div`
gap: 20px;
width: 100%;
max-width: 800px;
max-width: 1000px;
/* margin: auto; */
height: 100%;
/* max-height: 800px; */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default AgentDropdown
const StyledWrapper = styled.div<{ isValidationError: boolean }>`
display: flex;
flex-direction: column;
gap: 5px;
gap: 10px;
width: 100%;
.css-xrcw8y-container {
border: 3px solid ${({ theme }) => theme.body.textareaBorder};
Expand Down
34 changes: 23 additions & 11 deletions apps/ui/src/pages/Agents/AgentForm/components/AgentRunners.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ButtonSecondary, ButtonTertiary } from 'components/Button/Button'
import { StyledDeleteIcon } from 'pages/TeamOfAgents/TeamOfAgentsCard/TeamOfAgentsCard'
import AgentDropdown from './AgentDropdown'
import { useAgentsService } from 'services/agent/useAgentsService'
import TextareaFormik from 'components/TextareaFormik'

type AgentRunnersProps = {
formikField: string
Expand All @@ -36,12 +37,18 @@ const AgentRunners = ({ formikField, placeholder }: AgentRunnersProps) => {
<TypographyPrimary
value={`${placeholder}s`}
type={Typography.types.LABEL}
size={Typography.sizes.md}
size={Typography.sizes.lg}
/>
{values[formikField]?.map((item: any, index: number) => (
<>
<StyledCustomFieldWrapper key={index}>
<FormikTextField label='Task' name={`${formikField}.${index}.task`} />
<StyledRunnerFieldsWrapper key={index}>
<TextareaFormik
setFieldValue={setFieldValue}
label={t('task')}
value={item.task}
fieldName={`${formikField}.${index}.task`}
minHeight={90}
/>

<AgentDropdown
label={t('Runner')}
Expand All @@ -50,11 +57,10 @@ const AgentRunners = ({ formikField, placeholder }: AgentRunnersProps) => {
setFieldValue={setFieldValue}
options={agentOptions}
/>

<StyledButtonTertiary onClick={() => remove(index)} size={Button.sizes?.SMALL}>
<StyledDeleteIcon size={32} />
</StyledButtonTertiary>
</StyledCustomFieldWrapper>
</StyledRunnerFieldsWrapper>
</>
))}

Expand All @@ -78,18 +84,24 @@ const StyledFieldsWrapper = styled.div`
display: flex;
flex-direction: column;
gap: 5px;
gap: 20px;
`
const StyledCustomFieldWrapper = styled.div`
display: flex;
align-items: center;

gap: 5px;
`
const StyledButtonWrapper = styled.div`
width: fit-content;
`
const StyledButtonTertiary = styled(ButtonTertiary)`
padding: 0 4px;
margin-bottom: 6px;
margin-top: 38px;
margin-left: -14px;
width: 40px;
`
export const StyledRunnerFieldsWrapper = styled.div`
display: grid;
grid-template-columns: 2fr 1fr 0.1fr;
gap: 15px;
width: 100%;
`
2 changes: 1 addition & 1 deletion apps/ui/src/share-ui/components/Textarea/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const StyledTextarea = styled.textarea`
color: ${({ theme }) => theme.textFiled.primary.color};
outline: 4px solid ${({ theme }) => theme.textFiled.primary.borderColor};
border-radius: 6px;
border-radius: 4px;
&::placeholder {
/* @include theme-prop(color, text-field-placeholder-color); */
Expand Down

0 comments on commit aeef084

Please sign in to comment.