class documentation
class TemporalModel(BaseLlm): (source)
Constructor: TemporalModel(model_name, activity_config, summary_fn)
A Temporal-based LLM model that executes model invocations as activities.
| Method | __init__ |
Initialize the TemporalModel. |
| Async Method | generate |
Generate content asynchronously by executing model invocation as a Temporal activity. |
| Instance Variable | _activity |
Undocumented |
| Instance Variable | _model |
Undocumented |
| Instance Variable | _summary |
Undocumented |
def __init__(self, model_name:
str, activity_config: ActivityConfig | None = None, *, summary_fn: Callable[ [ LlmRequest], str | None] | None = None):
(source)
¶
Initialize the TemporalModel.
| Parameters | |
modelstr | The name of the model to use. |
activityActivityConfig | None | Configuration options for the activity execution. |
summaryCallable[ | Optional callable that receives the LlmRequest and returns a summary string (or None) for the activity. Must be deterministic as it is called during workflow execution. If the callable raises, the exception will propagate and fail the workflow task. |
| Raises | |
ValueError | If both ActivityConfig["summary"] and summary_fn are set. |
async def generate_content_async(self, llm_request:
LlmRequest, stream: bool = False) -> AsyncGenerator[ LlmResponse, None]:
(source)
¶
Generate content asynchronously by executing model invocation as a Temporal activity.
| Parameters | |
llmLlmRequest | The LLM request containing model parameters and content. |
stream:bool | Whether to stream the response (currently ignored). |
| Returns | |
AsyncGenerator[ | Undocumented |
| Yields | |
| The responses from the model. |