Files
marqdo/ext/ai/llm/index.mq.md
T
cflmy 9331af78e2 release(2.8.0): 合入 CHANGELOG/README/发版说明/skills prove 任务;CI 链接指向 doc/releases
- CHANGELOG.md:v2.8.0 条目(中英双语);
- README.md:版本行 2.7.1→2.8.0 + 愿景第 6 条(知识可证明);
- doc/releases/v2.8.0.md:双语发版说明(亮点/用法/已知限制);
- skills/marqdo-dev/index.mq.md:新增 prove 任务(路径/目录模式/
  require_lean/json;参数用 + 行声明升参,check 与 narrative-ratio 通过);
- 设计文档 §12.5 标记已合入;发版链接统一指向 doc/releases/v2.8.0.md。
2026-11-18 10:29:26 +08:00

2.9 KiB
Executable File

markup, title, import
markup title import
occlusion Provider adapters — requests, configuration and usage
ollama openai
ext/ai/llm/ollama.mq.md ext/ai/llm/openai.mq.md

This directory owns provider adaptation. OpenAI-compatible requests encode chat messages, decode replies and usage, and retain streaming/error conventions. Ollama selects its documented local defaults while reusing compatible transport. The parent model API creates author model resources; the AI root explains agent and trial responsibilities.

This offline usage example inspects response data only. It does not read credentials, load a plugin or contact the provider:

marqdo call ext/ai/llm/index.mq.md usage 'data={"usage":{"prompt_tokens":2,"completion_tokens":3,"total_tokens":5}}' --json

For local configuration, resolve_local reads the documented environment fallbacks and therefore needs environment.read. Sending chat_completions is a real HTTP effect and requires an explicitly configured endpoint, timeout and credential handling. Do not print a live configuration record containing secrets merely to prove that an adapter exists.

When adding a provider, preserve semantic message/event/result shapes at the public model boundary. Keep provider-specific headers and endpoint paths in the adapter, document supported response variants and test them against local fixtures before live traffic. A usage fixture does not verify provider availability, streaming latency or authentication.

usage

参数 类型 默认 说明
data map required Already received OpenAI-compatible response record
返回 类型 说明
result any Public prompt_tokens/completion_tokens/total_tokens usage projection

The data record is an observation rather than a request body. Missing counters follow the public adapter convention; the example above contains two input tokens, three output tokens and five total tokens. We return Read actual usage counters from the supplied response without claiming to have measured a new model invocation.

resolve_local

参数 类型 默认 说明
model any None Explicit local model override; None uses the adapter fallback
base_url any None Explicit local API base URL; None uses the documented environment/default
返回 类型 说明
result any Actual Ollama configuration selected by the existing resolver

The caller may supply model=None and base_url=None to use the shared local configuration rules. Resolving the configuration does not launch a service or ask the model for a response. We return [Resolve local model fields with the existing adapter](ollama.resolve(model=model, base_url=base_url)). Treat the resulting configuration as runtime data and only execute a request after granting its effects.