1
0

rerank.go 885 B

123456789101112131415161718192021222324252627282930313233
  1. package dto
  2. type RerankRequest struct {
  3. Documents []any `json:"documents"`
  4. Query string `json:"query"`
  5. Model string `json:"model"`
  6. TopN int `json:"top_n,omitempty"`
  7. ReturnDocuments *bool `json:"return_documents,omitempty"`
  8. MaxChunkPerDoc int `json:"max_chunk_per_doc,omitempty"`
  9. OverLapTokens int `json:"overlap_tokens,omitempty"`
  10. }
  11. func (r *RerankRequest) GetReturnDocuments() bool {
  12. if r.ReturnDocuments == nil {
  13. return false
  14. }
  15. return *r.ReturnDocuments
  16. }
  17. type RerankResponseResult struct {
  18. Document any `json:"document,omitempty"`
  19. Index int `json:"index"`
  20. RelevanceScore float64 `json:"relevance_score"`
  21. }
  22. type RerankDocument struct {
  23. Text any `json:"text"`
  24. }
  25. type RerankResponse struct {
  26. Results []RerankResponseResult `json:"results"`
  27. Usage Usage `json:"usage"`
  28. }