mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 22:39:36 +08:00
Co-authored-by: icarus <eurfelux@gmail.com> Co-authored-by: eeee0717 <chentao020717@outlook.com>
25 lines
702 B
TypeScript
25 lines
702 B
TypeScript
import { MultiModalDocument, RerankStrategy } from './RerankStrategy'
|
|
export class VoyageAIStrategy implements RerankStrategy {
|
|
buildUrl(baseURL?: string): string {
|
|
if (baseURL && baseURL.endsWith('/')) {
|
|
return `${baseURL}rerank`
|
|
}
|
|
if (baseURL && !baseURL.endsWith('/v1')) {
|
|
baseURL = `${baseURL}/v1`
|
|
}
|
|
return `${baseURL}/rerank`
|
|
}
|
|
buildRequestBody(query: string, documents: MultiModalDocument[], topN: number, model?: string) {
|
|
const textDocuments = documents.filter((d) => d.text).map((d) => d.text!)
|
|
return {
|
|
model,
|
|
query,
|
|
documents: textDocuments,
|
|
top_k: topN
|
|
}
|
|
}
|
|
extractResults(data: any) {
|
|
return data.data
|
|
}
|
|
}
|