Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: instruction textarea using autoresize #4404

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all 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
2 changes: 1 addition & 1 deletion web/screens/Thread/ThreadRightPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
const componentDataRuntimeSetting = getConfigurationsData(
modelRuntimeParams,
selectedModel
).filter((x) => x.key !== 'prompt_template')

Check warning on line 86 in web/screens/Thread/ThreadRightPanel/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

86 line is not covered with tests

// engine setting
const modelEngineParams = extractModelLoadParams(
Expand All @@ -96,41 +96,41 @@
const componentDataEngineSetting = getConfigurationsData(
modelEngineParams,
selectedModel
).filter((x) => x.key !== 'prompt_template' && x.key !== 'embedding')

Check warning on line 99 in web/screens/Thread/ThreadRightPanel/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

99 line is not covered with tests

// the max value of max token has to follow context length
const maxTokens = componentDataRuntimeSetting.find(
(x) => x.key === 'max_tokens'

Check warning on line 103 in web/screens/Thread/ThreadRightPanel/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

103 line is not covered with tests
)
const contextLength = componentDataEngineSetting.find(
(x) => x.key === 'ctx_len'

Check warning on line 106 in web/screens/Thread/ThreadRightPanel/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

106 line is not covered with tests
)
if (maxTokens && contextLength) {
// replace maxToken to componentDataRuntimeSetting
const updatedComponentDataRuntimeSetting: SettingComponentProps[] =
componentDataRuntimeSetting.map((settingComponentProps) => {
if (settingComponentProps.key !== 'max_tokens')
return settingComponentProps
const contextLengthValue = Number(contextLength.controllerProps.value)
const maxTokenValue = Number(

Check warning on line 115 in web/screens/Thread/ThreadRightPanel/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

111-115 lines are not covered with tests
settingComponentProps.controllerProps.value
)
const controllerProps =
settingComponentProps.controllerProps as SliderComponentProps
const sliderProps: SliderComponentProps = {

Check warning on line 120 in web/screens/Thread/ThreadRightPanel/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

119-120 lines are not covered with tests
...controllerProps,
max: contextLengthValue,
value: Math.min(maxTokenValue, contextLengthValue),
}

const updatedSettingProps: SettingComponentProps = {

Check warning on line 126 in web/screens/Thread/ThreadRightPanel/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

126 line is not covered with tests
...settingComponentProps,
controllerProps: sliderProps,
}
return updatedSettingProps

Check warning on line 130 in web/screens/Thread/ThreadRightPanel/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

130 line is not covered with tests
})

return {

Check warning on line 133 in web/screens/Thread/ThreadRightPanel/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

133 line is not covered with tests
runtimeSettings: updatedComponentDataRuntimeSetting,
engineSettings: componentDataEngineSetting,
}
Expand All @@ -156,8 +156,8 @@

const onAssistantInstructionChanged = useCallback(
(e: React.ChangeEvent<HTMLTextAreaElement>) => {
if (activeThread && activeAssistant)
updateThreadMetadata({

Check warning on line 160 in web/screens/Thread/ThreadRightPanel/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

159-160 lines are not covered with tests
...activeThread,
assistants: [
{
Expand Down Expand Up @@ -257,7 +257,7 @@
id="assistant-instructions"
placeholder="Eg. You are a helpful assistant."
value={activeAssistant?.instructions ?? ''}
// autoResize
autoResize
onChange={onAssistantInstructionChanged}
/>
</div>
Expand Down
Loading