redis

package
v0.14.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultLatestK is the default number of latest conversation turns to retrieve
	DefaultLatestK = 5
)

Functions

func Init

func Init(logger *zap.Logger) base.IConnector

func NewClient

func NewClient(config *structpb.Struct) (*goredis.Client, error)

NewClient creates a new redis client

func WriteNonSystemMessage

func WriteNonSystemMessage(client *goredis.Client, sessionID string, message MultiModalMessageWithTime) error

func WriteSystemMessage

func WriteSystemMessage(client *goredis.Client, sessionID string, message MultiModalMessageWithTime) error

WriteSystemMessage writes system message for a given session ID

Types

type ChatHistoryRetrieveInput

type ChatHistoryRetrieveInput struct {
	SessionID            string `json:"session_id"`
	LatestK              *int   `json:"latest_k,omitempty"`
	IncludeSystemMessage bool   `json:"include_system_message"`
}

type ChatHistoryRetrieveOutput

type ChatHistoryRetrieveOutput struct {
	Messages []*MultiModalMessage `json:"messages"`
	Status   bool                 `json:"status"`
}

ChatHistoryReadOutput is a wrapper struct for the messages associated with a session ID

func RetrieveSessionMessages

func RetrieveSessionMessages(client *goredis.Client, input ChatHistoryRetrieveInput) ChatHistoryRetrieveOutput

RetrieveSessionMessages retrieves the latest K conversation turns from the Redis list for the given session ID

type ChatMessageWriteInput

type ChatMessageWriteInput struct {
	SessionID string `json:"session_id"`
	Message
}

type ChatMessageWriteOutput

type ChatMessageWriteOutput struct {
	Status bool `json:"status"`
}

type ChatMultiModalMessageWriteInput

type ChatMultiModalMessageWriteInput struct {
	SessionID string `json:"session_id"`
	MultiModalMessage
}

type Connector

type Connector struct {
	base.Connector
}

func (*Connector) CreateExecution

func (c *Connector) CreateExecution(defUID uuid.UUID, task string, config *structpb.Struct, logger *zap.Logger) (base.IExecution, error)

func (*Connector) Test

func (c *Connector) Test(defUID uuid.UUID, config *structpb.Struct, logger *zap.Logger) (pipelinePB.Connector_State, error)

type DisableSSL

type DisableSSL struct {
	Mode SSLMode `json:"mode"`
}

DisableSSL is the struct for disable SSL

func (*DisableSSL) GetConfig

func (d *DisableSSL) GetConfig() (*tls.Config, error)

type Execution

type Execution struct {
	base.Execution
}

func (*Execution) Execute

func (e *Execution) Execute(inputs []*structpb.Struct) ([]*structpb.Struct, error)

type Message

type Message struct {
	Role     string                  `json:"role"`
	Content  string                  `json:"content"`
	Metadata *map[string]interface{} `json:"metadata,omitempty"`
}

type MessageWithTime

type MessageWithTime struct {
	Message
	Timestamp int64 `json:"timestamp"`
}

type MultiModalContent

type MultiModalContent struct {
	Type     string  `json:"type"`
	Text     *string `json:"text,omitempty"`
	ImageURL *struct {
		URL string `json:"url"`
	} `json:"image_url,omitempty"`
}

type MultiModalMessage

type MultiModalMessage struct {
	Role     string                  `json:"role"`
	Content  []MultiModalContent     `json:"content"`
	Metadata *map[string]interface{} `json:"metadata,omitempty"`
}

type MultiModalMessageWithTime

type MultiModalMessageWithTime struct {
	MultiModalMessage
	Timestamp int64 `json:"timestamp"`
}

func RetrieveSystemMessage

func RetrieveSystemMessage(client *goredis.Client, sessionID string) (bool, *MultiModalMessageWithTime, error)

RetrieveSystemMessage gets system message based on a given session ID

type SSLMode

type SSLMode string

SSLMode is the type for SSL mode

const (
	DisableSSLMode    SSLMode = "disable"
	VerifyFullSSLMode SSLMode = "verify-full"
)

type SSLModeConfig

type SSLModeConfig interface {
	GetConfig() (*tls.Config, error)
}

SSLConfig is the interface for SSL configuration

type VerifyFullSSL

type VerifyFullSSL struct {
	Mode       SSLMode `json:"mode"`
	CaCert     string  `json:"ca_cert"`
	ClientCert string  `json:"client_cert"`
	ClientKey  string  `json:"client_key"`
}

VerifyFullSSL is the struct for verify-full SSL. It always requires encryption and verification of the identify of the server.

func (*VerifyFullSSL) GetConfig

func (e *VerifyFullSSL) GetConfig() (*tls.Config, error)

Jump to

Keyboard shortcuts

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