[Go] Fix searchbot retrieval_test accept kb_id as array, fix model recognize (#16452)

This commit is contained in:
Wang Qi
2026-06-29 17:17:20 +08:00
committed by GitHub
parent 3202ec6abf
commit c0f64295c2
2 changed files with 36 additions and 14 deletions

View File

@@ -132,6 +132,24 @@ type SearchBotRetrievalTestRequest struct {
// Highlight *bool `json:"highlight,omitempty"`
}
// UnmarshalJSON accepts both kb_id (Python API) and kb_ids (Go compatibility).
func (r *SearchBotRetrievalTestRequest) UnmarshalJSON(data []byte) error {
type Alias SearchBotRetrievalTestRequest
aux := struct {
*Alias
KbID common.StringSlice `json:"kb_id"`
}{
Alias: (*Alias)(r),
}
if err := json.Unmarshal(data, &aux); err != nil {
return err
}
if len(r.KbIDs) == 0 && len(aux.KbID) > 0 {
r.KbIDs = aux.KbID
}
return nil
}
// SearchBotRequest is the request body for POST /api/v1/searchbots/related_questions.
type SearchBotRequest struct {
Question string `json:"question" binding:"required"`