Skip to content

Commit

Permalink
add quickconfig fields
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed Sep 11, 2024
1 parent fc03ff2 commit 9e13b84
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 116 deletions.
7 changes: 6 additions & 1 deletion common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,17 @@ export const DELIMITER_OPTIONAL_FIELDS = ['delimiter'];
export const SHARED_OPTIONAL_FIELDS = ['max_chunk_limit', 'description', 'tag'];

/**
* QUERY PRESETS
* DEFAULT FIELD VALUES
*/
export const DEFAULT_TEXT_FIELD = 'my_text';
export const DEFAULT_VECTOR_FIELD = 'my_embedding';
export const DEFAULT_IMAGE_FIELD = 'my_image';
export const DEFAULT_LABEL_FIELD = 'label';
export const DEFAULT_LLM_RESPONSE_FIELD = 'llm_response';

/**
* QUERY PRESETS
*/
export const VECTOR_FIELD_PATTERN = `{{vector_field}}`;
export const TEXT_FIELD_PATTERN = `{{text_field}}`;
export const IMAGE_FIELD_PATTERN = `{{image_field}}`;
Expand Down
1 change: 1 addition & 0 deletions common/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ export type QuickConfigureFields = {
imageField?: string;
labelField?: string;
embeddingLength?: number;
llmResponseField?: string;
};

/**
Expand Down
40 changes: 34 additions & 6 deletions public/pages/workflows/new_workflow/quick_configure_inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
COHERE_DIMENSIONS,
DEFAULT_IMAGE_FIELD,
DEFAULT_LABEL_FIELD,
DEFAULT_LLM_RESPONSE_FIELD,
DEFAULT_TEXT_FIELD,
DEFAULT_VECTOR_FIELD,
MODEL_STATE,
Expand Down Expand Up @@ -84,6 +85,13 @@ export function QuickConfigureInputs(props: QuickConfigureInputsProps) {
};
break;
}
case WORKFLOW_TYPE.RAG: {
defaultFieldValues = {
textField: DEFAULT_TEXT_FIELD,
llmResponseField: DEFAULT_LLM_RESPONSE_FIELD,
};
break;
}
case WORKFLOW_TYPE.CUSTOM:
default:
break;
Expand Down Expand Up @@ -143,10 +151,7 @@ export function QuickConfigureInputs(props: QuickConfigureInputsProps) {

return (
<>
{(props.workflowType === WORKFLOW_TYPE.SEMANTIC_SEARCH ||
props.workflowType === WORKFLOW_TYPE.MULTIMODAL_SEARCH ||
props.workflowType === WORKFLOW_TYPE.HYBRID_SEARCH ||
props.workflowType === WORKFLOW_TYPE.SENTIMENT_ANALYSIS) && (
{props.workflowType !== WORKFLOW_TYPE.CUSTOM ? (
<>
<EuiSpacer size="m" />
<EuiAccordion
Expand All @@ -159,12 +164,16 @@ export function QuickConfigureInputs(props: QuickConfigureInputsProps) {
label={
props.workflowType === WORKFLOW_TYPE.SENTIMENT_ANALYSIS
? 'Model'
: props.workflowType === WORKFLOW_TYPE.RAG
? 'Large language model'
: 'Embedding model'
}
isInvalid={false}
helpText={
props.workflowType === WORKFLOW_TYPE.SENTIMENT_ANALYSIS
? 'The sentiment analysis model'
: props.workflowType === WORKFLOW_TYPE.RAG
? 'The large language model to generate user-friendly responses'
: 'The model to generate embeddings'
}
>
Expand Down Expand Up @@ -209,6 +218,8 @@ export function QuickConfigureInputs(props: QuickConfigureInputsProps) {
helpText={`The name of the text document field to be ${
props.workflowType === WORKFLOW_TYPE.SENTIMENT_ANALYSIS
? 'analyzed'
: props.workflowType === WORKFLOW_TYPE.RAG
? 'used as context to the large language model (LLM)'
: 'embedded'
}`}
>
Expand All @@ -222,7 +233,7 @@ export function QuickConfigureInputs(props: QuickConfigureInputsProps) {
}}
/>
</EuiCompressedFormRow>
<EuiSpacer size="s" />
<EuiSpacer size="s" />{' '}
{props.workflowType === WORKFLOW_TYPE.MULTIMODAL_SEARCH && (
<>
<EuiCompressedFormRow
Expand Down Expand Up @@ -297,9 +308,26 @@ export function QuickConfigureInputs(props: QuickConfigureInputsProps) {
/>
</EuiCompressedFormRow>
)}
{props.workflowType === WORKFLOW_TYPE.RAG && (
<EuiCompressedFormRow
label={'LLM response field'}
isInvalid={false}
helpText="The name of the field containing the large language model (LLM) response"
>
<EuiCompressedFieldText
value={fieldValues?.llmResponseField || ''}
onChange={(e) => {
setFieldValues({
...fieldValues,
llmResponseField: e.target.value,
});
}}
/>
</EuiCompressedFormRow>
)}
</EuiAccordion>
</>
)}
) : undefined}
</>
);
}
Loading

0 comments on commit 9e13b84

Please sign in to comment.