google

package
v0.20.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	FinishReasonUnspecified     = "FINISH_REASON_UNSPECIFIED"
	FinishStop                  = "STOP"
	FinishMaxTokens             = "MAX_TOKENS"
	FinishSafety                = "SAFETY"
	FinishRecitation            = "RECITATION"
	FinishLanguage              = "LANGUAGE"
	FinishOther                 = "OTHER"
	FinishBlocklist             = "BLOCKLIST"
	FinishProhibitedContent     = "PROHIBITED_CONTENT"
	FinishSPII                  = "SPII"
	FinishMalformedFunctionCall = "MALFORMED_FUNCTION_CALL"
)

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 Candidate

type Candidate struct {
	Content      Content `json:"content"`
	FinishReason string  `json:"finishReason"`
}

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 {
	Contents []*Content `json:"contents"`
}

* 返回示例

{
    "candidates": [
        {
            "content": {
                "parts": [
                    {
                        "text": "Hello there! How can I help you today?\n"
                    }
                ],
                "role": "model"
            },
            "finishReason": "STOP",
            "avgLogprobs": -0.0011556809768080711
        }
    ],
    "usageMetadata": {
        "promptTokenCount": 2,
        "candidatesTokenCount": 11,
        "totalTokenCount": 13
    },
    "modelVersion": "gemini-1.5-flash-latest"
}

type Config

type Config struct {
	APIKey string `json:"google_api_key"`
	Base   string `json:"google_api_base"`
}

type Content

type Content struct {
	Parts []map[string]interface{} `json:"parts"`
	Role  string                   `json:"role"`
}

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 Error added in v0.19.5

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Status  string `json:"status"`
}

type FNewModelMode

type FNewModelMode func(string) IModelMode

type IModelMode

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

func NewChat

func NewChat(model string) IModelMode

type ModelConfig

type ModelConfig struct {
	ResponseMimeType string  `json:"response_format"`
	MaxOutputTokens  int     `json:"max_tokens_to_sample"`
	Temperature      float64 `json:"temperature"`
	TopP             float64 `json:"top_p"`
	TopK             int     `json:"top_k"`
}

type ModelFactory

type ModelFactory struct {
}

type Response

type Response struct {
	Candidates    []Candidate   `json:"candidates"`
	UsageMetadata UsageMetadata `json:"usageMetadata"`
	Error         Error         `json:"error"`
}

type UsageMetadata added in v0.19.5

type UsageMetadata struct {
	PromptTokenCount     int `json:"promptTokenCount"`
	CandidatesTokenCount int `json:"candidatesTokenCount"`
	TotalTokenCount      int `json:"totalTokenCount"`
}

Jump to

Keyboard shortcuts

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