Documentation
¶
Index ¶
- func CreateEmbeddingsStepObject(runtime *goja.Runtime, loop *eventloop.EventLoop, ...) (*goja.Object, error)
- func CreateStepObject[T any, U any](runtime *goja.Runtime, loop *eventloop.EventLoop, step steps.Step[T, U], ...) (*goja.Object, error)
- func NewJSLambdaStep[T any, U any](runtime *goja.Runtime, fn goja.Callable, inputConverter func(T) goja.Value, ...) steps.Step[T, U]
- func RegisterConversation(runtime *goja.Runtime) error
- func RegisterEmbeddings(runtime *goja.Runtime, globalName string, provider embeddings.Provider, ...) error
- func RegisterFactory(runtime *goja.Runtime, loop *eventloop.EventLoop, ...) error
- func RegisterStep[T any, U any](runtime *goja.Runtime, loop *eventloop.EventLoop, name string, ...) error
- type CallbackFunctions
- type JSConversation
- func (jc *JSConversation) AddMessage(role string, text string, options *goja.Object) (string, error)
- func (jc *JSConversation) AddMessageWithImage(role string, text string, imagePath string) (string, error)
- func (jc *JSConversation) AddToolResult(toolID string, result string) (string, error)
- func (jc *JSConversation) AddToolUse(toolID string, name string, input interface{}) (string, error)
- func (jc *JSConversation) GetMessageView(messageID string) (string, error)
- func (jc *JSConversation) GetMessages() conversation.Conversation
- func (jc *JSConversation) GetSinglePrompt() string
- func (jc *JSConversation) ToGoConversation() conversation.Conversation
- func (jc *JSConversation) UpdateMetadata(messageID string, metadata map[string]interface{}) (bool, error)
- type JSEmbeddingsWrapper
- type JSStepWrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateEmbeddingsStepObject ¶
func CreateEmbeddingsStepObject(runtime *goja.Runtime, loop *eventloop.EventLoop, provider steps.Step[string, []float32]) (*goja.Object, error)
Example usage with embeddings step
func CreateStepObject ¶
func CreateStepObject[T any, U any]( runtime *goja.Runtime, loop *eventloop.EventLoop, step steps.Step[T, U], inputConverter func(goja.Value) T, outputConverter func(U) goja.Value, ) (*goja.Object, error)
CreateStepObject creates a JavaScript object wrapping a Step with Promise, blocking and callback APIs
func NewJSLambdaStep ¶
func NewJSLambdaStep[T any, U any]( runtime *goja.Runtime, fn goja.Callable, inputConverter func(T) goja.Value, outputConverter func(goja.Value) (U, error), ) steps.Step[T, U]
Helper to create a LambdaStep from a JavaScript function
func RegisterConversation ¶
RegisterConversation registers the Conversation constructor in the JavaScript runtime
func RegisterEmbeddings ¶
func RegisterEmbeddings(runtime *goja.Runtime, globalName string, provider embeddings.Provider, loop *eventloop.EventLoop) error
RegisterEmbeddings registers the embeddings functionality in the given Goja runtime
func RegisterFactory ¶
func RegisterFactory(runtime *goja.Runtime, loop *eventloop.EventLoop, stepSettings *settings.StepSettings) error
RegisterFactory registers the chat step factory functionality in the JavaScript runtime
Types ¶
type CallbackFunctions ¶
type JSConversation ¶
type JSConversation struct {
// contains filtered or unexported fields
}
JSConversation wraps a conversation.Manager to expose it to JavaScript
func NewJSConversation ¶
func NewJSConversation(runtime *goja.Runtime) *JSConversation
func (*JSConversation) AddMessage ¶
func (jc *JSConversation) AddMessage(role string, text string, options *goja.Object) (string, error)
AddMessage adds a new chat message to the conversation
func (*JSConversation) AddMessageWithImage ¶
func (jc *JSConversation) AddMessageWithImage(role string, text string, imagePath string) (string, error)
AddMessageWithImage adds a chat message with an attached image
func (*JSConversation) AddToolResult ¶
func (jc *JSConversation) AddToolResult(toolID string, result string) (string, error)
AddToolResult adds a tool result message
func (*JSConversation) AddToolUse ¶
func (jc *JSConversation) AddToolUse(toolID string, name string, input interface{}) (string, error)
AddToolUse adds a tool use message
func (*JSConversation) GetMessageView ¶
func (jc *JSConversation) GetMessageView(messageID string) (string, error)
GetMessageView returns a formatted view of a specific message
func (*JSConversation) GetMessages ¶
func (jc *JSConversation) GetMessages() conversation.Conversation
GetMessages returns all messages in the conversation
func (*JSConversation) GetSinglePrompt ¶
func (jc *JSConversation) GetSinglePrompt() string
GetSinglePrompt returns the conversation as a single prompt string
func (*JSConversation) ToGoConversation ¶
func (jc *JSConversation) ToGoConversation() conversation.Conversation
ToGoConversation returns the underlying Go conversation
func (*JSConversation) UpdateMetadata ¶
func (jc *JSConversation) UpdateMetadata(messageID string, metadata map[string]interface{}) (bool, error)
UpdateMetadata updates a message's metadata
type JSEmbeddingsWrapper ¶
type JSEmbeddingsWrapper struct {
// contains filtered or unexported fields
}