Skip to content

0.15.0

Choose a tag to compare

@decitre decitre released this 27 Nov 09:13
· 19 commits to main since this release

Tool calling, a camera and microphone that Python can ask for, and a WebGPU that falls back to WASM instead of failing. The embedding and classification options of LLM that 0.14.0 deprecated are removed.

Upgrading

  • LLM no longer embeds or classifies. LLM.create(embedding_model=...) and LLM.create(classification_model=...) now raise a TypeError, and llm.embed(), llm.classify() and llm.similarity_search() are gone. Use Embedder.create(model) and Classifier.create(model); the 0.14.0 release notes show the one-for-one replacement. A model that was loaded together with a generator is now a second object with its own dispose().
  • Notebooks are renumbered again, to go from language models to pipelines to low-level material. Old notebook URLs (?path=ch17_streaming.ipynb and the others) no longer exist. The new order is: 01 to 05 unchanged; 06 tool calling, 07 streaming, 08 token probabilities; 09 embeddings, 10 classification, 11 orchestration; 12 tasks, 13 vision, 14 image outputs, 15 camera, 16 speech, 17 microphone; 18 tokenizers, 19 ONNX models, 20 text to image, 21 WebGPU; ch99 is unchanged.

New

  • WebGPU falls back to WASM. With backend="webgpu", a browser with no WebGPU adapter, or a failure that is specific to WebGPU (a lost device, a shader or buffer limit, an operator or float16 the adapter lacks), now loads the model on WASM once and says why. llm.backend (and Embedder, Classifier, Pipeline, OnnxModel) report the backend that ran, and backend_fallback_reason says why it changed. Out-of-memory and fetch errors are not retried, since WASM would hit them too. Pass backend_fallback=False to fail instead. The default backend is still "wasm". Failures are recognised by their wording, so a runtime message outside the pattern is raised, not retried; software adapters are not detected. See #111 and "WebGPU fallback" in the parameters reference.
  • ToolRunner: validated tool calling (ToolRunner, Tool, AgentResult, model_tool). A model replies with a JSON tool call or an answer; the tool name and arguments are checked against the registered tools and their schemas before anything runs, so an unknown tool or invalid arguments never execute. The refusal goes back to the model and uses a step. The loop stops on an answer, the step limit, a timeout or a cancel, and AgentResult.steps records every reply and its outcome. After a tool has run, a reply with no JSON object in it is the answer. See #77.
  • A tool-calling notebook, ch06_tool-calling. It runs Qwen2.5-0.5B-Instruct (q4, about 790 MB) through ToolRunner on WebGPU when the browser has a hardware adapter, on WASM otherwise, and shows with a scripted model what happens to an unknown tool, invalid arguments, non-JSON and the step limit. The model is small: in the measurements behind the notebook it chose the right tool for 5 of 8 questions, so treat that run as a demonstration.
  • CameraCapture.request() and AudioRecorder.request() show a prompt in the widget and wait for the user to tap before capturing, so Python can ask for a photo or a recording. A request resolves only with media captured for it, and raises CaptureCancelled on Cancel, TimeoutError on a timeout, and the browser's error when the camera or microphone is refused. Every ending releases the device. See #78.

Changed

  • A failed fetch is reported as a fetch. A load error of Load failed (Safari), Failed to fetch (Chrome) or NetworkError (Firefox) used to get the advice that the model may not be supported by the backend. It now says a file could not be fetched and how to find which one, and suggests the other backend only after a WebGPU failure. See #109.
  • ch20 (text to image) and ch21 (WebGPU) pass backend_fallback=False, so they cannot run on WASM without saying so.
  • The two Voici apps (camera-objects, speak-french) ask for backend="webgpu" instead of "wasm", and run on WASM where WebGPU is missing or fails to load. Only the fallback path was run, in headless Chromium without a GPU (voici-smoke); they were not run on a real GPU or a phone.

Fixed

  • A tool call that was cut off or malformed ended a ToolRunner run. After a tool ran, a reply that json.loads rejected, such as a call cut off at the token limit or with a trailing comma, became the final answer. A reply is now prose only when it has no opening brace; anything that looks like JSON but does not parse goes back to the model. See #108.

Docs

  • Running a static embedding model (POTION) with OnnxModel and tokenizer() is documented in the ONNX guide (#94).

Notes

  • Only the WebGPU fallback in the no-adapter case was run in a real browser (headless Chromium, backend-fallback-smoke), plus ch21 on an Apple GPU. A WebGPU failure after a successful adapter check is covered by tests with mocks, not a real browser.
  • ch20 and ch06 were not re-run in a browser with these changes.
  • Real Safari is still untested.
  • Making WebGPU the default backend is tracked in #114.