Skip to main content

STACKITChatGenerator

Generate text using STACKIT generative models through their model serving service.

Basic Information

  • Type: haystack_integrations.components.generators.stackit.chat.chat_generator.STACKITChatGenerator
  • Components it can connect with:
    • ChatPromptBuilder: STACKITChatGenerator receives a rendered prompt from ChatPromptBuilder.
    • DeepsetAnswerBuilder: STACKITChatGenerator sends the generated replies to DeepsetAnswerBuilder through OutputAdapter.

Inputs

ParameterTypeDefaultDescription
messagesList[ChatMessage]A list of ChatMessage instances representing the input messages.
streaming_callbackOptional[StreamingCallbackT]NoneA callback function that is called when a new token is received from the stream.
generation_kwargsOptional[Dict[str, Any]]NoneAdditional keyword arguments for text generation. These parameters override the parameters in pipeline configuration. For a list of supported parameters, see STACKIT documentation.
toolsOptional[Union[List[Tool], Toolset]]NoneA list of tools or a Toolset for which the model can prepare calls. If set, it overrides the tools parameter in pipeline configuration. This parameter can accept either a list of Tool objects or a Toolset instance.
tools_strictOptional[bool]NoneWhether to enable strict schema adherence for tool calls. If set to True, the model follows exactly the schema provided in the parameters field of the tool definition, but this may increase latency. If set, it overrides the tools_strict parameter in pipeline configuration.

Outputs

ParameterTypeDefaultDescription
repliesList[ChatMessage]A list containing the generated responses as ChatMessage instances.

Overview

Use STACKITChatGenerator to generate text using models through STACKIT API. For a list of supported models, see STACKIT documentation.

Authorization

You need an STACKIT API key to use this component. Connect deepset to your STACKIT account by creating a secret called STACKIT_API_KEY. For more information about secrets, see Secrets.

Usage Example

Initializing the Component

components:
STACKITChatGenerator:
type: haystack_integrations.components.generators.stackit.chat.chat_generator.STACKITChatGenerator
init_parameters:

Parameters

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
modelstrThe name of the chat completion model to use.
api_keySecretSecret.from_env_var('STACKIT_API_KEY')The STACKIT API key.
streaming_callbackOptional[StreamingCallbackT]NoneA callback function that is called when a new token is received from the stream. The callback function accepts StreamingChunk as an argument.
api_base_urlOptional[str]https://api.openai-compat.model-serving.eu01.onstackit.cloud/v1The STACKIT API Base url.
generation_kwargsOptional[Dict[str, Any]]NoneOther parameters to use for the model. These parameters are all sent directly to the STACKIT endpoint. Some of the supported parameters: - max_tokens: The maximum number of tokens the output text can have. - temperature: What sampling temperature to use. Higher values mean the model will take more risks. Try 0.9 for more creative applications and 0 (argmax sampling) for ones with a well-defined answer. - top_p: An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - stream: Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. - safe_prompt: Whether to inject a safety prompt before all conversations. - random_seed: The seed to use for random sampling.
timeoutOptional[float]NoneTimeout for STACKIT client calls. If not set, it defaults to either the OPENAI_TIMEOUT environment variable, or 30 seconds.
max_retriesOptional[int]NoneMaximum number of retries to contact STACKIT after an internal error. If not set, it defaults to either the OPENAI_MAX_RETRIES environment variable, or set to 5.
http_client_kwargsOptional[Dict[str, Any]]NoneA dictionary of keyword arguments to configure a custom httpx.Clientor httpx.AsyncClient. For more information, see the HTTPX documentation.

Run Method Parameters

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
messagesList[ChatMessage]A list of ChatMessage instances representing the input messages.
streaming_callbackOptional[StreamingCallbackT]NoneA callback function that is called when a new token is received from the stream.
generation_kwargsOptional[Dict[str, Any]]NoneAdditional keyword arguments for text generation. These parameters override the parameters in pipeline configuration. For a list of supported parameters, see STACKIT documentation.
toolsOptional[Union[List[Tool], Toolset]]NoneA list of tools or a Toolset for which the model can prepare calls. If set, it overrides the tools parameter in pipeline configuration. This parameter can accept either a list of Tool objects or a Toolset instance.
tools_strictOptional[bool]NoneWhether to enable strict schema adherence for tool calls. If set to True, the model follows exactly the schema provided in the parameters field of the tool definition, but this may increase latency. If set, it overrides the tools_strict parameter in pipeline configuration.