mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-20 07:00:09 +08:00
fix: Gemini reasoning model check and improve citation popover structure
- Added a new condition to the Gemini reasoning model check to include models with IDs starting with 'gemini' and containing 'thinking'. - Refactored the CitationsList component to improve the structure of popover content for web search and knowledge citations. - Updated styled components for better layout and responsiveness in the citation popover. - Adjusted margin styles in ErrorBlock for consistent spacing. - Fix Anthropic request cannot handle webSearch and knowbase references
This commit is contained in:
parent
5e0cae06db
commit
73e760132c
@ -192,7 +192,7 @@ export class AnthropicAPIClient extends BaseApiClient<
|
|||||||
const parts: MessageParam['content'] = [
|
const parts: MessageParam['content'] = [
|
||||||
{
|
{
|
||||||
type: 'text',
|
type: 'text',
|
||||||
text: getMainTextContent(message)
|
text: await this.getMessageContent(message)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@ -2469,6 +2469,10 @@ export function isGeminiReasoningModel(model?: Model): boolean {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (model.id.startsWith('gemini') && model.id.includes('thinking')) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
if (model.id.includes('gemini-2.5')) {
|
if (model.id.includes('gemini-2.5')) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,7 @@ const MessageErrorInfo: React.FC<{ block: ErrorMessageBlock }> = ({ block }) =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Alert = styled(AntdAlert)`
|
const Alert = styled(AntdAlert)`
|
||||||
margin: 0.5rem 0;
|
margin: 0.5rem 0 !important;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
`
|
`
|
||||||
|
|||||||
@ -53,17 +53,21 @@ const CitationsList: React.FC<CitationsListProps> = ({ citations }) => {
|
|||||||
if (!count) return null
|
if (!count) return null
|
||||||
|
|
||||||
const popoverContent = (
|
const popoverContent = (
|
||||||
<PopoverContent>
|
<div>
|
||||||
{citations.map((citation) => (
|
{citations.map((citation) => (
|
||||||
<PopoverContentItem key={citation.url || citation.number}>
|
<PopoverContentItem key={citation.url || citation.number}>
|
||||||
{citation.type === 'websearch' ? (
|
{citation.type === 'websearch' ? (
|
||||||
<WebSearchCitation citation={citation} />
|
<PopoverContent>
|
||||||
|
<WebSearchCitation citation={citation} />
|
||||||
|
</PopoverContent>
|
||||||
) : (
|
) : (
|
||||||
<KnowledgeCitation citation={citation} />
|
<KnowledgePopoverContent>
|
||||||
|
<KnowledgeCitation citation={citation} />
|
||||||
|
</KnowledgePopoverContent>
|
||||||
)}
|
)}
|
||||||
</PopoverContentItem>
|
</PopoverContentItem>
|
||||||
))}
|
))}
|
||||||
</PopoverContent>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -184,9 +188,7 @@ const KnowledgeCitation: React.FC<{ citation: Citation }> = ({ citation }) => {
|
|||||||
<CitationIndex>{citation.number}</CitationIndex>
|
<CitationIndex>{citation.number}</CitationIndex>
|
||||||
{citation.content && <CopyButton content={citation.content} />}
|
{citation.content && <CopyButton content={citation.content} />}
|
||||||
</WebSearchCardHeader>
|
</WebSearchCardHeader>
|
||||||
<WebSearchCardContent className="selectable-text">
|
<WebSearchCardContent className="selectable-text">{citation.content && citation.content}</WebSearchCardContent>
|
||||||
{citation.content && truncateText(citation.content, 100)}
|
|
||||||
</WebSearchCardContent>
|
|
||||||
</WebSearchCard>
|
</WebSearchCard>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
)
|
)
|
||||||
@ -196,7 +198,7 @@ const OpenButton = styled(Button)`
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 3px 8px;
|
padding: 3px 8px;
|
||||||
margin-bottom: 8px;
|
margin: 8px 0;
|
||||||
align-self: flex-start;
|
align-self: flex-start;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
background-color: var(--color-background-soft);
|
background-color: var(--color-background-soft);
|
||||||
@ -318,10 +320,15 @@ const WebSearchCardContent = styled.div`
|
|||||||
`
|
`
|
||||||
|
|
||||||
const PopoverContent = styled.div`
|
const PopoverContent = styled.div`
|
||||||
max-width: min(340px, 60vw);
|
max-width: min(400px, 60vw);
|
||||||
max-height: 60vh;
|
max-height: 60vh;
|
||||||
padding: 0 12px;
|
padding: 0 12px;
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const KnowledgePopoverContent = styled(PopoverContent)`
|
||||||
|
max-width: 800px;
|
||||||
|
`
|
||||||
|
|
||||||
const PopoverContentItem = styled.div`
|
const PopoverContentItem = styled.div`
|
||||||
border-bottom: 0.5px solid var(--color-border);
|
border-bottom: 0.5px solid var(--color-border);
|
||||||
&:last-child {
|
&:last-child {
|
||||||
|
|||||||
@ -4,9 +4,9 @@ import { HStack } from '@renderer/components/Layout'
|
|||||||
import { TopView } from '@renderer/components/TopView'
|
import { TopView } from '@renderer/components/TopView'
|
||||||
import { searchKnowledgeBase } from '@renderer/services/KnowledgeService'
|
import { searchKnowledgeBase } from '@renderer/services/KnowledgeService'
|
||||||
import { FileType, KnowledgeBase } from '@renderer/types'
|
import { FileType, KnowledgeBase } from '@renderer/types'
|
||||||
import { Divider, Input, List, message, Modal, Spin, Tooltip, Typography } from 'antd'
|
import { Divider, Input, InputRef, List, message, Modal, Spin, Tooltip, Typography } from 'antd'
|
||||||
import { Search } from 'lucide-react'
|
import { Search } from 'lucide-react'
|
||||||
import { useState } from 'react'
|
import { useEffect, useRef, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
|
|
||||||
@ -26,6 +26,7 @@ const PopupContainer: React.FC<Props> = ({ base, resolve }) => {
|
|||||||
const [results, setResults] = useState<Array<ExtractChunkData & { file: FileType | null }>>([])
|
const [results, setResults] = useState<Array<ExtractChunkData & { file: FileType | null }>>([])
|
||||||
const [searchKeyword, setSearchKeyword] = useState('')
|
const [searchKeyword, setSearchKeyword] = useState('')
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
const searchInputRef = useRef<InputRef>(null)
|
||||||
|
|
||||||
const handleSearch = async (value: string) => {
|
const handleSearch = async (value: string) => {
|
||||||
if (!value.trim()) {
|
if (!value.trim()) {
|
||||||
@ -82,6 +83,12 @@ const PopupContainer: React.FC<Props> = ({ base, resolve }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (searchInputRef.current) {
|
||||||
|
searchInputRef.current.focus()
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={null}
|
title={null}
|
||||||
@ -109,6 +116,7 @@ const PopupContainer: React.FC<Props> = ({ base, resolve }) => {
|
|||||||
}}>
|
}}>
|
||||||
<HStack style={{ padding: '0 12px', marginTop: 8 }}>
|
<HStack style={{ padding: '0 12px', marginTop: 8 }}>
|
||||||
<Input
|
<Input
|
||||||
|
ref={searchInputRef}
|
||||||
prefix={
|
prefix={
|
||||||
<SearchIcon>
|
<SearchIcon>
|
||||||
<Search size={15} />
|
<Search size={15} />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user