common_handler

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 7 Imported by: 0

README

common_handler

Shared response handlers used by multiple provider adaptors for response formats that are identical across providers.

Key Functions

  • RerankHandler -- parses a rerank API response, normalizes usage (sets PromptTokens from TotalTokens), writes the JSON response to the http.ResponseWriter, and returns the extracted dto.Usage.

Usage

import "github.com/LingByte/ling-base/relay/common_handler"

// Inside an adaptor's DoResponse method:
usage, apiErr := common_handler.RerankHandler(ctx, info, resp, w)
if apiErr != nil {
    return nil, apiErr
}
return usage, nil

Documentation

Overview

Package common_handler provides shared response handlers for relay providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RerankHandler

func RerankHandler(c context.Context, info *common.RelayInfo, resp *http.Response, w http.ResponseWriter) (*dto.Usage, *types.NewAPIError)

RerankHandler parses a rerank response and writes it to w.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL