tryParseArguments

fun tryParseArguments(tools: List<Tool>? = null): Map<String, JsonNode>

Attempts to parse the arguments passed to the function.

If there is a mistake in the JSON provided by ChatGPT, this method will throw a HallucinationException. You should catch this exception and return the error provided by HallucinationException.jsonDumps. After you reply to ChatGPT with the error, it may attempt to fix its mistake, or simply continue on without using the tool.

When using com.cjcrafter.openai.OpenAI.streamChatCompletion, you should wait until the stream is closed before calling this method. You can check this by checking the com.cjcrafter.openai.chat.ChatChoiceChunk.isFinished.

Return

The parsed arguments.

Parameters

tools

The list of tools that ChatGPT has access to, or null to skip advanced checking.