Reranking
Use the Go SDK to rank candidate documents by relevance to a query.
Provider/model examples:
- Cohere:
Provider: schemas.Cohere,Model: "rerank-v3.5" - vLLM:
Provider: schemas.VLLM,Model: "BAAI/bge-reranker-v2-m3"
Basic Example
Section titled “Basic Example”package main
import ( "context" "fmt"
deepintshield "github.com/maximhq/deepintshield/core" "github.com/maximhq/deepintshield/core/schemas")
func main() { client, err := deepintshield.Init(context.Background(), schemas.DeepIntShieldConfig{ Account: &MyAccount{}, }) if err != nil { panic(err) } defer client.Shutdown()
request := &schemas.DeepIntShieldRerankRequest{ Provider: schemas.Cohere, Model: "rerank-v3.5", Query: "What is DeepIntShield?", Documents: []schemas.RerankDocument{ {Text: "DeepIntShield is an AI gateway that unifies many LLM providers."}, {Text: "Paris is the capital of France."}, {Text: "DeepIntShield exposes an OpenAI-compatible API."}, }, Params: &schemas.RerankParameters{ TopN: deepintshield.Ptr(2), ReturnDocuments: deepintshield.Ptr(true), }, }
resp, bfErr := client.RerankRequest(schemas.NewDeepIntShieldContext(context.Background(), schemas.NoDeadline), request) if bfErr != nil { panic(bfErr.Error.Message) }
for _, result := range resp.Results { fmt.Printf("index=%d score=%.4f\n", result.Index, result.RelevanceScore) }}Parameters
Section titled “Parameters”Provider,Model: provider/model to use for rerankQuery: query textDocuments: documents to score (text, optionalid,meta)Params.TopN: max result countParams.MaxTokensPerDoc: provider-dependent token capParams.Priority: provider-dependent priority hintParams.ReturnDocuments: include source document in each resultFallbacks: fallback provider/model choices
For vLLM, set Provider to schemas.VLLM and use the upstream model ID as Model (without the vllm/ prefix that is used in Gateway HTTP requests).
Response
Section titled “Response”DeepIntShieldRerankResponse includes:
Results []RerankResult(index,relevance_score, optionaldocument)Model- optional
Usage ExtraFieldsmetadata (provider,latency,request_type, etc.)
Next Steps
Section titled “Next Steps”- Streaming Responses - Real-time response processing
- Tool Calling - Enable AI to use external functions
- Multimodal AI - Process images and multimedia content
- Core Features - Advanced DeepIntShield capabilities