Compare commits

...

1 Commits

Author SHA1 Message Date
kangfenmao
73e760132c 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
2025-06-26 12:26:13 +08:00
5 changed files with 32 additions and 13 deletions

View File

@@ -192,7 +192,7 @@ export class AnthropicAPIClient extends BaseApiClient<
const parts: MessageParam['content'] = [
{
type: 'text',
text: getMainTextContent(message)
text: await this.getMessageContent(message)
}
]

View File

@@ -2469,6 +2469,10 @@ export function isGeminiReasoningModel(model?: Model): boolean {
return false
}
if (model.id.startsWith('gemini') && model.id.includes('thinking')) {
return true
}
if (model.id.includes('gemini-2.5')) {
return true
}

View File

@@ -31,7 +31,7 @@ const MessageErrorInfo: React.FC<{ block: ErrorMessageBlock }> = ({ block }) =>
}
const Alert = styled(AntdAlert)`
margin: 0.5rem 0;
margin: 0.5rem 0 !important;
padding: 10px;
font-size: 12px;
`

View File

@@ -53,17 +53,21 @@ const CitationsList: React.FC<CitationsListProps> = ({ citations }) => {
if (!count) return null
const popoverContent = (
<PopoverContent>
<div>
{citations.map((citation) => (
<PopoverContentItem key={citation.url || citation.number}>
{citation.type === 'websearch' ? (
<WebSearchCitation citation={citation} />
<PopoverContent>
<WebSearchCitation citation={citation} />
</PopoverContent>
) : (
<KnowledgeCitation citation={citation} />
<KnowledgePopoverContent>
<KnowledgeCitation citation={citation} />
</KnowledgePopoverContent>
)}
</PopoverContentItem>
))}
</PopoverContent>
</div>
)
return (
@@ -184,9 +188,7 @@ const KnowledgeCitation: React.FC<{ citation: Citation }> = ({ citation }) => {
<CitationIndex>{citation.number}</CitationIndex>
{citation.content && <CopyButton content={citation.content} />}
</WebSearchCardHeader>
<WebSearchCardContent className="selectable-text">
{citation.content && truncateText(citation.content, 100)}
</WebSearchCardContent>
<WebSearchCardContent className="selectable-text">{citation.content && citation.content}</WebSearchCardContent>
</WebSearchCard>
</ContextMenu>
)
@@ -196,7 +198,7 @@ const OpenButton = styled(Button)`
display: flex;
align-items: center;
padding: 3px 8px;
margin-bottom: 8px;
margin: 8px 0;
align-self: flex-start;
font-size: 12px;
background-color: var(--color-background-soft);
@@ -318,10 +320,15 @@ const WebSearchCardContent = styled.div`
`
const PopoverContent = styled.div`
max-width: min(340px, 60vw);
max-width: min(400px, 60vw);
max-height: 60vh;
padding: 0 12px;
`
const KnowledgePopoverContent = styled(PopoverContent)`
max-width: 800px;
`
const PopoverContentItem = styled.div`
border-bottom: 0.5px solid var(--color-border);
&:last-child {

View File

@@ -4,9 +4,9 @@ import { HStack } from '@renderer/components/Layout'
import { TopView } from '@renderer/components/TopView'
import { searchKnowledgeBase } from '@renderer/services/KnowledgeService'
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 { useState } from 'react'
import { useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
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 [searchKeyword, setSearchKeyword] = useState('')
const { t } = useTranslation()
const searchInputRef = useRef<InputRef>(null)
const handleSearch = async (value: string) => {
if (!value.trim()) {
@@ -82,6 +83,12 @@ const PopupContainer: React.FC<Props> = ({ base, resolve }) => {
}
}
useEffect(() => {
if (searchInputRef.current) {
searchInputRef.current.focus()
}
}, [])
return (
<Modal
title={null}
@@ -109,6 +116,7 @@ const PopupContainer: React.FC<Props> = ({ base, resolve }) => {
}}>
<HStack style={{ padding: '0 12px', marginTop: 8 }}>
<Input
ref={searchInputRef}
prefix={
<SearchIcon>
<Search size={15} />