mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-28 06:25:00 +00:00
feat(rerankers): Add new backend, support jina rerankers API (#2121)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
e16658b7ec
commit
b664edde29
25 changed files with 628 additions and 5 deletions
34
core/schema/jina.go
Normal file
34
core/schema/jina.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package schema
|
||||
|
||||
// RerankRequest defines the structure of the request payload
|
||||
type JINARerankRequest struct {
|
||||
Model string `json:"model"`
|
||||
Query string `json:"query"`
|
||||
Documents []string `json:"documents"`
|
||||
TopN int `json:"top_n"`
|
||||
}
|
||||
|
||||
// DocumentResult represents a single document result
|
||||
type JINADocumentResult struct {
|
||||
Index int `json:"index"`
|
||||
Document JINAText `json:"document"`
|
||||
RelevanceScore float64 `json:"relevance_score"`
|
||||
}
|
||||
|
||||
// Text holds the text of the document
|
||||
type JINAText struct {
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
// RerankResponse defines the structure of the response payload
|
||||
type JINARerankResponse struct {
|
||||
Model string `json:"model"`
|
||||
Usage JINAUsageInfo `json:"usage"`
|
||||
Results []JINADocumentResult `json:"results"`
|
||||
}
|
||||
|
||||
// UsageInfo holds information about usage of tokens
|
||||
type JINAUsageInfo struct {
|
||||
TotalTokens int `json:"total_tokens"`
|
||||
PromptTokens int `json:"prompt_tokens"`
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue