llmdriver

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 17 Imported by: 6

README

llmdriver

Build GitHub release (latest by date)

MIT Licence GitHub code size

Quality Gate Status

Reliability Rating Bugs

Security Rating Vulnerabilities

Maintainability Rating Technical Debt Code Smells

Lines of Code Coverage

大语言模型 服务调用驱动.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpDriverMap

func DumpDriverMap()

func GetConfigWithDefault

func GetConfigWithDefault(ctx context.Context, pattern, def string) string

func GetConfigWithNamePattern

func GetConfigWithNamePattern(ctx context.Context, name, namePattern, defPattern string) (v string)

func GetDriverMap

func GetDriverMap(ctx context.Context) *gmap.TreeMap

func GoX

func GoX(goroutineFunc func())

func Int

func Int(v int) *int

func Int64

func Int64(v int64) *int64

func Int64Value

func Int64Value(v *int64) int64

func IntValue

func IntValue(v *int) int

func LogError

func LogError(err error)

func Register

func Register(name string, driver Driver)

func String

func String(v string) *string

func StringNotEmpty

func StringNotEmpty(v string) *string

func StringValue

func StringValue(v *string) string

func VarInt

func VarInt(v *gvar.Var) *int

func VarInt64

func VarInt64(v *gvar.Var) *int64

func VarString

func VarString(v *gvar.Var) *string

Types

type Choice

type Choice interface {
	GetIndex() *int
	GetFinishReason() *string
	GetMessage() Message
}

type DefaultOutputStream

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

func NewDefaultOutputStream

func NewDefaultOutputStream() *DefaultOutputStream

func (*DefaultOutputStream) Close

func (s *DefaultOutputStream) Close(err error)

func (*DefaultOutputStream) Drain

func (s *DefaultOutputStream) Drain()

func (*DefaultOutputStream) Err

func (s *DefaultOutputStream) Err() (err error)

func (*DefaultOutputStream) Event

func (s *DefaultOutputStream) Event() <-chan OutputEvent

func (*DefaultOutputStream) Push

func (s *DefaultOutputStream) Push(event OutputEvent)

type Driver

type Driver interface {
	Available(ctx context.Context) (ok bool)
	Call(ctx context.Context, input Input) (output Output, err error)
	CallStream(ctx context.Context, input Input) (stream OutputStream)
}

func GetDriver

func GetDriver(ctx context.Context, name string) (Driver, error)

type Input

type Input interface {
	GetMessages() []Message
	GetTools() []Tool
}

func NewInput

func NewInput(messages []Message, tools []Tool) Input

type JsonKeysOption

type JsonKeysOption func(jsonKeysOptional)

func WithChoicesKey

func WithChoicesKey(choicesKey string) JsonKeysOption

func WithChoicesMessageKey

func WithChoicesMessageKey(choicesMessageKey string) JsonKeysOption

func WithCodeKey

func WithCodeKey(codeKey string) JsonKeysOption

func WithCompletionKey

func WithCompletionKey(completionKey string) JsonKeysOption

func WithEvent

func WithEvent(event string) JsonKeysOption

func WithEventId

func WithEventId(id string) JsonKeysOption

func WithIdKey

func WithIdKey(idKey string) JsonKeysOption

func WithMessageKey

func WithMessageKey(messageKey string) JsonKeysOption

func WithPromptKey

func WithPromptKey(promptKey string) JsonKeysOption

func WithTotalKey

func WithTotalKey(totalKey string) JsonKeysOption

func WithUsageKey

func WithUsageKey(usageKey string) JsonKeysOption

type Message

type Message interface {
	GetRole() *string
	GetContent() *string
	GetToolCalls() []ToolCall
	GetToolCallId() *string
	GetName() *string
}

func JsonToMessages

func JsonToMessages(json *gjson.Json) (messages []Message, err error)

func NewMessage

func NewMessage(role, content *string, options ...MessageOption) Message

type MessageOption

type MessageOption func(*message)

func WithName

func WithName(name *string) MessageOption

func WithToolCallId

func WithToolCallId(toolCallId *string) MessageOption

func WithToolCalls

func WithToolCalls(toolCalls []ToolCall) MessageOption

type Output

type Output interface {
	Code() *string
	Message() *string
	GetId() *string
	GetChoices() []Choice
	GetUsage() Usage
}

func NewJsonOutput

func NewJsonOutput(json *gjson.Json, options ...JsonKeysOption) Output

func ParseJsonOutput

func ParseJsonOutput(jsonString string, options ...JsonKeysOption) (Output, error)

type OutputEvent

type OutputEvent interface {
	EventId() *string
	Event() *string
	GetId() *string
	GetChoices() []Choice
	GetUsage() Usage
}

func NewJsonOutputEvent

func NewJsonOutputEvent(json *gjson.Json, options ...JsonKeysOption) OutputEvent

func ParseJsonOutputEvent

func ParseJsonOutputEvent(event *gclientx.Event, options ...JsonKeysOption) (OutputEvent, error)

type OutputStream

type OutputStream interface {
	Event() <-chan OutputEvent
	Err() error
	Drain()
}

type Tool

type Tool interface {
	GetType() *string
	GetFunction() ToolFunction
}

func JsonToTools

func JsonToTools(json *gjson.Json) (tools []Tool, err error)

func NewTool

func NewTool(tType *string, function ToolFunction) Tool

type ToolCall

type ToolCall interface {
	GetId() *string
	GetType() *string
	GetFunction() ToolCallFunction
	GetIndex() *int
}

func NewToolCall

func NewToolCall(id, tType *string, function ToolCallFunction, index *int) ToolCall

type ToolCallFunction

type ToolCallFunction interface {
	GetName() *string
	GetArguments() *string
}

func NewToolCallFunction

func NewToolCallFunction(name, arguments *string) ToolCallFunction

type ToolFunction

type ToolFunction interface {
	GetName() *string
	GetDescription() *string
	GetParameters() map[string]interface{}
}

func NewToolFunction

func NewToolFunction(name, description *string, parameters map[string]interface{}) ToolFunction

type Usage

type Usage interface {
	GetPromptTokens() *int64
	GetCompletionTokens() *int64
	GetTotalTokens() *int64
}

Directories

Path Synopsis
drivers
doubao Module
hunyuan Module
moonshot Module
qwen Module
zhipu Module
llmhttp module

Jump to

Keyboard shortcuts

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