apitest

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewApilTest

func NewApilTest(maxConcurrency int) interfaces.ApiTest

NewChannelTest creates a new ChannelTest instance

Types

type ChannelTest

type ChannelTest struct {
	// contains filtered or unexported fields
}

func (*ChannelTest) PrintResults

func (ct *ChannelTest) PrintResults(results []models.TestResult) error

PrintResults prints the test results in a formatted way

func (*ChannelTest) TestAllApis

func (ct *ChannelTest) TestAllApis(channels []*models.Channel) []models.TestResult

TestAllApis tests all provided channels

func (*ChannelTest) TestSingleChannel

func (ct *ChannelTest) TestSingleChannel(channelType models.ChannelType, url, model, key string) error

TestSingleChannel tests a single channel with the specified model

type GeminiContent

type GeminiContent struct {
	Parts []GeminiPart `json:"parts"`
}

type GeminiError

type GeminiError struct {
	Error struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
		Status  string `json:"status"`
		Details []struct {
			Type     string            `json:"@type"`
			Reason   string            `json:"reason,omitempty"`
			Domain   string            `json:"domain,omitempty"`
			Metadata map[string]string `json:"metadata,omitempty"`
			Message  string            `json:"message,omitempty"`
			Locale   string            `json:"locale,omitempty"`
		} `json:"details"`
	} `json:"error"`
}

GeminiError represents the error structure returned by Gemini API

type GeminiGenerationConfig

type GeminiGenerationConfig struct {
	MaxOutputTokens int      `json:"maxOutputTokens,omitempty"`
	Temperature     float64  `json:"temperature,omitempty"`
	TopP            float64  `json:"topP,omitempty"`
	TopK            int      `json:"topK,omitempty"`
	CandidateCount  int      `json:"candidateCount,omitempty"`
	StopSequences   []string `json:"stopSequences,omitempty"`
}

type GeminiPart

type GeminiPart struct {
	Text string `json:"text"`
}

type GeminiRequest

type GeminiRequest struct {
	Contents         []GeminiContent         `json:"contents"`
	GenerationConfig *GeminiGenerationConfig `json:"generationConfig,omitempty"`
}

GeminiRequest represents a test request for Gemini

type GeneralOpenAIRequest

type GeneralOpenAIRequest struct {
	Model               string         `json:"model"`
	Messages            []Message      `json:"messages"`
	MaxTokens           int            `json:"max_tokens,omitempty"`
	MaxCompletionTokens int            `json:"max_completion_tokens,omitempty"`
	Stream              bool           `json:"stream"`
	StreamOptions       *StreamOptions `json:"stream_options,omitempty"`
}

GeneralOpenAIRequest represents a test request for OpenAI

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

Message represents a chat message

type OpenAIError

type OpenAIError struct {
	Error struct {
		Message string `json:"message"`
		Type    string `json:"type"`
		Code    string `json:"code"`
	} `json:"error"`
}

OpenAIError represents the error structure returned by OpenAI API

type StreamOptions

type StreamOptions struct {
	MaxTokens int `json:"max_tokens,omitempty"`
}

type Usage

type Usage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

Usage represents token usage

Jump to

Keyboard shortcuts

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