gpt

package
v0.0.0-...-ca08d57 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: Unlicense Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiURL = "https://api.openai.com/v1/responses"
	Model  = "gpt-5.4-mini"

	TypeInputText          = "input_text"
	TypeInputImage         = "input_image"
	TypeMessage            = "message"
	TypeOutputText         = "output_text"
	TypeFunctionCall       = "function_call"
	TypeFunctionCallOutput = "function_call_output"

	RoleUser = "user"
)
View Source
const (
	MaxRetries               = 3
	MaxOutputTokens          = 2000
	MaxToolCallRounds        = 3
	DefaultSystemInstruction = "" /* 244-byte string literal not displayed */
)
View Source
const (
	MaxFetchedContentLength = 50_000
	FetchTimeout            = 30 * time.Second
)
View Source
const (
	BraveSearchURL    = "https://api.search.brave.com/res/v1/web/search"
	MaxSourceLinks    = 10
	BraveDefaultCount = 5
	BraveMaxCount     = 20
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIErrorResponse

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

type BraveSearchResponse

type BraveSearchResponse struct {
	Web struct {
		Results []BraveWebResult `json:"results"`
	} `json:"web"`
}

type BraveWebResult

type BraveWebResult struct {
	Title       string `json:"title"`
	URL         string `json:"url"`
	Description string `json:"description"`
	Age         string `json:"age"`
	PageAge     string `json:"page_age"`
}

type CalculatorTool

type CalculatorTool struct{}

func NewCalculatorTool

func NewCalculatorTool() *CalculatorTool

func (*CalculatorTool) Definition

func (t *CalculatorTool) Definition() FunctionTool

func (*CalculatorTool) Emoji

func (t *CalculatorTool) Emoji() string

func (*CalculatorTool) Execute

func (t *CalculatorTool) Execute(arguments string) (string, error)

type FunctionCallOutput

type FunctionCallOutput struct {
	Type   string `json:"type"`
	CallID string `json:"call_id"`
	Output string `json:"output"`
}

type FunctionParameters

type FunctionParameters struct {
	Type                 string              `json:"type"`
	Properties           map[string]Property `json:"properties"`
	Required             []string            `json:"required"`
	AdditionalProperties bool                `json:"additionalProperties"`
}

type FunctionTool

type FunctionTool struct {
	Type        string             `json:"type"`
	Name        string             `json:"name"`
	Description string             `json:"description"`
	Parameters  FunctionParameters `json:"parameters"`
	Strict      bool               `json:"strict"`
}

type InputImage

type InputImage struct {
	Type     string `json:"type"`
	ImageURL string `json:"image_url"`
}

type InputMessage

type InputMessage struct {
	Role    string `json:"role"`
	Content []any  `json:"content"`
}

type InputText

type InputText struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

type OutputContent

type OutputContent struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

type OutputItem

type OutputItem struct {
	Type string `json:"type"`
	// "message" fields
	Role    string          `json:"role,omitempty"`
	Content []OutputContent `json:"content,omitempty"`
	// "function_call" fields
	CallID    string `json:"call_id,omitempty"`
	Name      string `json:"name,omitempty"`
	Arguments string `json:"arguments,omitempty"`
}

OutputItem handles both "message" and "function_call" output types.

type Plugin

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

func New

func New(credentialService model.CredentialService, gptService Service) *Plugin

func (*Plugin) Commands

func (p *Plugin) Commands() []gotgbot.BotCommand

func (*Plugin) Handlers

func (p *Plugin) Handlers(botInfo *gotgbot.User) []plugin.Handler

func (*Plugin) Name

func (p *Plugin) Name() string

type Property

type Property struct {
	Type        string   `json:"type"`
	Description string   `json:"description"`
	Enum        []string `json:"enum,omitempty"`
}

type Reasoning

type Reasoning struct {
	Effort string `json:"effort"`
}

type Request

type Request struct {
	Model              string         `json:"model"`
	Input              []any          `json:"input"`
	Instructions       string         `json:"instructions"`
	Store              bool           `json:"store"`
	MaxOutputTokens    int            `json:"max_output_tokens"`
	PreviousResponseID string         `json:"previous_response_id,omitempty"`
	Tools              []FunctionTool `json:"tools,omitempty"`
	Reasoning          Reasoning      `json:"reasoning"`
}

type Response

type Response struct {
	ID     string       `json:"id"`
	Output []OutputItem `json:"output"`
}

type SearchResultsTool

type SearchResultsTool interface {
	Tool
	SearchResults() []BraveWebResult // this kinda sucks but we need the links at the end and the parse mode
}

type Service

type Service interface {
	GetResponseID(chat *gotgbot.Chat) (model.GPTData, error)
	ResetResponseID(chat *gotgbot.Chat) error
	SetResponseID(chat *gotgbot.Chat, responseID string) error
}

type Tool

type Tool interface {
	Definition() FunctionTool
	Execute(arguments string) (string, error)
	Emoji() string
}

type WebfetchTool

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

func NewWebfetchTool

func NewWebfetchTool(chatID int64) *WebfetchTool

func (*WebfetchTool) Definition

func (t *WebfetchTool) Definition() FunctionTool

func (*WebfetchTool) Emoji

func (t *WebfetchTool) Emoji() string

func (*WebfetchTool) Execute

func (t *WebfetchTool) Execute(arguments string) (string, error)

type WebsearchTool

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

func NewWebsearchTool

func NewWebsearchTool(apiKey string, chatID int64) *WebsearchTool

func (*WebsearchTool) Definition

func (t *WebsearchTool) Definition() FunctionTool

func (*WebsearchTool) Emoji

func (t *WebsearchTool) Emoji() string

func (*WebsearchTool) Execute

func (t *WebsearchTool) Execute(arguments string) (string, error)

func (*WebsearchTool) SearchResults

func (t *WebsearchTool) SearchResults() []BraveWebResult

Jump to

Keyboard shortcuts

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