chatgpt

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertPrompts added in v0.1.2

func ConvertPrompts(prompts []Prompt) []openai.ChatCompletionMessage

ConvertPrompts converts a slice of integration.Prompt to a slice of chatgpt.ChatMessage

func PromptToMessage added in v0.1.2

func PromptToMessage(prompt Prompt) openai.ChatCompletionMessage

PromptToMessage converts a prompt to a chatgpt.ChatMessage

Types

type ChatGPT

type ChatGPT struct {
	Prompts []Prompt
	// contains filtered or unexported fields
}

func New added in v0.1.4

func New(options *NewChatGPTOptions) *ChatGPT

New creates a new ChatGPT instance

func (*ChatGPT) Ask

func (chat *ChatGPT) Ask(user common.User, message string, historyContext string) string

Ask sends a message to the OpenAI API and returns the response

func (*ChatGPT) GetTools added in v0.1.4

func (chat *ChatGPT) GetTools() []openai.Tool

ChatGPT is a struct that represents a set of tools for ChatGPT

func (*ChatGPT) RegisterToolHandler added in v0.1.4

func (chat *ChatGPT) RegisterToolHandler(definition ToolerHandlerDefinion, handler func(common.User, map[string]any) (string, error))

RegisterToolHandler registers a tool handler

type NewChatGPTOptions added in v0.1.6

type NewChatGPTOptions struct {
	OpenAIKey        string
	MaxHistoryLength int
	OpenAIModel      string
	Prompts          []Prompt
}

NewChatGPTOptions are the options for creating a new ChatGPT instance

type Prompt added in v0.1.2

type Prompt struct {
	Role string `yaml:"role"`
	Text string `yaml:"text"`
}

Prompt is a struct that represents a ChatGPT message

type ToolHandlerParameter added in v0.1.4

type ToolHandlerParameter struct {
	Name        string
	Description string
	Type        jsonschema.DataType
	Required    bool
}

ToolHandlerParameter is a struct that represents a tool handler parameter

type ToolerHandlerDefinion added in v0.1.4

type ToolerHandlerDefinion struct {
	Name        string
	Description string
	Parameters  []ToolHandlerParameter
}

ToolerHandlerDefinion is a struct that represents a tool handler definition

Jump to

Keyboard shortcuts

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