ai

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PromptSummarizeThread         = "summarize_thread"
	PromptDirectMessageQuestion   = "direct_message_question"
	PromptEmojiSelect             = "emoji_select"
	PromptMeetingSummary          = "meeting_summary"
	PromptMeetingSummaryOnly      = "summary_only"
	PromptMeetingKeyPoints        = "meeting_key_points"
	PromptSpellcheck              = "spellcheck"
	PromptChangeTone              = "change_tone"
	PromptSimplifyText            = "simplify_text"
	PromptAIChangeText            = "ai_change_text"
	PromptSummarizeChannelSince   = "summarize_channel_since"
	PromptSummarizeChunk          = "summarize_chunk"
	PromptExplainCode             = "explain_code"
	PromptSuggestCodeImprovements = "suggest_code_improvements"
	PromptFindActionItemsSince    = "find_action_items_since"
	PromptFindOpenQuestionsSince  = "find_open_questions_since"
)

Conviance vars for the filenames in ai/prompts/

View Source
const PromptExtension = "tmpl"
View Source
const SystemSubTemplateName = ".system"
View Source
const UserSubTemplateName = ".user"

Variables

This section is empty.

Functions

This section is empty.

Types

type BotConversation

type BotConversation struct {
	Posts   []Post
	Tools   ToolStore
	Context ConversationContext
}

func ThreadToBotConversation

func ThreadToBotConversation(botID string, posts []*model.Post) BotConversation

func (*BotConversation) AddUserPost

func (b *BotConversation) AddUserPost(post *model.Post)

func (*BotConversation) AppendConversation

func (b *BotConversation) AppendConversation(conversation BotConversation)

func (*BotConversation) ExtractSystemMessage added in v0.2.0

func (b *BotConversation) ExtractSystemMessage() string

func (BotConversation) String added in v0.3.0

func (b BotConversation) String() string

func (*BotConversation) Truncate added in v0.5.0

func (b *BotConversation) Truncate(maxTokens int, countTokens func(string) int) bool

type BuiltInToolsFunc added in v0.6.0

type BuiltInToolsFunc func(isDM bool) []Tool

type ConversationContext added in v0.3.0

type ConversationContext struct {
	BotID            string
	Time             string
	ServerName       string
	CompanyName      string
	RequestingUser   *model.User
	Channel          *model.Channel
	Team             *model.Team
	Post             *model.Post
	PromptParameters map[string]string
}

func NewConversationContext added in v0.3.0

func NewConversationContext(botID string, requestingUser *model.User, channel *model.Channel, post *model.Post) ConversationContext

func NewConversationContextParametersOnly added in v0.3.0

func NewConversationContextParametersOnly(promptParameters map[string]string) ConversationContext

func (*ConversationContext) IsDMWithBot added in v0.6.0

func (c *ConversationContext) IsDMWithBot() bool

func (ConversationContext) String added in v0.4.0

func (c ConversationContext) String() string

type ImageGenerator

type ImageGenerator interface {
	GenerateImage(prompt string) (image.Image, error)
}

type LLMConfig

type LLMConfig struct {
	Model              string
	MaxGeneratedTokens int
}

type LanguageModel

type LanguageModel interface {
	ChatCompletion(conversation BotConversation, opts ...LanguageModelOption) (*TextStreamResult, error)
	ChatCompletionNoStream(conversation BotConversation, opts ...LanguageModelOption) (string, error)

	CountTokens(text string) int
	TokenLimit() int
}

type LanguageModelOption

type LanguageModelOption func(*LLMConfig)

func WithMaxGeneratedTokens added in v0.6.1

func WithMaxGeneratedTokens(maxGeneratedTokens int) LanguageModelOption

func WithModel

func WithModel(model string) LanguageModelOption

type Post

type Post struct {
	Role    PostRole
	Message string
}

type PostRole

type PostRole int
const (
	PostRoleUser PostRole = iota
	PostRoleBot
	PostRoleSystem
)

func GetPostRole

func GetPostRole(botID string, post *model.Post) PostRole

type Prompts

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

func NewPrompts

func NewPrompts(input fs.FS, getBuiltInTools BuiltInToolsFunc) (*Prompts, error)

func (*Prompts) ChatCompletion

func (p *Prompts) ChatCompletion(templateName string, context ConversationContext) (BotConversation, error)

type ServiceConfig added in v0.5.0

type ServiceConfig struct {
	Name                    string `json:"name"`
	ServiceName             string `json:"serviceName"`
	APIKey                  string `json:"apiKey"`
	OrgID                   string `json:"orgId"`
	DefaultModel            string `json:"defaultModel"`
	URL                     string `json:"url"`
	Username                string `json:"username"`
	Password                string `json:"password"`
	TokenLimit              int    `json:"tokenLimit"`
	StreamingTimeoutSeconds int    `json:"streamingTimeoutSeconds"`
}

type TextStreamResult

type TextStreamResult struct {
	Stream <-chan string
	Err    <-chan error
}

func NewStreamFromString

func NewStreamFromString(text string) *TextStreamResult

func (*TextStreamResult) ReadAll

func (t *TextStreamResult) ReadAll() string

type Tool added in v0.3.0

type Tool struct {
	Name        string
	Description string
	Schema      any
	Resolver    func(context ConversationContext, argsGetter ToolArgumentGetter) (string, error)
}

type ToolArgumentGetter added in v0.3.0

type ToolArgumentGetter func(args any) error

type ToolStore added in v0.3.0

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

func NewToolStore added in v0.3.0

func NewToolStore() ToolStore

func (*ToolStore) AddTools added in v0.3.0

func (s *ToolStore) AddTools(tools []Tool)

func (*ToolStore) GetTools added in v0.3.0

func (s *ToolStore) GetTools() []Tool

func (*ToolStore) ResolveTool added in v0.3.0

func (s *ToolStore) ResolveTool(name string, argsGetter ToolArgumentGetter, context ConversationContext) (string, error)

type Transcriber

type Transcriber interface {
	Transcribe(file io.Reader) (*subtitles.Subtitles, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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