RAG#

Submodules#

Basic RAG#

Class for Basic RAG.

This module provides:

  • BasicRAG

class grag.rag.basic_rag.BasicRAG(retriever: Retriever | None = None, model_name=None, doc_chain='stuff', task='QA', llm_kwargs=None, retriever_kwargs=None, stream: bool = False, custom_prompt: Prompt | FewShotPrompt | None = None)[source]#

Bases: object

Class for Basis RAG.

model_name[source]#

Name of the llm model

Type:

str

doc_chain[source]#

Name of the document chain, (“stuff”, “refine”), defaults to “stuff”

Type:

str

task[source]#

Name of task, defaults to “QA”

Type:

str

llm_kwargs[source]#

Keyword arguments for LLM class

Type:

dict

retriever_kwargs[source]#

Keyword arguments for Retriever class

Type:

dict

custom_prompt[source]#

Prompt, defaults to None

Type:

Prompt

property doc_chain[source]#

Returns the doc_chain.

property model_name[source]#

Return the name of the model.

static output_parser(call_func)[source]#

Decorator to format llm output.

prompt_matcher()[source]#

Matches relvant prompt using model, task and doc_chain.

refine_call(**kwargs)[source]#
refine_chain(query: str)[source]#

Call function for refine chain.

stuff_call(**kwargs)[source]#
stuff_chain(query: str)[source]#

Call function for stuff chain.

static stuff_docs(docs: List[Document]) str[source]#

Concatenates docs into a string seperated by ‘nn’.

Parameters:

docs – List of langchain_core.documents.Document

Returns:

string of document page content joined by ‘nn’

property task[source]#

Returns the task.

Module contents#