- @{page.props.userName} + @ +{page.props.userName}
diff --git a/src/utils/aiprdescription/configurationReducer.ts b/src/utils/aiprdescription/configurationReducer.ts new file mode 100644 index 00000000..6c612a15 --- /dev/null +++ b/src/utils/aiprdescription/configurationReducer.ts @@ -0,0 +1,38 @@ +import { DescriptionConfig, getDefaultDescriptionConfig } from "./descriptionconfig"; + +export const configurationReducer = (state: DescriptionConfig, action: { type: string, value: any }) => { + let newState: DescriptionConfig = { ...state }; + + switch (action.type) { + case "SET": + newState = action.value; + break; + case "SET_OPENAI_API_KEY": + newState.config.openai_api_key = action.value; + break; + case "SET_LENGTH": + newState.config.length = action.value; + break; + case "SET_TEMPERATURE": + newState.config.temperature = action.value; + break; + case "SET_MAX_INPUT_LENGTH": + newState.config.maxInputLength = action.value; + break; + case "SET_LANGUAGE": + newState.config.language = action.value; + break; + case "SET_SOURCE": + newState.config.source = action.value; + break; + case "SET_TONE": + newState.config.tone = action.value; + break; + case "CLEAR": + newState = getDefaultDescriptionConfig(); + break; + default: + return newState; + } + return newState; +}; diff --git a/src/utils/aiprdescription/cursorPositionInsert.ts b/src/utils/aiprdescription/cursorPositionInsert.ts new file mode 100644 index 00000000..e0114607 --- /dev/null +++ b/src/utils/aiprdescription/cursorPositionInsert.ts @@ -0,0 +1,19 @@ +// This function is used to insert text at the cursor position in the text area +export const insertAtCursorFromStream = async (textArea: HTMLTextAreaElement, stream: ReadableStream