ai

Generative AI for Gingee apps (chat, multimodal, document parsing, content safety) via provider adapters — similar to `db` / `email`. Configuration (single config): - Server defaults: `gingee.json` → `ai` - App override: `app.json` → `ai` - Per-call override: pass `{ config: { … } }` as the second argument to any method Providers: - `mock` — local deterministic responses (dev/tests) - `gemini` — Google Gemini (v1) - `xai` — Grok via xAI (P1 — stub until implemented) Streaming: `ai.chatStream(request, options)` yields chunk objects; final chunk has `done: true`. IMPORTANT: Requires the `ai` permission. See docs/permissions-guide.
Description:
  • Generative AI for Gingee apps (chat, multimodal, document parsing, content safety) via provider adapters — similar to `db` / `email`. Configuration (single config): - Server defaults: `gingee.json` → `ai` - App override: `app.json` → `ai` - Per-call override: pass `{ config: { … } }` as the second argument to any method Providers: - `mock` — local deterministic responses (dev/tests) - `gemini` — Google Gemini (v1) - `xai` — Grok via xAI (P1 — stub until implemented) Streaming: `ai.chatStream(request, options)` yields chunk objects; final chunk has `done: true`. IMPORTANT: Requires the `ai` permission. See docs/permissions-guide.

Members

(inner, constant) aiInstances :Map.<string, {adapter: object, config: object}>

Type:
  • Map.<string, {adapter: object, config: object}>

(inner) serverAiConfig :object|null

Type:
  • object | null

Methods

(static) chat(request, optionsopt) → {Promise.<object>}

Description:
  • Chat / text generation (supports multimodal content parts). Non-streaming.
Parameters:
Name Type Attributes Description
request object
Properties
Name Type Attributes Description
messages Array.<object> Chat messages: `{ role, content }` where content is a string or array of parts
system string <optional>
model string <optional>
temperature number <optional>
maxTokens number <optional>
options object <optional>
Properties
Name Type Attributes Description
config object <optional>
Per-call AI config override
Returns:
Result with `text`, `model`, `provider`, `usage`, etc.
Type
Promise.<object>

(static) chatStream(request, optionsopt) → {AsyncGenerator.<object>}

Description:
  • Streaming chat. Async generator yielding `{ textDelta, done, … }`. Final chunk has `done: true` and full `text`.
Example
for await (const chunk of ai.chatStream({ messages: [{ role: 'user', content: 'Hi' }] })) {
  if (!chunk.done) process.stdout.write(chunk.textDelta);
}
Parameters:
Name Type Attributes Description
request object Same as module:ai.chat
options object <optional>
Properties
Name Type Attributes Description
config object <optional>
Returns:
Type
AsyncGenerator.<object>

(static) complete()

Description:
  • Single-prompt completion (wrapper over chat).

(static) moderate()

Description:
  • Content safety check for text (and provider-dependent media later).

(static) parseDocument()

Description:
  • OCR / extract / summarize a document (buffer, text, or sandboxed path).