jac-by-llm

Delegates Jac function bodies to LLM calls with typed structured outputs.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/PMN123/trapdoor --skill jac-by-llm-pmn123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jac-by-llm
Source: https://github.com/PMN123/trapdoor/tree/main/.agents/skills/jac-by-llm
Command: npx skills add https://github.com/PMN123/trapdoor --skill jac-by-llm-pmn123

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing LLM-powered functions in Jac requires wiring prompts, parsing free-form model output into typed values, configuring providers, and testing without API keys. This Skill documents the by llm(...) syntax that replaces a function body with an LLM call returning typed objects, enums, or lists. ## Core Features & Use Cases - Structured Outputs: Return typed objs, enums, lists, and optional values directly from LLM calls, with sem statements serving as the prompt schema. - Tool Use & ReAct Agents: Pass function references via tools=[...] to enable automatic ReAct loops, including bound object methods as tools. - Provider Configuration: Configure OpenAI, Anthropic, Google, Ollama, or built-in local models via Model, jac.toml, or environment variables. - MockLLM Testing: Test LLM functions without API keys using sequential mock outputs. - Use Case: Build a ticket classifier that returns a typed Priority enum, or a ReAct agent that answers questions by calling a word_count tool, all testable offline with MockLLM. ## Quick Start Show me how to write a Jac function that summarizes text into a structured object using by llm with sem descriptions.

Frequently Asked Questions about jac-by-llm

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make an LLM return structured output in Jac?

Declare a function with a typed return annotation and replace its body with `by llm(...)`. Define the return type as an `obj`, enum, or list, and describe every field with `sem` statements, which form the prompt schema the LLM sees.

How do I give an LLM function tools in Jac?

Pass function references in the `tools=[...]` option of `by llm`, which automatically enables the ReAct loop. Each tool needs its own `sem` and per-argument `sem` so the LLM knows when to call it; bound object methods also work as tools.

Which model providers does Jac byLLM support?

byLLM supports OpenAI, Anthropic, Google, Ollama, and built-in local models. Configure them via a `Model` glob, `jac.toml` under `[byllm.model]`, or environment variables like `OPENAI_API_KEY` and `BYLLM_DEFAULT_MODEL`.

How do I test Jac LLM functions without API keys?

Use MockLLM from `jaclang.byllm.lib` with a `config` containing an `outputs` list. Mock outputs are consumed sequentially, one per `by` call, and typed returns accept pre-built instances like enum members or object lists.

Why does my inline by llm expression fail at runtime?

Inline expressions like `x = "prompt" by llm;` are not supported and raise `NotImplementedError` at runtime despite passing `jac check`. Always declare a named function with `by llm(...)` and call it instead.

Can Jac by llm process images and video?

Yes, using the `Image` and `Video` types from `jaclang.byllm.lib` as function parameters with a vision-capable model. Image accepts file paths, URLs, bytes, and PIL images; Video requires the `byllm[video]` extra and an fps sampling rate.