web-llm
web-llm copied to clipboard
Add Hermes-2-Pro function calling example with JSON schema
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"}]}