generation
Composable generation APIs for Rago.
Modules:
-
base–Base classes for generation steps.
-
cohere–CohereGen class for text generation using Cohere's API.
-
deepseek–DeepSeek generation module.
-
fireworks–FireworksGen class for text generation using Fireworks API.
-
gemini–GeminiGen class for text generation using Google's Gemini model.
-
groq–Groq class for text generation.
-
hugging_face–Hugging Face classes for text generation.
-
hugging_face_inf–Hugging Face inferencing classes for text generation.
-
llama–Llama generation module.
-
openai–OpenAI Generation Model class for flexible GPT-based text generation.
-
phi–Phi generation module.
-
together–TogetherGen class for text generation using Together AI's API.
Classes:
-
Generation–Public generation wrapper that resolves a concrete backend lazily.
-
GenerationBase–Generic generation step.
-
GenerationParameters–Parameters for configuring generation steps.
Generation
Generation(
api_key: str = '',
model_name: str = '',
backend: str = '',
engine: str = '',
temperature: float = 0.0,
prompt_template: str = '',
output_max_length: int = 500,
structured_output: Type[BaseModel] | None = None,
api_params: dict[str, Any] | None = None,
device: str = 'auto',
system_message: str = '',
cache: Any = None,
logs: dict[str, Any] | None = None,
)
Bases: StepBase
Public generation wrapper that resolves a concrete backend lazily.
Methods:
-
apply–Apply declarative configuration to the generation wrapper.
-
generate–Resolve the concrete generator and run generation.
-
process–Process the current pipeline content with generation.
Source code in src/rago/generation/__init__.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
apply
apply(parameters: Any) -> None
Apply declarative configuration to the generation wrapper.
Source code in src/rago/generation/__init__.py
84 85 86 87 88 89 90 91 92 93 | |
generate
generate(query: str, data: list[str]) -> str | BaseModel
Resolve the concrete generator and run generation.
Source code in src/rago/generation/__init__.py
165 166 167 168 169 | |
process
Process the current pipeline content with generation.
Source code in src/rago/generation/__init__.py
171 172 173 174 | |
GenerationBase
GenerationBase(
model_name: Optional[str] = None,
temperature: Optional[float] = None,
prompt_template: str = '',
output_max_length: int = 500,
device: str = 'auto',
structured_output: Optional[Type[BaseModel]] = None,
system_message: str = '',
api_params: dict[str, Any] = DEFAULT_API_PARAMS,
api_key: str = '',
cache: Cache | None = None,
logs: dict[str, Any] | None = None,
)
Bases: StepBase
Generic generation step.
Methods:
-
apply–Apply attached configuration to the step.
-
generate–Generate text with optional language parameter.
-
process–Generate a result from the current pipeline content.
Source code in src/rago/generation/base.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
apply
apply(parameters: Any) -> None
Apply attached configuration to the step.
Source code in src/rago/base.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
generate
abstractmethod
generate(query: str, data: list[str]) -> str | BaseModel
Generate text with optional language parameter.
Source code in src/rago/generation/base.py
169 170 171 172 173 174 175 | |
process
Generate a result from the current pipeline content.
Source code in src/rago/generation/base.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
GenerationParameters
GenerationParameters(**kwargs: Any)
Bases: ParametersBase
Parameters for configuring generation steps.
Methods:
-
apply–Merge additional configuration into this object.
-
process–Return the input unchanged for configuration-only objects.
Attributes:
-
params(dict[str, Any]) –Expose the underlying parameter mapping.
Source code in src/rago/base.py
62 63 | |
params
property
params: dict[str, Any]
Expose the underlying parameter mapping.
apply
apply(parameters: Any) -> None
Merge additional configuration into this object.
Source code in src/rago/base.py
86 87 88 | |