fcdae8f41f
* feat(UI, OpenAI): support OpenAI 4o web search add support for web search citations - refactor: Introduced a new CitationsList component to display citations in MessageContent. - feat: Enhanced message handling to support web search results and annotations from OpenAI. - refactor: Removed the deprecated MessageSearchResults component for cleaner code structure. - refactor: Added utility functions for link conversion and URL extraction from Markdown. * chore: remove debug logging from ProxyManager * revert(OpenAIProvider): streamline reasoning check for stream output handling * chore(OpenAIProvider): correct placement of webSearch in response object * fix(patches): update OpenAI package version and remove patch references - Integrated dayjs for dynamic date formatting in prompts.ts. * feat(Citation, Favicon): enhance OpenAI web search support and citation handling - Improved FallbackFavicon component to cache failed favicon URLs. - Support all web search citation preview - Added support for Hunyuan search model in OpenAIProvider and ApiService. * refactor(provider/AI): move additional search parameters to AI Provider
39 lines
829 B
TypeScript
39 lines
829 B
TypeScript
import { Model } from '@renderer/types'
|
|
import { ChatCompletionTool } from 'openai/resources'
|
|
|
|
import { WEB_SEARCH_PROMPT_FOR_ZHIPU } from './prompts'
|
|
|
|
export function getWebSearchTools(model: Model): ChatCompletionTool[] {
|
|
if (model?.provider === 'zhipu') {
|
|
if (model.id === 'glm-4-alltools') {
|
|
return [
|
|
{
|
|
type: 'web_browser',
|
|
web_browser: {
|
|
browser: 'auto'
|
|
}
|
|
} as unknown as ChatCompletionTool
|
|
]
|
|
}
|
|
return [
|
|
{
|
|
type: 'web_search',
|
|
web_search: {
|
|
enable: true,
|
|
search_result: true,
|
|
search_prompt: WEB_SEARCH_PROMPT_FOR_ZHIPU
|
|
}
|
|
} as unknown as ChatCompletionTool
|
|
]
|
|
}
|
|
|
|
return [
|
|
{
|
|
type: 'function',
|
|
function: {
|
|
name: 'googleSearch'
|
|
}
|
|
}
|
|
]
|
|
}
|