Files
wehub-resource-sync f73e710e38
Build site and push to gh-pages / Build site (push) Waiting to run
Build / build (push) Waiting to run
Linter / lint (push) Waiting to run
Security / dependency-review (push) Waiting to run
Security / npm-audit (push) Waiting to run
Security / codeql (push) Waiting to run
Tests / test (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 12:42:51 +08:00
..

OpenAI API Demos - Function calling

This folder contains two main ways of using function calling with WebLLM.

function-calling-manual demonstrates how you can use function calling with Llama3.1 and Hermes2 without using the tools, tool_choice, and tool_call fields. This is the most flexible way and you can follow the instruction given by the model releaser and iterate yourself on top of that. However, you need to do parsing on your own, which differs for each model. For instance, Hermes2 models use <tool_call> and </tool_call> to wrap around a tool call, which may be very different from other models' format.

function-calling-openai conforms to the OpenAI function calling usage, leveraging tools, tool_choice, and tool_call fields. This is more usable, but sacrifices the flexibility since we have pre-defined system prompt for this.