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

Method _text_tool_arguments

examples/server/server.py:5333–5361  ·  view source on GitHub ↗
(
        self,
        tool_name: str,
        arguments: Any,
        *,
        partial: bool,
    )

Source from the content-addressed store, hash-verified

5331 return None
5332
5333 def _text_tool_arguments(
5334 self,
5335 tool_name: str,
5336 arguments: Any,
5337 *,
5338 partial: bool,
5339 ) -> Optional[str]:
5340 if isinstance(arguments, str):
5341 parsed_arguments = self._raw_object_tool_arguments(arguments)
5342 if parsed_arguments is not None:
5343 text = self._text_tool_argument_from_object(tool_name, parsed_arguments)
5344 if text is not None:
5345 return text
5346 if partial:
5347 return None
5348 return json.dumps(parsed_arguments, ensure_ascii=False, separators=(",", ":"))
5349 return arguments
5350 if isinstance(arguments, ResponseParser.PartialJsonObject):
5351 arguments = arguments.value
5352 if isinstance(arguments, dict):
5353 text = self._text_tool_argument_from_object(tool_name, arguments)
5354 if text is not None:
5355 return text
5356 if partial:
5357 return None
5358 return json.dumps(arguments, ensure_ascii=False, separators=(",", ":"))
5359 if partial:
5360 return None
5361 return str(arguments)
5362
5363 @classmethod
5364 def _raw_object_tool_arguments(cls, value: str) -> Optional[Dict[str, Any]]:

Callers 2

_parsed_chat_messageMethod · 0.95

Tested by

no test coverage detected