Functions
FUNC sentence_delimiter
tag: Tag string prefix, e.g."i"or"c".sentence_num: Zero-based index of the sentence.
- Tag string (including trailing space) that identifies the beginning of
- the indicated sentence in sentence-tagged text.
FUNC mark_sentence_boundaries
<[prefix][number]>
at the location of each sentence boundary.
Args:
split_strings: Input string(s), pre-split into sentences.tag_prefix: String to place before the number part of each tagged sentence boundary.
- List of input strings with all sentence boundaries marked.
FUNC move_documents_to_message
chat_completion: A chat completion request as dataclass or parsed JSON.how: How to serialize the documents; supported values are"string","json", and"roles".
- A copy of
chat_completionwith any documents underextra_body - moved to the first message. Returned type will be the same as the input type.
- May return original object if no edits are necessary.
TypeError: Ifchat_completionis not a :class:ChatCompletionordict.ValueError: Ifhowis not one of"string","json", or"roles".
Classes
CLASS IntrinsicsRewriter
General-purpose chat completion rewriter for intrinsics.
General-purpose chat completion rewriter for use with models that implement
LLM intrinsics. Reads parameters of the model’s input and output formats
from a YAML configuration file and edits the input chat completion appropriately.
Args:
config_file: Path to the YAML configuration file for the target intrinsic. Mutually exclusive withconfig_dict.config_dict: Inline configuration dictionary. Mutually exclusive withconfig_file.model_name: Optional model name used to locate model-specific overrides within the configuration.
config: Parsed YAML configuration file for the target intrinsic.response_format: JSON Schema of the expected response format.parameters: Additional parameters (key-value pairs) that this rewriter adds to all chat completion requests.extra_body_parameters: Extended vLLM-specific parameters that go under theextra_bodyelement of each request. These are merged with any existingextra_bodycontent in incoming requests.instruction: Optional instruction template. When present, a new user message is appended with the formatted instruction.sentence_boundaries: Optional sentence-boundary marking specification, mapping location strings ("last_message"or"documents") to marker prefixes (e.g."c"produces<c0>,<c1>, …).docs_as_message: Optional specification for moving documents fromextra_body/documentsto a user message at the start of the messages list. Value must be"string","json", or"roles".