arguments As Json Or Null
Parses FunctionResponse.arguments into a JsonObject, or returns null when the model produced no arguments, malformed JSON, or a JSON value that is not an object.
Example:
val call = response.choices.first().message.toolCalls?.first()
val city = call?.function?.argumentsAsJsonOrNull()
?.get("city")?.jsonPrimitive?.contentContent copied to clipboard
Return
The parsed arguments, or null if they are absent or not a valid JSON object.
Parameters
json
Json instance used for parsing; the default is sufficient for plain argument objects.