Documentation
¶
Overview ¶
Package tokenizer provides a DataProducer plugin that tokenizes the request prompt and publishes the result on InferenceRequestBody.TokenizedPrompt for downstream consumers (scorers, filters, other data producers).
Index ¶
- Constants
- Variables
- func CacheSaltFromBody(body *fwkrh.InferenceRequestBody) string
- func ChatCompletionsToRenderChatRequest(chat *fwkrh.ChatCompletionsRequest) *tokenizerTypes.RenderChatRequest
- func ConvertMMFeaturesFromUpstream(features []fwkrh.MultiModalFeature) (map[string][]string, map[string][]kvblock.PlaceholderRange)
- func LegacyPluginFactory(name string, rawParameters *json.Decoder, handle plugin.Handle) (plugin.Plugin, error)deprecated
- func PluginFactory(name string, rawParameters *json.Decoder, handle plugin.Handle) (plugin.Plugin, error)
- type Plugin
Constants ¶
const ( // PluginType is the canonical type name used to register the plugin. PluginType = "token-producer" // LegacyPluginType is the previous type name. Existing YAML configs that // reference it continue to work. Will be removed in a future release. // // Deprecated: use PluginType ("token-producer") instead. LegacyPluginType = "tokenizer" )
Variables ¶
var TokenizedPromptDataKey = plugin.NewDataKey(tokenizedPromptKeyID, PluginType)
Functions ¶
func CacheSaltFromBody ¶
func CacheSaltFromBody(body *fwkrh.InferenceRequestBody) string
CacheSaltFromBody returns the cache salt from whichever protocol is populated. The protocol switch lives here so producers populate TokenizedPrompt.CacheSalt from one place and consumers read only that field.
func ChatCompletionsToRenderChatRequest ¶
func ChatCompletionsToRenderChatRequest(chat *fwkrh.ChatCompletionsRequest) *tokenizerTypes.RenderChatRequest
ChatCompletionsToRenderChatRequest converts a ChatCompletionsRequest to a tokenization RenderChatRequest, including multimodal content blocks.
func ConvertMMFeaturesFromUpstream ¶
func ConvertMMFeaturesFromUpstream(features []fwkrh.MultiModalFeature) (map[string][]string, map[string][]kvblock.PlaceholderRange)
ConvertMMFeaturesFromUpstream regroups the flat list of multimodal features back into the kv-cache map-shape expected by kvblock.ComputeBlockExtraFeatures.
func LegacyPluginFactory
deprecated
func LegacyPluginFactory(name string, rawParameters *json.Decoder, handle plugin.Handle) (plugin.Plugin, error)
LegacyPluginFactory wraps PluginFactory for the deprecated `tokenizer` type name. It logs a one-time-per-instantiation deprecation warning and delegates to PluginFactory. Will be removed when LegacyPluginType is removed.
Deprecated: register PluginType ("token-producer") instead.
Types ¶
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin tokenizes the prompt in the incoming request and writes the result to InferenceRequestBody.TokenizedPrompt for downstream DataProducer / scoring plugins.
func NewPlugin ¶
NewPlugin constructs the configured backend: udsTokenizerConfig (deprecated), vllm /render (selected by 'vllm' or 'modelName'), or estimate byte-packing (the default when no backend is set).
func (*Plugin) Produce ¶
func (p *Plugin) Produce(ctx context.Context, request *scheduling.InferenceRequest, _ []scheduling.Endpoint) error
Produce derives the request's TokenizedPrompt via the configured backend and stores it on the body. Skips when one is already present; errors propagate to the Director, which logs and continues.
func (*Plugin) ProduceTimeout ¶
ProduceTimeout surfaces the backend's render timeout when it manages one, so the director extends the data-producer budget past its default. Returns 0 to keep the default (e.g. the estimate backend, which is in-memory).