Skip to content

Using tool calls sometimes results in JSON.parse errors. #686

@nhhynd

Description

@nhhynd

Description

Normal response

"```[{"name": "brightness", "arguments": {"targetBrightness": 100}}]```"

Wrong response

"```[{"name": "brightness", "arguments": {"targetBrightness": 100}}]``````[]```"
[React Native ExecuTorch] SyntaxError: JSON Parse error: Unexpected character: `
    at parse (native)
    at parseToolCall (llm.ts:17:48)
    at ?anon_0_ (LLMController.ts:280:36)
    at next (native)
    at asyncGeneratorStep (asyncToGenerator.js:3:17)
    at _next (asyncToGenerator.js:17:27)
    at tryCallOne (address at InternalBytecode.js:1:1180)
    at anonymous (address at InternalBytecode.js:1:1874)

Steps to reproduce

  1. Set get_weather and brightness in TOOL_DEFINITIONS.
  2. Request the weather and then change the brightness.
  3. Receive malformed JSON.

Snack or a link to a repository

No response

React Native Executorch version

0.5.15

React Native version

0.82.1

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native

Architecture

Fabric (New Architecture)

Build type

Debug mode

Device

Real device

Device model

Samsung Galaxy 24 ultra (Android 15)

AI model

HAMMER2_1_1_5B

Performance logs

No response

Acknowledgements

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    modelIssues related to exporting, improving, fixing ML models

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions