chains

package
v0.0.0-...-9a0c461 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ConversationMemoryKey = "chat_history"

Variables

This section is empty.

Functions

func Conversation

func Conversation(model llmcomposer.LLM, opts ...LLMOptions) llmcomposer.ChainFunc

Conversation is a chain that can be used to create a conversation with a chat model. It works best with Chat models, but can also be used with Completion models. It creates a memory buffer with the key "chat_history" by default, but this can be changed by using the WithMemory option. If you change the memory buffer or the prompt, make sure the memory's outputKey is set to the same value (default = ConversationMemoryKey) used in the prompt.

func LLM

func LLM(model llmcomposer.LLM, prompt llmcomposer.Prompt, opts ...LLMOptions) llmcomposer.ChainFunc

LLM is a chain link that calls an LLM. It can be used to wrap a call to an LLM, so that it can be used as a chain link.

func Parallel

func Parallel(maxParallel int, chains ...llmcomposer.Chain) llmcomposer.ChainFunc

Parallel executes a list of chains in parallel, up to a maximum number of concurrent executions. If any of the chains returns an error, the execution is stopped and the error is returned. The results of all chains are merged into a single Values object. The order of the results is not guaranteed.

TODO: Fix any data race issues

func Sequential

func Sequential(chains ...llmcomposer.Chain) llmcomposer.ChainFunc

Sequential is a chain that executes a list of chains in sequence. The output of each chain is passed as input to the next one. The output of the last chain is returned as the output of the Sequential chain.

Types

type LLMOptions

type LLMOptions func(*llmOptions)

func WithMemory

func WithMemory(memory llmcomposer.Memory) LLMOptions

func WithOutputKey

func WithOutputKey(key string) LLMOptions

func WithPrompt

func WithPrompt(prompt llmcomposer.Prompt) LLMOptions

Jump to

Keyboard shortcuts

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