(
self,
schema: Dict[str, Any],
*,
tools: Optional[List[ChatTemplateTool]] = None,
completion_id: str = "",
choice_index: int = 0,
generation_prompt: str = "",
)
| 4396 | ITEM_MODE_DONE = 5 |
| 4397 | |
| 4398 | def __init__( |
| 4399 | self, |
| 4400 | schema: Dict[str, Any], |
| 4401 | *, |
| 4402 | tools: Optional[List[ChatTemplateTool]] = None, |
| 4403 | completion_id: str = "", |
| 4404 | choice_index: int = 0, |
| 4405 | generation_prompt: str = "", |
| 4406 | ) -> None: |
| 4407 | self._schema = schema |
| 4408 | self._tools = tools |
| 4409 | self._completion_id = completion_id |
| 4410 | self._choice_index = choice_index |
| 4411 | self._generation_prompt = generation_prompt |
| 4412 | self._tool_schemas = self._cached_tool_schema_map(tools) |
| 4413 | self._started = False |
| 4414 | self._text_parts: List[str] = [] |
| 4415 | self._message: Dict[str, Any] = {} |
| 4416 | self._stream_plan = self._cached_stream_plan(schema) |
| 4417 | self._direct = ResponseParser.DirectState( |
| 4418 | deltas=bool(self._stream_plan is not None and self._stream_plan.get("direct_deltas")), |
| 4419 | pending="", |
| 4420 | mode=self.DIRECT_MODE_PRELUDE, |
| 4421 | done=False, |
| 4422 | saw_tool_calls=False, |
| 4423 | tool_call_count=0, |
| 4424 | assistant_prefix="", |
| 4425 | leading_capture_field=None, |
| 4426 | leading_capture_start="", |
| 4427 | leading_capture_end="", |
| 4428 | leading_capture_strip_after=False, |
| 4429 | leading_capture_implicit=False, |
| 4430 | content_end_markers=(), |
| 4431 | trim_before_iterator=False, |
| 4432 | iterator_start="", |
| 4433 | iterator_end="", |
| 4434 | stop_markers=(), |
| 4435 | function_start="", |
| 4436 | function_name_end="", |
| 4437 | function_end="", |
| 4438 | parameter_start="", |
| 4439 | parameter_name_end="", |
| 4440 | parameter_end="", |
| 4441 | ) |
| 4442 | self._item = ResponseParser.ItemState( |
| 4443 | pending="", |
| 4444 | mode=self.ITEM_MODE_FUNCTION_HEADER, |
| 4445 | tool_call_index=0, |
| 4446 | tool_name="", |
| 4447 | parameter_count=0, |
| 4448 | visible_tool_call=None, |
| 4449 | visible_function=None, |
| 4450 | current_parameter=None, |
| 4451 | current_parameter_value="", |
| 4452 | current_schema_type=None, |
| 4453 | current_parameter_schema={}, |
| 4454 | ) |
| 4455 | if self._direct.deltas and self._stream_plan is not None: |
nothing calls this directly
no test coverage detected