web-llm icon indicating copy to clipboard operation
web-llm copied to clipboard

Add Hermes-2-Pro function calling example with JSON schema

Open rickzx opened this issue 9 months ago • 0 comments

This PR adds a function calling example with JSON schema, using Hermes-2-Pro-Mistral-7B model.

The system prompt is adapted from: https://github.com/NousResearch/Hermes-Function-Calling/blob/main/prompt_assets/sys_prompt.yml#L29

Query:

What is the current weather in celsius in Pittsburgh and Tokyo?

Output JSON schema:

const T = Type.Object({
  tool_calls: Type.Array(
    Type.Object({
      arguments: Type.Any(),
      name: Type.String(),
    })
  )
});

Generated output:

{"tool_calls": [{"arguments": {"location": "Pittsburgh, PA", "unit": "celsius"}, "name": "get_current_weather"}, {"arguments": {"location": "Tokyo, Japan", "unit": "celsius"}, "name": "get_current_weather"}]}

rickzx avatar May 08 '24 23:05 rickzx