wenxin

package
v0.20.3 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(id, name string, v *Config, workers map[eosc.RequireId]eosc.IWorker) (eosc.IWorker, error)

Create 创建驱动实例

func NewFactory

func NewFactory() eosc.IExtenderDriverFactory

NewFactory 创建service_http驱动工厂

func Register

func Register(register eosc.IExtenderDriverRegister)

Register 注册驱动

Types

type Chat

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

func (*Chat) Endpoint

func (c *Chat) Endpoint() string

func (*Chat) RequestConvert

func (c *Chat) RequestConvert(ctx eocontext.EoContext, extender map[string]interface{}) error

func (*Chat) ResponseConvert

func (c *Chat) ResponseConvert(ctx eocontext.EoContext) error

type ClientRequest

type ClientRequest struct {
	Messages []*Message `json:"messages"`
}

type Config

type Config struct {
	APIKey    string `json:"api_key"`
	SecretKey string `json:"secret_key"`
}

type Converter

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

func (*Converter) RequestConvert

func (c *Converter) RequestConvert(ctx eocontext.EoContext, extender map[string]interface{}) error

func (*Converter) ResponseConvert

func (c *Converter) ResponseConvert(ctx eocontext.EoContext) error

type FNewModelMode

type FNewModelMode func(string) IModelMode

type IModelMode

type IModelMode interface {
	Endpoint() string
	convert.IConverter
}

func NewChat

func NewChat(model string) IModelMode

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type ModelConfig

type ModelConfig struct {
	FrequencyPenalty float64 `json:"frequency_penalty"`
	MaxTokens        int     `json:"max_tokens"`
	PresencePenalty  float64 `json:"presence_penalty"`
	ResponseFormat   string  `json:"response_format"`
	Temperature      float64 `json:"temperature"`
	TopP             float64 `json:"top_p"`
	DisableSearch    bool    `json:"disable_search"`
}

type Response

type Response struct {
	Id           string `json:"id"`
	Object       string `json:"object"`
	Created      int    `json:"created"`
	Result       string `json:"result"`
	FinishReason string `json:"finish_reason"`
	ErrorCode    int    `json:"error_code"`
	ErrorMsg     string `json:"error_msg"`
	Usage        Usage  `json:"usage"`
}

type TokenResponse

type TokenResponse struct {
	//RefreshToken  string `json:"refresh_token"`
	ExpiresIn int `json:"expires_in"`
	//SessionKey    string `json:"session_key"`
	AccessToken string `json:"access_token"`
}

type Usage added in v0.19.5

type Usage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

Usage provides information about the token counts for the request and response. {"prompt_tokens":19,"completion_tokens":21,"total_tokens":40}

Jump to

Keyboard shortcuts

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