add enable reasoning button
This commit is contained in:
parent
43405bceac
commit
084f6cc27e
4 changed files with 51 additions and 2 deletions
|
|
@ -1,4 +1,8 @@
|
|||
import { AtSymbolIcon, PhotoIcon } from "@heroicons/react/24/outline";
|
||||
import {
|
||||
AtSymbolIcon,
|
||||
LightBulbIcon,
|
||||
PhotoIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { InputModifiers } from "core";
|
||||
import { modelSupportsImages, modelSupportsTools } from "core/llm/autodetect";
|
||||
import { useContext, useRef } from "react";
|
||||
|
|
@ -10,8 +14,10 @@ import {
|
|||
selectCurrentToolCallApplyState,
|
||||
} from "../../redux/selectors/selectCurrentToolCall";
|
||||
import { selectSelectedChatModel } from "../../redux/slices/configSlice";
|
||||
import { setHasReasoningEnabled } from "../../redux/slices/sessionSlice";
|
||||
import { exitEdit } from "../../redux/thunks/edit";
|
||||
import { getAltKeyLabel, isMetaEquivalentKeyPressed } from "../../util";
|
||||
import { cn } from "../../util/cn";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
import ModelSelect from "../modelSelection/ModelSelect";
|
||||
import { ModeSelect } from "../ModeSelect";
|
||||
|
|
@ -51,6 +57,9 @@ function InputToolbar(props: InputToolbarProps) {
|
|||
const currentToolCallApplyState = useAppSelector(
|
||||
selectCurrentToolCallApplyState,
|
||||
);
|
||||
const hasReasoningEnabled = useAppSelector(
|
||||
(store) => store.session.hasReasoningEnabled,
|
||||
);
|
||||
|
||||
const isEnterDisabled =
|
||||
props.disabled ||
|
||||
|
|
@ -143,6 +152,25 @@ function InputToolbar(props: InputToolbarProps) {
|
|||
</ToolTip>
|
||||
</HoverItem>
|
||||
)}
|
||||
{defaultModel?.provider === "anthropic" && (
|
||||
<HoverItem
|
||||
onClick={() =>
|
||||
dispatch(setHasReasoningEnabled(!hasReasoningEnabled))
|
||||
}
|
||||
>
|
||||
<LightBulbIcon
|
||||
data-tooltip-id="model-reasoning-tooltip"
|
||||
className={cn(
|
||||
"h-3 w-3 hover:brightness-150",
|
||||
hasReasoningEnabled && "brightness-200",
|
||||
)}
|
||||
/>
|
||||
|
||||
<ToolTip id="model-reasoning-tooltip" place="top">
|
||||
Use Model Reasoning
|
||||
</ToolTip>
|
||||
</HoverItem>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import {
|
|||
import {
|
||||
acceptToolCall,
|
||||
addContextItemsAtIndex,
|
||||
setHasReasoningEnabled,
|
||||
updateApplyState,
|
||||
} from "../redux/slices/sessionSlice";
|
||||
import { setTTSActive } from "../redux/slices/uiSlice";
|
||||
|
|
@ -86,6 +87,13 @@ function ParallelListeners() {
|
|||
setLocalStorage("fontSize", configResult.config.ui.fontSize);
|
||||
document.body.style.fontSize = `${configResult.config.ui.fontSize}px`;
|
||||
}
|
||||
|
||||
if (
|
||||
configResult.config?.selectedModelByRole.chat?.completionOptions
|
||||
?.reasoning
|
||||
) {
|
||||
dispatch(setHasReasoningEnabled(true));
|
||||
}
|
||||
},
|
||||
[dispatch, hasDoneInitialConfigLoad],
|
||||
);
|
||||
|
|
@ -241,7 +249,7 @@ function ParallelListeners() {
|
|||
dispatch(updateEditStateApplyState(state));
|
||||
|
||||
if (state.status === "closed") {
|
||||
dispatch(exitEdit({}));
|
||||
void dispatch(exitEdit({}));
|
||||
}
|
||||
} else {
|
||||
// chat or agent
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ type SessionState = {
|
|||
curIndex: number;
|
||||
};
|
||||
newestToolbarPreviewForInput: Record<string, string>;
|
||||
hasReasoningEnabled?: boolean;
|
||||
};
|
||||
|
||||
const initialState: SessionState = {
|
||||
|
|
@ -594,6 +595,9 @@ export const sessionSlice = createSlice({
|
|||
setIsInEdit: (state, action: PayloadAction<boolean>) => {
|
||||
state.isInEdit = action.payload;
|
||||
},
|
||||
setHasReasoningEnabled: (state, action: PayloadAction<boolean>) => {
|
||||
state.hasReasoningEnabled = action.payload;
|
||||
},
|
||||
setNewestToolbarPreviewForInput: (
|
||||
state,
|
||||
{
|
||||
|
|
@ -691,6 +695,7 @@ export const {
|
|||
deleteSessionMetadata,
|
||||
setNewestToolbarPreviewForInput,
|
||||
setIsInEdit,
|
||||
setHasReasoningEnabled,
|
||||
} = sessionSlice.actions;
|
||||
|
||||
export const { selectIsGatheringContext } = sessionSlice.selectors;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,14 @@ export const streamNormalInput = createAsyncThunk<
|
|||
};
|
||||
}
|
||||
|
||||
if (state.session.hasReasoningEnabled) {
|
||||
completionOptions = {
|
||||
...completionOptions,
|
||||
reasoning: true,
|
||||
reasoningBudgetTokens: completionOptions.reasoningBudgetTokens ?? 2048,
|
||||
};
|
||||
}
|
||||
|
||||
// Send request
|
||||
const gen = extra.ideMessenger.llmStreamChat(
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue