fix(Inputbar): enhance message usage estimation and clean up code structure
This commit is contained in:
parent
10848f7a45
commit
3768c135d8
@ -180,11 +180,13 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic, topic }) =
|
|||||||
if (mentionModels) {
|
if (mentionModels) {
|
||||||
userMessage.mentions = mentionModels
|
userMessage.mentions = mentionModels
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFunctionCallingModel(model)) {
|
if (isFunctionCallingModel(model)) {
|
||||||
if (!isEmpty(enabledMCPs) && !isEmpty(activedMcpServers)) {
|
if (!isEmpty(enabledMCPs) && !isEmpty(activedMcpServers)) {
|
||||||
userMessage.enabledMCPs = activedMcpServers.filter((server) => enabledMCPs?.some((s) => s.id === server.id))
|
userMessage.enabledMCPs = activedMcpServers.filter((server) => enabledMCPs?.some((s) => s.id === server.id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
userMessage.usage = await estimateMessageUsage(userMessage)
|
userMessage.usage = await estimateMessageUsage(userMessage)
|
||||||
currentMessageId.current = userMessage.id
|
currentMessageId.current = userMessage.id
|
||||||
|
|
||||||
|
|||||||
@ -90,8 +90,7 @@ const AssistantSettingPopupContainer: React.FC<Props> = ({ resolve, tab, ...prop
|
|||||||
content: {
|
content: {
|
||||||
padding: 0,
|
padding: 0,
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
background: 'var(--color-background)',
|
background: 'var(--color-background)'
|
||||||
border: `1px solid var(--color-frame-border)`
|
|
||||||
},
|
},
|
||||||
header: { padding: '10px 15px', borderBottom: '0.5px solid var(--color-border)', margin: 0 }
|
header: { padding: '10px 15px', borderBottom: '0.5px solid var(--color-border)', margin: 0 }
|
||||||
}}
|
}}
|
||||||
@ -100,8 +99,7 @@ const AssistantSettingPopupContainer: React.FC<Props> = ({ resolve, tab, ...prop
|
|||||||
centered>
|
centered>
|
||||||
<HStack>
|
<HStack>
|
||||||
<LeftMenu>
|
<LeftMenu>
|
||||||
<Menu
|
<StyledMenu
|
||||||
style={{ width: 220, padding: 5, background: 'transparent' }}
|
|
||||||
defaultSelectedKeys={[tab || 'prompt']}
|
defaultSelectedKeys={[tab || 'prompt']}
|
||||||
mode="vertical"
|
mode="vertical"
|
||||||
items={items}
|
items={items}
|
||||||
@ -195,6 +193,16 @@ const StyledModal = styled(Modal)`
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const StyledMenu = styled(Menu)`
|
||||||
|
width: 220px;
|
||||||
|
padding: 5px;
|
||||||
|
background: transparent;
|
||||||
|
margin-top: 2px;
|
||||||
|
.ant-menu-item {
|
||||||
|
margin-bottom: 7px;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
export default class AssistantSettingsPopup {
|
export default class AssistantSettingsPopup {
|
||||||
static show(props: AssistantSettingPopupShowParams) {
|
static show(props: AssistantSettingPopupShowParams) {
|
||||||
return new Promise<Assistant>((resolve) => {
|
return new Promise<Assistant>((resolve) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user