utils

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BasicColors = []ColorInfo{
	{Color: color.RGBA{R: 255, G: 0, B: 0, A: 255}, Name: "Red"},
	{Color: color.RGBA{R: 0, G: 255, B: 0, A: 255}, Name: "Green"},
	{Color: color.RGBA{R: 0, G: 0, B: 255, A: 255}, Name: "Blue"},
	{Color: color.RGBA{R: 255, G: 255, B: 0, A: 255}, Name: "Yellow"},
	{Color: color.RGBA{R: 255, G: 0, B: 255, A: 255}, Name: "Magenta"},
	{Color: color.RGBA{R: 0, G: 255, B: 255, A: 255}, Name: "Cyan"},
	{Color: color.RGBA{R: 255, G: 165, B: 0, A: 255}, Name: "Orange"},
	{Color: color.RGBA{R: 128, G: 0, B: 128, A: 255}, Name: "Purple"},
	{Color: color.RGBA{R: 165, G: 42, B: 42, A: 255}, Name: "Brown"},
}

BasicColors provides a list of basic colors with their names

Functions

func ClearConsole

func ClearConsole()

ClearConsole clears the console screen

func FindAvailablePort

func FindAvailablePort(startPort int) int

FindAvailablePort finds an available port starting from the given port

func IsPortAvailable

func IsPortAvailable(port int) bool

IsPortAvailable checks if a port is available

func Min

func Min(a, b int) int

Min returns the minimum of two integers

Types

type ChatMessage added in v0.0.7

type ChatMessage struct {
	Role    string           `json:"role"`
	Content []MessageContent `json:"content"`
}

ChatMessage represents a message in the chat

type ChatRequest added in v0.0.7

type ChatRequest struct {
	Model     string        `json:"model"`
	Messages  []ChatMessage `json:"messages"`
	MaxTokens int           `json:"max_tokens"`
	Stream    bool          `json:"stream"`
}

ChatRequest represents the chat completion request structure

type ChatResponse added in v0.0.7

type ChatResponse struct {
	Choices []struct {
		Message struct {
			Content string `json:"content"`
		} `json:"message"`
	} `json:"choices"`
}

ChatResponse represents the chat completion response structure

func SendChatRequest added in v0.0.7

func SendChatRequest(ctx context.Context, url, apiKey, model string, imageURL string, maxTokens int) (*ChatResponse, error)

SendChatRequest sends a chat completion request to the specified URL

type ColorInfo added in v0.0.7

type ColorInfo struct {
	Color color.RGBA
	Name  string
}

ColorInfo represents a basic color with its name

func GenerateRandomImage

func GenerateRandomImage(width, height int) (image.Image, []ColorInfo)

GenerateRandomImage creates a random colored image with a pattern

func GetRandomUniqueColors added in v0.0.7

func GetRandomUniqueColors(n int) []ColorInfo

GetRandomUniqueColors returns n unique random colors from the basic colors

type ImageURL added in v0.0.7

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

ImageURL represents an image URL

type MessageContent added in v0.0.7

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

MessageContent represents the content of a message

Jump to

Keyboard shortcuts

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