chatmodel

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: May 4, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Pachage model include Base IO Schema etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTenantAndChatID added in v0.1.7

func GetTenantAndChatID(ctx context.Context) (string, string, error)

GetTenantAndChatID retrieves the tenant and chat ID from the provided context. If the context does not contain a ChatContext, it returns error.

func NewChatID

func NewChatID() string

NewChatID generates a new chat ID using the flake ID generator.

func Stringify

func Stringify(s any) string

func ToBytes

func ToBytes(s any) []byte

func WithChatContext

func WithChatContext(ctx context.Context, chatCtx ChatContext) context.Context

WithChatContext returns a new context with ChatContext value

Types

type BaseClarificationResult

type BaseClarificationResult struct {
	Confidence    string `` /* 161-byte string literal not displayed */
	Clarification string `` /* 205-byte string literal not displayed */
	Reasoning     string `` /* 128-byte string literal not displayed */
}

type ChatContext

type ChatContext interface {
	// GetTenantID retrieves the tenant ID from the context
	GetTenantID() string
	// GetChatID retrieves the chat ID from the context
	GetChatID() string
	// AppData returns immutable app data
	AppData() any
	// GetMetadata retrieves metadata by key
	GetMetadata(key string) (value any, ok bool)
	// SetMetadata sets metadata by key
	SetMetadata(key string, value any)
}

ChatContext is the context for the chat agent,

func GetChatContext

func GetChatContext(ctx context.Context) ChatContext

GetChatContext retrieves the ChatContext from the context

func NewChatContext

func NewChatContext(tenantID, chatID string, appData any) ChatContext

type ContentProvider

type ContentProvider interface {
	// GetContent gets the content of the message for the chat history
	GetContent() string
}

type FewShotExample

type FewShotExample struct {
	Prompt     string
	Completion string
}

type FewShotExamples

type FewShotExamples []FewShotExample

type Input

type Input struct {
	// Content is the chat message sent by the user to the assistant.
	Content string `` /* 126-byte string literal not displayed */
}

Input represents the input from the user to the AI agent.

func NewInput

func NewInput(chatMessage string) *Input

NewInput returns a new BaseAgentInput

type Output

type Output struct {
	// contains the markdown-enabled response generated by the chat agent.
	Content string `` /* 141-byte string literal not displayed */
}

Output represents the response generated by the chat agent.

func NewOutput

func NewOutput(chatMessage string) *Output

NewOutput returns a new BaseAgentOutput

func (Output) GetContent

func (o Output) GetContent() string

GetContent gets the content of the message for the chat history

type OutputParser

type OutputParser[T any] interface {
	// Parse parses the output of an LLM call.
	Parse(text string) (*T, error)
	// GetFormatInstructions returns a string describing the format of the output.
	GetFormatInstructions() string
	// Type returns the string type key uniquely identifying this class of parser
	Type() string
}

OutputParser is an interface for parsing the output of an LLM call.

type String added in v0.2.10

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

String is a simple string type that implements the ContentProvider interface.

func NewString added in v0.2.10

func NewString(str string) *String

func (String) Bytes added in v0.2.10

func (s String) Bytes() []byte

func (String) GetContent added in v0.2.10

func (o String) GetContent() string

GetContent gets the content of the message for the chat history

func (String) String added in v0.2.10

func (s String) String() string

func (*String) Unmarshal added in v0.2.10

func (s *String) Unmarshal(bs []byte) error

type Stringer

type Stringer interface {
	String() string
}

Jump to

Keyboard shortcuts

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