View Source Rag.Generation (rag v0.2.1)
Functions to generate a response and helpers to work with a generation struct.
Summary
Types
Represents a generation, the main datastructure in rag.
Functions
Appends an error to the existing list of errors.
Passes generation.prompt to response_function or provider to generate a response.
If successful, puts the result in generation.response.
Gets the evaluation at key in generation.evaluations.
Gets the retrieval result at key in generation.retrieval_results.
Sets halted? to true to skip all remaining operations.
Creates a new generation struct from a query.
Puts context in generation.context.
Puts context_sources in generation.context_sources.
Puts evaluation at key in generation.evaluations.
Puts prompt in generation.prompt.
Puts query_embedding in generation.query_embedding.
Puts response in generation.response.
Puts retrieval_result at key in generation.retrieval_results.
Types
@type embedding() :: [number()]
@type provider() :: struct()
@type t() :: %Rag.Generation{ context: String.t() | nil, context_sources: [String.t()], errors: [any()], evaluations: %{optional(atom()) => any()}, halted?: boolean(), prompt: String.t() | nil, query: String.t() | nil, query_embedding: embedding() | nil, response: String.t() | nil, retrieval_results: %{optional(atom()) => any()} }
Represents a generation, the main datastructure in rag.
Functions
Appends an error to the existing list of errors.
@spec generate_response(t(), response_function() | provider()) :: t()
Passes generation.prompt to response_function or provider to generate a response.
If successful, puts the result in generation.response.
Gets the evaluation at key in generation.evaluations.
Gets the retrieval result at key in generation.retrieval_results.
Sets halted? to true to skip all remaining operations.
Creates a new generation struct from a query.
Puts context in generation.context.
Puts context_sources in generation.context_sources.
Puts evaluation at key in generation.evaluations.
Puts prompt in generation.prompt.
Puts query_embedding in generation.query_embedding.
Puts response in generation.response.
Puts retrieval_result at key in generation.retrieval_results.