Documentation
¶
Overview ¶
Package chains provides common chain patterns for composing LangChain components.
Index ¶
- type LLMChain
- func (c *LLMChain) Batch(ctx context.Context, inputs []map[string]any, opts ...core.Option) ([]string, error)
- func (c *LLMChain) GetName() string
- func (c *LLMChain) Invoke(ctx context.Context, input map[string]any, opts ...core.Option) (string, error)
- func (c *LLMChain) Stream(ctx context.Context, input map[string]any, opts ...core.Option) (*core.StreamIterator[string], error)
- type RetrievalQA
- func (r *RetrievalQA) Batch(ctx context.Context, inputs []map[string]any, opts ...core.Option) ([]string, error)
- func (r *RetrievalQA) GetName() string
- func (r *RetrievalQA) Invoke(ctx context.Context, input map[string]any, opts ...core.Option) (string, error)
- func (r *RetrievalQA) Stream(ctx context.Context, input map[string]any, opts ...core.Option) (*core.StreamIterator[string], error)
- type StuffDocumentsChain
- func (c *StuffDocumentsChain) Batch(ctx context.Context, inputs []map[string]any, opts ...core.Option) ([]string, error)
- func (c *StuffDocumentsChain) GetName() string
- func (c *StuffDocumentsChain) Invoke(ctx context.Context, input map[string]any, opts ...core.Option) (string, error)
- func (c *StuffDocumentsChain) Stream(ctx context.Context, input map[string]any, opts ...core.Option) (*core.StreamIterator[string], error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LLMChain ¶
type LLMChain struct {
// contains filtered or unexported fields
}
LLMChain is the simplest chain: prompt -> model -> output. It implements Runnable[map[string]any, string].
func NewLLMChain ¶
func NewLLMChain(llm llms.ChatModel, prompt *prompts.ChatPromptTemplate) *LLMChain
NewLLMChain creates a new LLMChain.
func (*LLMChain) Batch ¶
func (c *LLMChain) Batch(ctx context.Context, inputs []map[string]any, opts ...core.Option) ([]string, error)
Batch runs the chain for multiple inputs.
type RetrievalQA ¶
type RetrievalQA struct {
// contains filtered or unexported fields
}
RetrievalQA combines a retriever with an LLM to answer questions. It retrieves relevant documents and uses them as context.
func NewRetrievalQA ¶
func NewRetrievalQA(retriever retrievers.Retriever, llmChain *LLMChain) *RetrievalQA
NewRetrievalQA creates a new RetrievalQA chain.
func (*RetrievalQA) Batch ¶
func (r *RetrievalQA) Batch(ctx context.Context, inputs []map[string]any, opts ...core.Option) ([]string, error)
Batch runs the chain for multiple inputs.
func (*RetrievalQA) GetName ¶
func (r *RetrievalQA) GetName() string
GetName returns the chain name.
type StuffDocumentsChain ¶
type StuffDocumentsChain struct {
// contains filtered or unexported fields
}
StuffDocumentsChain combines retrieved documents into a single context and passes them to an LLM chain.
func NewStuffDocumentsChain ¶
func NewStuffDocumentsChain(llmChain *LLMChain) *StuffDocumentsChain
NewStuffDocumentsChain creates a chain that "stuffs" all documents into the prompt.
func (*StuffDocumentsChain) Batch ¶
func (c *StuffDocumentsChain) Batch(ctx context.Context, inputs []map[string]any, opts ...core.Option) ([]string, error)
Batch runs the chain for multiple inputs.
func (*StuffDocumentsChain) GetName ¶
func (c *StuffDocumentsChain) GetName() string
GetName returns the chain name.