diff options
| author | Ethan Werner <mail@ethanwerner.com> | 2026-10-10 20:55:33 +0000 |
|---|---|---|
| committer | Ethan Werner <mail@ethanwerner.com> | 2026-10-10 20:56:50 +0000 |
| commit | f8423ebea413605b42de23f5dd06c5479d3fa1dd (patch) | |
| tree | 2612a5eb026c59e7aae01f10a1cf62f2ee43042c /src/provider.h | |
Diffstat (limited to 'src/provider.h')
| -rw-r--r-- | src/provider.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/provider.h b/src/provider.h new file mode 100644 index 0000000..ae60896 --- /dev/null +++ b/src/provider.h @@ -0,0 +1,41 @@ +#ifndef LLSH_PROVIDER_H +#define LLSH_PROVIDER_H + +#include <stdbool.h> + +#include "llm.h" +#include "mcp.h" +#include "session.h" + +/* The session-bound provider layer: implements the `llsh_model` vtable on + * top of llm.h's protocol layer, wiring in the session (config, preamble, + * allowed tools, .agents), the built-in + MCP tool registry, and the + * session's emit callback. */ + +/* Which one-shot role this model serves. `complete` uses the matching + * preamble; `stream` (the agent turn) always uses the session preamble. */ +typedef enum { + PROV_ROLE_MAIN = 0, + PROV_ROLE_SUMMARIZER, + PROV_ROLE_EVALUATOR, + PROV_ROLE_RUBRIC, +} provider_role; + +/* Create a session-bound model. `sess` may be NULL until + * provider_model_attach; `mcp` may be NULL (no MCP tools). */ +llsh_model *provider_model_new(session *sess, mcp_registry *mcp, + provider_role role); +void provider_model_attach(llsh_model *m, session *sess); + +/* Test hook: build the request body (without sending) for the session's + * current config, preamble, and tool set, for a single one-shot prompt. + * Caller frees the returned string. */ +char *provider_preview_request(session *sess, const char *prompt, + bool with_tools); + +/* On stop, an assistant message can carry more tool calls than the + * tool-result messages that follow it (we stopped mid-loop). Trim the + * surplus calls so the committed history stays a valid request. */ +void provider_trim_dangling_calls(message *msgs, size_t n); + +#endif /* LLSH_PROVIDER_H */ |