aigc

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AIGCs = map[string]*DSL{}

AIGCs the loaded AIGCs

View Source
var Autopilots = []string{}

Autopilots the loaded autopilots

Functions

func Load

func Load(cfg config.Config) error

Load load AIGC

Types

type AI

type AI interface {
	ChatCompletions(messages []map[string]interface{}, option map[string]interface{}, cb func(data []byte) int) (interface{}, *exception.Exception)
	ChatCompletionsWith(ctx context.Context, messages []map[string]interface{}, option map[string]interface{}, cb func(data []byte) int) (interface{}, *exception.Exception)
	GetContent(response interface{}) (string, *exception.Exception)
	Embeddings(input interface{}, user string) (interface{}, *exception.Exception)
	Tiktoken(input string) (int, error)
	MaxToken() int
}

AI the AI interface

type DSL

type DSL struct {
	ID        string   `json:"-" yaml:"-"`
	Name      string   `json:"name,omitempty"`
	Connector string   `json:"connector"`
	Process   string   `json:"process,omitempty"`
	Prompts   []Prompt `json:"prompts"`
	Optional  Optional `json:"optional,omitempty"`
	AI        AI       `json:"-" yaml:"-"`
}

DSL the connector DSL

func LoadFile

func LoadFile(file string, id string) (*DSL, error)

LoadFile load AIGC by file

func LoadSource

func LoadSource(data []byte, file, id string) (*DSL, error)

LoadSource load AIGC

func Select

func Select(id string) (*DSL, error)

Select select the AIGC

func (*DSL) Call

func (ai *DSL) Call(content string, user string, option map[string]interface{}) (interface{}, *exception.Exception)

Call the AIGC

type Optional

type Optional struct {
	Autopilot bool `json:"autopilot,omitempty"`
	JSON      bool `json:"json,omitempty"`
}

Optional optional

type Prompt

type Prompt struct {
	Role    string `json:"role"`
	Content string `json:"content"`
	Name    string `json:"name,omitempty"`
}

Prompt a prompt

Jump to

Keyboard shortcuts

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