util

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcDeviation

func CalcDeviation(counts map[int]map[model.Role]int, theoretical map[model.Role]float64) float64

func CalcHasErrorAgents

func CalcHasErrorAgents(agents []*model.Agent) int

func CalcTheoretical

func CalcTheoretical(roleNumMap map[model.Role]int, gameCount int, teamCount int) (map[model.Role]float64, []model.Role)

func CalcWinSideTeam

func CalcWinSideTeam(statusMap map[model.Agent]model.Status) model.Team

func ConvertWavToSegment added in v0.3.13

func ConvertWavToSegment(params ConvertWavToSegmentParams) ([]string, error)

func CountAliveTeams

func CountAliveTeams(statusMap map[model.Agent]model.Status) (int, int)

func CountLength added in v0.3.5

func CountLength(text string, inWord bool, countSpaces bool) int

func CreateAgents

func CreateAgents(conns []model.Connection, roles map[model.Role]int) []*model.Agent

func CreateAgentsWithProfiles added in v0.3.9

func CreateAgentsWithProfiles(conns []model.Connection, roles map[model.Role]int, profiles []model.Profile, encoding map[string]string) []*model.Agent

func CreateAgentsWithRole

func CreateAgentsWithRole(roleMapConns map[model.Role][]model.Connection) []*model.Agent

func CreateAgentsWithRoleAndProfile added in v0.3.1

func CreateAgentsWithRoleAndProfile(roleMapConns map[model.Role][]model.Connection, profiles []model.Profile, encoding map[string]string) []*model.Agent

func FilterAgents

func FilterAgents(agents []*model.Agent, filter func(*model.Agent) bool) []*model.Agent

func FindAgentByName

func FindAgentByName(agents []*model.Agent, name string) *model.Agent

func GenerateMatches

func GenerateMatches(gameCount int, teamCount int, roles []model.Role, theoretical map[model.Role]float64) ([]map[model.Role][]int, float64)

func GenerateProfiles added in v0.3.9

func GenerateProfiles(config model.DynamicProfileConfig, profileEncoding map[string]string, size int) ([]model.Profile, error)

func GetCandidates

func GetCandidates(votes []model.Vote, condition func(model.Vote) bool) []model.Agent

func GetDuration added in v0.3.13

func GetDuration(ffprobePath string, args []string, targetPath string) (float64, error)

func GetRoleMap

func GetRoleMap(agents []*model.Agent) map[model.Agent]model.Role

func GetRoleTeamNamesMap

func GetRoleTeamNamesMap(agents []*model.Agent) map[model.Role][]string

func IdxMatchToTeamNameMatch

func IdxMatchToTeamNameMatch(idxTeamMap map[int]string, match map[model.Role][]int) map[model.Role][]string

func IsValidPlayerToken

func IsValidPlayerToken(secret string, tokenString string, team string) bool

func IsValidReceiver

func IsValidReceiver(secret string, tokenString string) bool

func SelectRandomAgent

func SelectRandomAgent(agents []model.Agent) model.Agent

func TeamNameMatchToIdxMatch

func TeamNameMatchToIdxMatch(idxTeamMap map[int]string, match map[model.Role][]string) map[model.Role][]int

func TrimLength added in v0.3.5

func TrimLength(text string, length int, inWord bool, countSpaces bool) string

Types

type ChatCompletionRequest added in v0.3.9

type ChatCompletionRequest struct {
	Model          string         `json:"model"`
	Messages       []Message      `json:"messages"`
	ResponseFormat ResponseFormat `json:"response_format"`
	MaxTokens      int            `json:"max_tokens"`
}

type ChatCompletionResponse added in v0.3.9

type ChatCompletionResponse struct {
	Choices []Choice `json:"choices"`
}

type Choice added in v0.3.9

type Choice struct {
	Message struct {
		Content string `json:"content"`
	} `json:"message"`
}

type ContentItem added in v0.3.9

type ContentItem struct {
	Type     string   `json:"type"`
	Text     string   `json:"text,omitempty"`
	ImageURL ImageURL `json:"image_url,omitempty"`
}

type ConvertWavToSegmentParams added in v0.3.13

type ConvertWavToSegmentParams struct {
	FfmpegPath      string
	FfprobePath     string
	DurationArgs    []string
	ConvertArgs     []string
	PreConvertArgs  []string
	SplitArgs       []string
	TempDir         string
	SegmentDuration float64
	Data            []byte
	BaseDir         string
	BaseName        string
}

type ImageURL added in v0.3.9

type ImageURL struct {
	URL string `json:"url"`
}

type JSONSchema added in v0.3.9

type JSONSchema struct {
	Name   string          `json:"name"`
	Strict bool            `json:"strict"`
	Schema json.RawMessage `json:"schema"`
}

type Message added in v0.3.9

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

type ProfileData added in v0.3.9

type ProfileData struct {
	Name      string         `json:"name"`
	Arguments map[string]any `json:"-"`
}

type ResponseFormat added in v0.3.9

type ResponseFormat struct {
	Type       string     `json:"type"`
	JSONSchema JSONSchema `json:"json_schema"`
}

Jump to

Keyboard shortcuts

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