assistant

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const BaseURL = "https://api.openai.com/v1"

Variables

This section is empty.

Functions

func Do

func Do(req *http.Request) ([]byte, error)

func ExtractArg1

func ExtractArg1(jsonStr string) (string, error)

func FormatString added in v0.0.7

func FormatString(input string) string

FormatString formata uma string para atender aos requisitos: - Remove caracteres inválidos - Substitui espaços por "_" - Garante que o comprimento máximo seja de 64 caracteres

func SubmitToolOutput

func SubmitToolOutput(threadID, runID, toolCallID, output string) error

func ToolFromTool

func ToolFromTool(t tools.Tool) llms.Tool

toolFromTool converts an llms.Tool to a Tool.

Types

type Annotation

type Annotation struct {
	FileCitation string `json:"file_citation"`
	FilePath     string `json:"file_path"`
}

type Assistant

type Assistant struct {
	ID           string            `json:"id,omitempty"`
	Model        string            `json:"model"`
	Name         string            `json:"name,omitempty"`
	Description  string            `json:"description,omitempty"`
	Instructions string            `json:"instructions,omitempty"`
	Tools        *[]llms.Tool      `json:"tools,omitempty"`
	ToolResource *ToolResource     `json:"tool_resources,omitempty"`
	Temperature  *float64          `json:"temperature,omitempty"`
	TopP         *float64          `json:"top_p,omitempty"`
	Metadata     map[string]string `json:"metadata,omitempty"`
}

func NewAssistant

func NewAssistant(opts ...AssistantOption) (*Assistant, error)

NewAssistant inicializa um novo assistente, opcionalmente com um ID de assistente existente.

func (*Assistant) DeleteAssistant

func (a *Assistant) DeleteAssistant() (*AssistantResponse, error)

Delete an assistant.

func (*Assistant) ListAssistants

func (a *Assistant) ListAssistants() ([]Assistant, error)

Returns a list of assistants.

func (*Assistant) RetrieveAssistant

func (a *Assistant) RetrieveAssistant() (*Assistant, error)

Retrieve assistan

func (*Assistant) UpdateAssistant

func (a *Assistant) UpdateAssistant(assistnt Assistant) (*Assistant, error)

Modifies an assistant.

type AssistantOption

type AssistantOption func(*Assistant)

Option define o tipo para opções funcionais para configurar o assistente.

func WithAssistantID

func WithAssistantID(id string) AssistantOption

WithAssistantID configura o assistente com um ID existente.

func WithDescription

func WithDescription(description string) AssistantOption

WithDescription configura a descrição do assistente.

func WithInstructions

func WithInstructions(instructions string) AssistantOption

WithInstructions configura as instruções do assistente.

func WithMetadata

func WithMetadata(metadata map[string]string) AssistantOption

WithMetadata configura os metadados do assistente.

func WithModel

func WithModel(model string) AssistantOption

WithModel configura o modelo do assistente.

func WithName

func WithName(name string) AssistantOption

WithName configura o nome do assistente.

func WithTemperature

func WithTemperature(temperature float64) AssistantOption

WithTemperature configura a temperatura do assistente.

func WithToolResource

func WithToolResource(toolResource ToolResource) AssistantOption

WithToolResource configura o recurso da ferramenta do assistente.

func WithTools

func WithTools(tools []tools.Tool) AssistantOption

WithTools configura as ferramentas do assistente.

func WithTopP

func WithTopP(topP float64) AssistantOption

WithTopP configura o valor TopP do assistente.

type AssistantResponse

type AssistantResponse struct {
	ID      string      `json:"id"`
	Object  string      `json:"object"`
	Data    []Assistant `json:"data,omitempty"`
	Deleted bool        `json:"deleted,omitempty"`
}

type Attachments

type Attachments struct {
	FileID string `json:"file_id"`
	Tools  []Tool `json:"tools"`
}

type ChunkingStrategy

type ChunkingStrategy struct {
	Type   string                 `json:"type"`
	Static StaticChunkingStrategy `json:"static"`
}

type CodeInterpreter

type CodeInterpreter struct {
	Type string `json:"type"` //The type of tool being defined: code_interpreter
}

type CodeInterpreterToolResource

type CodeInterpreterToolResource struct {
	FileIDs []string `json:"file_ids"`
}

type Content

type Content struct {
	Text      ContentText `json:"text,omitempty"`
	ImageURL  ImageURL    `json:"image_url,omitempty"`
	ImageFile ImageFile   `json:"image_file,omitempty"`
}

type ContentText

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

type ContentTextValue

type ContentTextValue struct {
	Value       string       `json:"value"`
	Annotations []Annotation `json:"annotations"`
}

type File

type File struct {
	FileID string `json:"file_id"`
	Detail string `json:"detail,omitempty"`
}

type FileSearch

type FileSearch struct {
	MaxNumResults int           `json:"max_num_results"`
	RankingOption RankingOption `json:"ranking_option"`
}

type FileSearchToolResource

type FileSearchToolResource struct {
	VectorStoreIDs []string      `json:"vector_store_ids,omitempty"`
	VectorStores   []VectorStore `json:"vector_stores,omitempty"`
}

type ImageFile

type ImageFile struct {
	Type      string `json:"type"`
	ImageFile File   `json:"image_file"`
}

type ImageURL

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

type RankingOption

type RankingOption struct {
	Ranker         string  `json:"ranker"`
	ScoreThreshold float64 `json:"score_threshold"`
}

type StaticChunkingStrategy

type StaticChunkingStrategy struct {
	MaxChunkSizeTokens int `json:"max_chunk_size_tokens"`
	ChunkOverlapTokens int `json:"chunk_overlap_tokens"`
}

type Tool

type Tool struct {
	ID       string    `json:"id,omitempty"`
	Type     ToolType  `json:"type"`
	Function llms.Tool `json:"function,omitempty"`
}

type ToolCall

type ToolCall struct {
	ID       string       `json:"id,omitempty"`
	Type     ToolType     `json:"type"`
	Function ToolFunction `json:"function,omitempty"`
}

func ToolCallsFromToolCalls

func ToolCallsFromToolCalls(tcs []llms.ToolCall) []ToolCall

toolCallsFromToolCalls converts a slice of llms.ToolCall to a slice of ToolCall.

type ToolFunction

type ToolFunction struct {
	Name      string `json:"name"`
	Arguments string `json:"arguments"`
}

type ToolResource

type ToolResource struct {
	CodeInterpreter *CodeInterpreterToolResource `json:"code_interpreter,omitempty"`
	FileSearch      *FileSearchToolResource      `json:"file_search,omitempty"`
}

type ToolType

type ToolType string
const (
	ToolTypeFunction    ToolType = "function"
	ToolTypeFileSearch  ToolType = "file_search"
	CodeInterpreterType ToolType = "code_interpreter"
)

type URL

type URL struct {
	URL    string `json:"url"`
	Detail string `json:"detail,omitempty"`
}

type VectorStore

type VectorStore struct {
	FileIDs          []string         `json:"file_ids,omitempty"`
	ChunkingStrategy ChunkingStrategy `json:"chunking_strategy,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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