MCPcopy Index your code
hub / github.com/abetlen/llama-cpp-python / _stream_state_message

Method _stream_state_message

examples/server/server.py:7533–7560  ·  view source on GitHub ↗
(self, *, partial: bool)

Source from the content-addressed store, hash-verified

7531 return self._parsed_chat_message(parsed=parsed)
7532
7533 def _stream_state_message(self, *, partial: bool) -> Dict[str, Any]:
7534 assert self._stream_state is not None
7535 if self._stream_plan is not None and self._stream_plan.get("direct_deltas"):
7536 copied = {
7537 key: (
7538 [
7539 {
7540 child_key: (
7541 dict(child_value)
7542 if isinstance(child_value, dict)
7543 else child_value
7544 )
7545 for child_key, child_value in tool_call.items()
7546 }
7547 for tool_call in cast(List[Dict[str, Any]], value)
7548 ]
7549 if key == "tool_calls" and isinstance(value, list)
7550 else value
7551 )
7552 for key, value in self._message.items()
7553 }
7554 if copied.get("tool_calls"):
7555 copied["function_call"] = dict(
7556 cast(List[Dict[str, Any]], copied["tool_calls"])[0]["function"]
7557 )
7558 return copied
7559 parsed = cast(Dict[str, Any], self._stream_state.parsed)
7560 return self._parsed_chat_message(parsed=parsed, partial=partial)
7561
7562 def _stream_state_complete(self) -> bool:
7563 if self._stream_plan is None:

Callers

nothing calls this directly

Calls 1

_parsed_chat_messageMethod · 0.95

Tested by

no test coverage detected