feat: support /v1/rerank router

This commit is contained in:
nongqiqin
2024-04-30 12:29:41 +08:00
parent 2720e1a358
commit 893c9adeb9
8 changed files with 133 additions and 0 deletions

View File

@@ -143,3 +143,27 @@ type CompletionsStreamResponse struct {
FinishReason string `json:"finish_reason"`
} `json:"choices"`
}
type Document struct {
Text string `json:"text"`
}
type DocumentResult struct {
Index int `json:"index"`
Score float64 `json:"score"`
Document *Document `json:"document,omitempty"`
}
type RerankRequest struct {
Model string `json:"model"`
Query string `json:"query"`
Documents []Document `json:"documents"`
TopN *int `json:"top_n,omitempty"`
MaxChunksPerDoc *int `json:"max_chunks_per_doc,omitempty"`
ReturnDocuments bool `json:"return_documents"`
}
type RerankResponse struct {
ID string `json:"id,omitempty"`
Results []DocumentResult `json:"results"`
Error *string `json:"error,omitempty"`
}