Преглед на файлове

🔧 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.
CaIon преди 10 месеца
родител
ревизия
038202b1f6
променени са 2 файла, в които са добавени 11 реда и са изтрити 5 реда
  1. 1 1
      relay/channel/xinference/dto.go
  2. 10 4
      relay/common_handler/rerank.go

+ 1 - 1
relay/channel/xinference/dto.go

@@ -1,7 +1,7 @@
 package xinference
 
 type XinRerankResponseDocument struct {
-	Document       string  `json:"document,omitempty"`
+	Document       any     `json:"document,omitempty"`
 	Index          int     `json:"index"`
 	RelevanceScore float64 `json:"relevance_score"`
 }

+ 10 - 4
relay/common_handler/rerank.go

@@ -38,10 +38,16 @@ func RerankHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Respo
 			}
 			if info.ReturnDocuments {
 				var document any
-				if result.Document == "" {
-					document = info.Documents[result.Index]
-				} else {
-					document = result.Document
+				if result.Document != nil {
+					if doc, ok := result.Document.(string); ok {
+						if doc == "" {
+							document = info.Documents[result.Index]
+						} else {
+							document = doc
+						}
+					} else {
+						document = result.Document
+					}
 				}
 				respResult.Document = document
 			}