service

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// execute host command on local machine
	Ask suggestionType = iota

	// translate text
	Translate

	// data from web page contents
	Web

	// data from file contents
	File

	// execute host command on local machine
	Cmd

	// clear all conversation history
	Clear

	// Config system setting
	Config

	// show all supported models
	Models

	// Reset suggestion
	Reset

	// Quit suggestion
	Quit

	// Others is key for various arbitrary suggestions
	Others
)
View Source
const PLUGIN_NAME_FILE_CONTENT = "file-content"
View Source
const PLUGIN_NAME_FILE_SUMMARY = "file-summary"
View Source
const PLUGIN_NAME_FILE_TRANSLATE_CN = "file-translate-cn"
View Source
const PLUGIN_NAME_FILE_TRANSLATE_EN = "file-translate-en"
View Source
const PLUGIN_NAME_FILE_TRANSLATE_JP = "file-translate-jp"
View Source
const PLUGIN_NAME_WEB_CONTENT = "web-content"
View Source
const PLUGIN_NAME_WEB_SUMMARY = "web-summary"
View Source
const PLUGIN_NAME_WEB_TRANSLATE_CN = "web-translate-cn"
View Source
const PLUGIN_NAME_WEB_TRANSLATE_EN = "web-translate-en"
View Source
const PLUGIN_NAME_WEB_TRANSLATE_JP = "web-translate-jp"

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatBot

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

func NewChatbot

func NewChatbot(chat_history_path string, name string, role_name string, log_history bool, verbose bool) *ChatBot

func (*ChatBot) Ask

func (bot *ChatBot) Ask(question string) bool

func (*ChatBot) CheckConnectivity

func (bot *ChatBot) CheckConnectivity() bool

func (*ChatBot) Close

func (bot *ChatBot) Close(exit bool)

func (*ChatBot) CommandProcessor

func (bot *ChatBot) CommandProcessor(original_msg string, arr_cmd []string) (string, bool, error)

func (*ChatBot) Run

func (bot *ChatBot) Run()

func (*ChatBot) Say

func (bot *ChatBot) Say(msg string, need_dump bool)

func (*ChatBot) ShakeHands

func (bot *ChatBot) ShakeHands() (string, error)

type ChatGPTCLient

type ChatGPTCLient struct {
	gpt3.Client

	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func NewChatBotClient added in v0.1.10

func NewChatBotClient(api_key string, api_endpoint string) *ChatGPTCLient

func (*ChatGPTCLient) AddMsgHistory added in v0.1.10

func (c *ChatGPTCLient) AddMsgHistory(role_name string, content string)

func (*ChatGPTCLient) AdjustMsgHistory added in v0.1.10

func (c *ChatGPTCLient) AdjustMsgHistory(init_msg_len int, question_len int, model string) (bool, int)

func (*ChatGPTCLient) CreateChatCompletionEx added in v0.1.10

func (c *ChatGPTCLient) CreateChatCompletionEx(
	model string,
	token_len int,
	temperature float32,
	role_name string,
	username string,
	chat_history *model.ConversationHistory,

) (response gpt3.ChatCompletionResponse, err error)

API call to Create a completion for the chat message.

func (*ChatGPTCLient) EstimateAvailableTokenNumber added in v0.1.10

func (c *ChatGPTCLient) EstimateAvailableTokenNumber(model string, question_leng int) int

func (*ChatGPTCLient) GetMaxTokens added in v0.1.8

func (c *ChatGPTCLient) GetMaxTokens(model string) int

please refer to this page for limitation:

https://platform.openai.com/docs/models/gpt-3-5

func (*ChatGPTCLient) GetMsgHistoryLength added in v0.1.10

func (c *ChatGPTCLient) GetMsgHistoryLength() int

func (*ChatGPTCLient) IsAvailable added in v0.2.0

func (c *ChatGPTCLient) IsAvailable(model string) bool

check if the model is available

func (*ChatGPTCLient) ListAllModels added in v0.2.0

func (c *ChatGPTCLient) ListAllModels() []string

func (*ChatGPTCLient) ResetMsgHistory added in v0.1.10

func (c *ChatGPTCLient) ResetMsgHistory(prompt string, opening string)

func (*ChatGPTCLient) UserLogin

func (c *ChatGPTCLient) UserLogin() (string, error)

func (*ChatGPTCLient) UserLogout

func (c *ChatGPTCLient) UserLogout() (string, error)

func (*ChatGPTCLient) UserRegistration

func (c *ChatGPTCLient) UserRegistration(email string, endpoint_url string) (string, error)

type FilePlugin

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

func (*FilePlugin) Close

func (*FilePlugin) Close() error

func (*FilePlugin) Execute

func (plugin *FilePlugin) Execute(original_msg string, arr_cmd []string) (processed bool, replaced_msg string, replaced_cmd []string, err error)

func (*FilePlugin) Open

func (plugin *FilePlugin) Open() error

type LivePrefixState

type LivePrefixState struct {
	LivePrefix string
	IsEnable   bool
	Buffer     string
}

func (*LivePrefixState) ChangeLivePrefix

func (lps *LivePrefixState) ChangeLivePrefix() (string, bool)

func (*LivePrefixState) InputModePadding

func (lps *LivePrefixState) InputModePadding(cmds string) bool

func (*LivePrefixState) ResetInputMode

func (lps *LivePrefixState) ResetInputMode()

type ModelData added in v0.1.10

type ModelData struct {
	ID         string            `json:"id"`
	Object     ObjectType        `json:"object"`
	Created    int64             `json:"created"`
	OwnedBy    string            `json:"owned_by"`
	Permission []ModelPermission `json:"permission"`
	Root       string            `json:"root"`
	Parent     string            `json:"parent"`
}

type ModelPermission added in v0.1.10

type ModelPermission struct {
	ID                 string     `json:"id"`
	Object             ObjectType `json:"object"`
	Created            int64      `json:"created"`
	AllowCreateEngine  bool       `json:"allow_create_engine"`
	AllowSampling      bool       `json:"allow_sampling"`
	AllowLogProbs      bool       `json:"allow_logprobs"`
	AllowSearchIndices bool       `json:"allow_search_indices"`
	AllowView          bool       `json:"allow_view"`
	AllowFineTuning    bool       `json:"allow_fine_tuning"`
	Organization       string     `json:"organization"`
	Group              string     `json:"group"`
	IsBlocking         bool       `json:"is_blocking"`
}

type ModelsListResponse added in v0.1.10

type ModelsListResponse struct {
	Data   []ModelData `json:"data"`
	Object ObjectType
}

type ObjectType added in v0.1.10

type ObjectType string
const (
	OTModel           ObjectType = "model"
	OTModelPermission ObjectType = "model_permission"
	OTList            ObjectType = "list"
	OTEdit            ObjectType = "edit"
	OTTextCompletion  ObjectType = "text_completion"
	OTEEmbedding      ObjectType = "embedding"
	OTFile            ObjectType = "file"
	OTFineTune        ObjectType = "fine-tune"
	OTFineTuneEvent   ObjectType = "fine-tune-event"
)

type Plugin

type Plugin interface {
	Open() error
	Close() error
	Execute(original_msg string, arr_cmd []string) (processed bool, replaced_msg string, replaced_cmd []string, err error)
}

type PluginManager

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

func NewPluginManager

func NewPluginManager() *PluginManager

func (*PluginManager) AddPlugin

func (pm *PluginManager) AddPlugin(p Plugin)

func (*PluginManager) Close

func (pm *PluginManager) Close() error

func (*PluginManager) Execute

func (pm *PluginManager) Execute(original_msg string, arr_cmd []string) (processed bool, replaced_msg string, replaced_cmd []string, err error)

func (*PluginManager) Open

func (pm *PluginManager) Open() error

type WebSummaryPlugin

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

func (*WebSummaryPlugin) Close

func (*WebSummaryPlugin) Close() error

func (*WebSummaryPlugin) Execute

func (plugin *WebSummaryPlugin) Execute(original_msg string, arr_cmd []string) (processed bool, replaced_msg string, replaced_cmd []string, err error)

func (*WebSummaryPlugin) Open

func (plugin *WebSummaryPlugin) Open() error

Jump to

Keyboard shortcuts

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