mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-25 19:30:17 +08:00
* feat: Add search summary model and related functionality - Introduce new search summary model configuration in settings - Implement search summary prompt and model selection - Add support for generating search keywords across providers - Update localization files with new search summary model translations - Enhance web search functionality with search summary generation * refactor: Improve web search error handling and async flow * fix: Update migration version for settings search summary prompt * refactor(webSearch): Remove search summary model references from settings and localization files - Deleted search summary model entries from English, Japanese, Russian, Chinese, and Traditional Chinese localization files. - Refactored ModelSettings component to remove search summary model handling. - Updated related services and settings to eliminate search summary model dependencies. * refactor(llm): Remove search summary model from state and related hooks
73 lines
2.2 KiB
TypeScript
73 lines
2.2 KiB
TypeScript
import BaseProvider from '@renderer/providers/BaseProvider'
|
|
import ProviderFactory from '@renderer/providers/ProviderFactory'
|
|
import { Assistant, GenerateImageParams, Message, Model, Provider, Suggestion } from '@renderer/types'
|
|
import OpenAI from 'openai'
|
|
|
|
import { CompletionsParams } from '.'
|
|
|
|
export default class AiProvider {
|
|
private sdk: BaseProvider
|
|
|
|
constructor(provider: Provider) {
|
|
this.sdk = ProviderFactory.create(provider)
|
|
}
|
|
|
|
public async fakeCompletions(params: CompletionsParams): Promise<void> {
|
|
return this.sdk.fakeCompletions(params)
|
|
}
|
|
|
|
public async completions({
|
|
messages,
|
|
assistant,
|
|
mcpTools,
|
|
onChunk,
|
|
onFilterMessages
|
|
}: CompletionsParams): Promise<void> {
|
|
return this.sdk.completions({ messages, assistant, mcpTools, onChunk, onFilterMessages })
|
|
}
|
|
|
|
public async translate(message: Message, assistant: Assistant, onResponse?: (text: string) => void): Promise<string> {
|
|
return this.sdk.translate(message, assistant, onResponse)
|
|
}
|
|
|
|
public async summaries(messages: Message[], assistant: Assistant): Promise<string> {
|
|
return this.sdk.summaries(messages, assistant)
|
|
}
|
|
|
|
public async summaryForSearch(messages: Message[], assistant: Assistant): Promise<string | null> {
|
|
return this.sdk.summaryForSearch(messages, assistant)
|
|
}
|
|
|
|
public async suggestions(messages: Message[], assistant: Assistant): Promise<Suggestion[]> {
|
|
return this.sdk.suggestions(messages, assistant)
|
|
}
|
|
|
|
public async generateText({ prompt, content }: { prompt: string; content: string }): Promise<string> {
|
|
return this.sdk.generateText({ prompt, content })
|
|
}
|
|
|
|
public async check(model: Model): Promise<{ valid: boolean; error: Error | null }> {
|
|
return this.sdk.check(model)
|
|
}
|
|
|
|
public async models(): Promise<OpenAI.Models.Model[]> {
|
|
return this.sdk.models()
|
|
}
|
|
|
|
public getApiKey(): string {
|
|
return this.sdk.getApiKey()
|
|
}
|
|
|
|
public async generateImage(params: GenerateImageParams): Promise<string[]> {
|
|
return this.sdk.generateImage(params)
|
|
}
|
|
|
|
public async getEmbeddingDimensions(model: Model): Promise<number> {
|
|
return this.sdk.getEmbeddingDimensions(model)
|
|
}
|
|
|
|
public getBaseURL(): string {
|
|
return this.sdk.getBaseURL()
|
|
}
|
|
}
|