Documentation ¶
Overview ¶
Package ernie wrapper around the Baidu Large Language Model Platform APIs. ERNIE-Bot is a Baidu-developed large language model. Additional information can be found at: https://cloud.baidu.com/doc/WENXINWORKSHOP/index.html .
Index ¶
- Constants
- Variables
- type LLM
- func (o *LLM) Call(ctx context.Context, prompt string, options ...llms.CallOption) (string, error)
- func (o *LLM) CreateEmbedding(ctx context.Context, texts []string) ([][]float32, error)
- func (o *LLM) GenerateContent(ctx context.Context, messages []llms.MessageContent, ...) (*llms.ContentResponse, error)
- type ModelName
- type Option
Constants ¶
const ( ModelNameERNIEBot = "ERNIE-Bot" ModelNameERNIEBotTurbo = "ERNIE-Bot-turbo" ModelNameERNIEBotPro = "ERNIE-Bot-pro" ModelNameBloomz7B = "BLOOMZ-7B" ModelNameLlama2_7BChat = "Llama-2-7b-chat" ModelNameLlama2_13BChat = "Llama-2-13b-chat" ModelNameLlama2_70BChat = "Llama-2-70b-chat" )
Variables ¶
var ( ErrEmptyResponse = errors.New("no response") ErrCodeResponse = errors.New("has error code") )
Functions ¶
This section is empty.
Types ¶
type LLM ¶
func (*LLM) CreateEmbedding ¶
CreateEmbedding use ernie Embedding-V1. 1. texts counts less than 16 2. text runes counts less than 384 doc: https://cloud.baidu.com/doc/WENXINWORKSHOP/s/alj562vvu
func (*LLM) GenerateContent ¶
func (o *LLM) GenerateContent(ctx context.Context, messages []llms.MessageContent, options ...llms.CallOption) (*llms.ContentResponse, error)
GenerateContent implements the Model interface.
type Option ¶
type Option func(*options)
func WithAKSK ¶
WithAKSK passes the ERNIE API Key and Secret Key to the client. If not set, the keys are read from the ERNIE_API_KEY and ERNIE_SECRET_KEY environment variable. eg:
export ERNIE_API_KEY={Api Key} export ERNIE_SECRET_KEY={Serect Key}
Api Key,Serect Key from https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application More information available: https://cloud.baidu.com/doc/WENXINWORKSHOP/s/flfmc9do2
func WithAccessToken ¶
WithAccessToken usually used for dev, Prod env recommend use WithAKSK.
func WithCallbackHandler ¶
WithCallbackHandler passes the callback Handler to the client.
func WithModelName ¶
WithModelName passes the Model Name to the client. If not set, use default ERNIE-Bot.