Pro 9879 ai reference - #567
Conversation
| |---|---|---| | ||
| | `low` | `gemini-3.1-flash-lite` | — | | ||
| | `medium` | `gemini-3.5-flash` | — | | ||
| | `high` | `gemini-3.5-flash` | `high` | |
There was a problem hiding this comment.
I now realize we don't use Gemini Pro. But I guess is OK as a start. I didn't spent too much time on Gemini.
There was a problem hiding this comment.
There isn't a Pro text encoder. I also noticed that 3.5 is a little stale. There is a 3.5-flash-lite now also.
|
|
||
| **For OpenAI proper, prefer `openai`.** It speaks OpenAI's first-class Responses API and supports `reasoning` alongside `tools`. | ||
|
|
||
| [`openai-compatible`](/reference/modules/ai-adapter-openai-compatible.md) speaks Chat Completions, the de facto wire standard of the whole ecosystem — that is what makes it the universal adapter. It works against `api.openai.com` too, but there a `tools` request drops `reasoning`, because the service rejects the combination in that dialect. Aliased entries describe other services, which accept it, and pass through untouched. |
There was a problem hiding this comment.
but there a toolsrequest dropsreasoning`` - this sounds odd, do we need the there part?
There was a problem hiding this comment.
Clarified and language cleaned up.
myovchev
left a comment
There was a problem hiding this comment.
This was a long read (!) but I think overall is very clear and helpful. I spotted some minor problems. Some of my comments are only "thinking loud" stuff.
| } | ||
| } | ||
| }, | ||
| 'my-module': {} |
There was a problem hiding this comment.
Avoid using my-xxx, this is reserved apostrophe thing and can behave in unexpected ways.
| | `pending` | `'refuse'` \| `'execute'` | What to do with a transcript ending in unanswered tool calls. See [Suspension](#suspension-asking-the-user-mid-run). | | ||
| | `toolInput` | object | Answers for suspended tool calls, keyed by tool call id. Requires `pending: 'execute'`. | | ||
| | `schema` | object | JSON Schema (object root) for structured output. | | ||
| | `effort` | string | The routing level to resolve. Defaults to `effort.default`. | |
There was a problem hiding this comment.
Defaults to the value of `effort.default`
| { type: 'image', image: { url: 'https://example.com/photo.jpg' } } | ||
| ] | ||
| } | ||
| ] |
There was a problem hiding this comment.
Here the dev should also see the assistant entry (between the user queries), leaving them out is confusing.
| | text | `{ type: 'text', text }` | `user`, `assistant` | | ||
| | image | `{ type: 'image', image: { url } }` or `{ type: 'image', image: { data, mediaType } }` | `user`, `assistant` | | ||
| | tool call | `{ type: 'toolCall', id, name, input }` | `assistant` | | ||
| | tool result | `{ type: 'toolResult', toolCallId, output }` or `{ …, error }` | `tool` | |
There was a problem hiding this comment.
The table explains entries that are NOT in the example above
There was a problem hiding this comment.
Updated and clarified.
| // } | ||
| ``` | ||
|
|
||
| `active` answers "is AI usable"; `modelCatalog` answers "what is configured". Under mock mode with no providers, `active` is `true` and the catalog is empty. |
There was a problem hiding this comment.
We have (probably forgot to document it) apos.ai.mockMode boolean as well, so it's possible to check that too.
There was a problem hiding this comment.
apos.ai.mockmode is documented, but worth adding here. (see lines 523 and 1539)
|
|
||
| ### `can(req, action, docOrType, [mode])` | ||
|
|
||
| The AI permission seam. Same signature and semantics as `apos.permission.can` — see [Permissions and workflow](/guide/permissions-and-workflow.md) — but it is **not** a plain proxy: it applies AI-specific policy first, and can only ever be as restrictive as `apos.permission.can`, never looser. |
There was a problem hiding this comment.
Meant to be used with tools or anything AI executed on behalf of the current user - probably worth mentioning.
There was a problem hiding this comment.
Clarified and updated.
|
|
||
| ## Tools | ||
|
|
||
| Tools are how a model does things: read content, search, write a draft, publish. The engine owns the loop; you own the handlers. |
There was a problem hiding this comment.
Do not mention publish here - it's not clear the approach we take in the future.
There was a problem hiding this comment.
Removed here and several other places.
|
|
||
| `input` is a JSON Schema describing the arguments the model may pass. This tool takes none, so `{ type: 'object' }` — an object with nothing in it — is the whole schema. The handler returns an object, and that object is what the model reads. | ||
|
|
||
| `kind: 'query'` says the tool only reads. Queries the model asks for together run in parallel; without it a tool defaults to `'action'` and runs serially, one after another. Tag your read-only tools and a model that asks for six of them at once gets its answer in the time of the slowest, not the sum. See [Kinds and scheduling](#kinds-and-scheduling). |
There was a problem hiding this comment.
We never state what is the return type requirements - it's has to be ALWAYS an object, even when no schema is configured.
There was a problem hiding this comment.
This was clearly stated elsewhere, but it is also needed here.
|
|
||
| // Instead of an inline function: a method on any module, resolved at | ||
| // startup. Handy when the handler is long or already exists | ||
| handler: 'page-tools:findPages' |
There was a problem hiding this comment.
I'm not sure we should encourage anon functions as handlers. I'd say remove the last sentence. It depends on projects standards and architecture design raised by the dev providing the tools.
|
|
||
| ### Errors in handlers | ||
|
|
||
| There are exactly two outcomes for a failure, and the error code alone decides which. |
There was a problem hiding this comment.
There are 3 - aiInput, described above in the "Suspend" details. It even got an AI tool throw example that showcases how it works.
Please indicate which branch this PR should merge into:
Check one
Summary
Summarize the changes briefly, including which issue/ticket this resolves. If it closes an existing Github issue, include "Closes #[issue number]"
This PR adds the ai-adapter reference modules to the site. Closes pro-9879.
What are the specific steps to test this change?
For example:
What kind of change does this PR introduce?
(Check at least one)
Make sure the PR fulfills these requirements:
If adding a new feature without an already open issue, it's best to open a feature request issue first and wait for approval before working on it.
Other information: