base
BaseLLM
Bases: BaseModel
Base class for Large Language Model implementations.
Provides common configuration parameters and interface methods for LLMs.
Source code in rm_gallery/core/model/base.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
|
achat(messages, **kwargs)
async
Async version of chat method using thread pooling.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messages
|
List[ChatMessage] | str
|
Input messages in various formats |
required |
**kwargs
|
Same parameters as chat() |
{}
|
Returns:
Type | Description |
---|---|
ChatResponse | GeneratorChatResponse
|
ChatResponse or GeneratorChatResponse depending on streaming configuration |
Source code in rm_gallery/core/model/base.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
chat(messages, **kwargs)
Process chat messages and generate a response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messages
|
List[ChatMessage] | str
|
Input messages in various formats (list of ChatMessage, single ChatMessage, or string) |
required |
**kwargs
|
Additional implementation-specific parameters |
{}
|
Returns:
Type | Description |
---|---|
ChatResponse | GeneratorChatResponse
|
ChatResponse for non-streaming responses or GeneratorChatResponse for streaming |
Source code in rm_gallery/core/model/base.py
175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
chat_batched(messages_batched, **kwargs)
Process multiple message batches concurrently.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messages_batched
|
List[List[ChatMessage]] | str
|
List of message lists or single string input |
required |
**kwargs
|
Same parameters as chat() |
{}
|
Returns:
Type | Description |
---|---|
List[ChatResponse]
|
List of ChatResponses in the same order as input batches |
Source code in rm_gallery/core/model/base.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|
register_tools(tools, tool_choice)
Register tools for the LLM to use during response generation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tools
|
List[Dict[str, Any]]
|
List of tool definitions in OpenAI tool format |
required |
tool_choice
|
Union[str, Dict]
|
Tool selection strategy ('auto' or specific tool definition) |
required |
Source code in rm_gallery/core/model/base.py
189 190 191 192 193 194 195 196 197 198 199 |
|
simple_chat(query, history=None, sys_prompt='', debug=False)
Simplified chat interface for basic query/response scenarios.
Handles conversation history and system prompts automatically.
Source code in rm_gallery/core/model/base.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
|
simple_chat_reasoning(query, history=None, sys_prompt='', debug=False)
Simplified chat interface with reasoning stream handling.
Processes streaming responses with separate reasoning content handling.
Source code in rm_gallery/core/model/base.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
|
get_from_dict_or_env(data, key, default=None)
Get a value from a dictionary or an environment variable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Dict[str, Any]
|
The dictionary to look up the key in. |
required |
key
|
str
|
The key to look up in the dictionary or environment. This can be a list of keys to try in order. |
required |
default
|
Optional[str]
|
The default value to return if the key is not in the dictionary or the environment. Defaults to None. |
None
|
Source code in rm_gallery/core/model/base.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|