Commit 038202b1 by CaIon

馃敡 fix(xinference): update Document type to 'any' for flexibility

- Changed the type of `Document` in `XinRerankResponseDocument` from `string` to `any` to accommodate various data types.
- Updated the `RerankHandler` to handle `Document` as `any`, ensuring proper assignment based on its actual type.

These modifications enhance the handling of document data, allowing for greater versatility in response structures.
parent 6d2f34a8
package xinference package xinference
type XinRerankResponseDocument struct { type XinRerankResponseDocument struct {
Document string `json:"document,omitempty"` Document any `json:"document,omitempty"`
Index int `json:"index"` Index int `json:"index"`
RelevanceScore float64 `json:"relevance_score"` RelevanceScore float64 `json:"relevance_score"`
} }
......
...@@ -38,10 +38,16 @@ func RerankHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Respo ...@@ -38,10 +38,16 @@ func RerankHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Respo
} }
if info.ReturnDocuments { if info.ReturnDocuments {
var document any var document any
if result.Document == "" { if result.Document != nil {
document = info.Documents[result.Index] if doc, ok := result.Document.(string); ok {
} else { if doc == "" {
document = result.Document document = info.Documents[result.Index]
} else {
document = doc
}
} else {
document = result.Document
}
} }
respResult.Document = document respResult.Document = document
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment