@molecule/api-ai-openai 1.4.1 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-09-24T07:06:51.312Z
6
+ Generated: 2026-10-01T18:20:48.517Z
7
7
  -->
8
8
 
9
9
  # @molecule/api-ai-openai
@@ -14,6 +14,26 @@ Generated: 2026-09-24T07:06:51.312Z
14
14
 
15
15
  OpenAI (GPT) AI provider for molecule.dev.
16
16
 
17
+ ## Quick Start
18
+
19
+ ```typescript
20
+ // npm install @molecule/api-ai-openai --workspace=api
21
+ import { setProvider, requireProvider } from '@molecule/api-ai'
22
+ import { provider } from '@molecule/api-ai-openai'
23
+
24
+ // Named registration — several AI providers can be bonded side by side
25
+ // (getProviderByName('openai') targets this one); the FIRST one
26
+ // registered also answers requireProvider() (see @molecule/api-ai).
27
+ setProvider('openai', provider) // reads OPENAI_API_KEY from the environment
28
+
29
+ let reply = ''
30
+ for await (const event of requireProvider().chat({
31
+ messages: [{ role: 'user', content: 'Hello!' }],
32
+ })) {
33
+ if (event.type === 'text') reply += event.content // or forward the chunk to the client (SSE)
34
+ }
35
+ ```
36
+
17
37
  ## Type
18
38
 
19
39
  `provider`
package/dist/index.d.ts CHANGED
@@ -1,6 +1,25 @@
1
1
  /**
2
2
  * OpenAI (GPT) AI provider for molecule.dev.
3
3
  *
4
+ * @example
5
+ * ```typescript
6
+ * // npm install @molecule/api-ai-openai --workspace=api
7
+ * import { setProvider, requireProvider } from '@molecule/api-ai'
8
+ * import { provider } from '@molecule/api-ai-openai'
9
+ *
10
+ * // Named registration — several AI providers can be bonded side by side
11
+ * // (getProviderByName('openai') targets this one); the FIRST one
12
+ * // registered also answers requireProvider() (see @molecule/api-ai).
13
+ * setProvider('openai', provider) // reads OPENAI_API_KEY from the environment
14
+ *
15
+ * let reply = ''
16
+ * for await (const event of requireProvider().chat({
17
+ * messages: [{ role: 'user', content: 'Hello!' }],
18
+ * })) {
19
+ * if (event.type === 'text') reply += event.content // or forward the chunk to the client (SSE)
20
+ * }
21
+ * ```
22
+ *
4
23
  * @remarks
5
24
  * Config: `OPENAI_API_KEY` (SERVER-side only) plus an optional default model id/base URL.
6
25
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,cAAc,oBAAoB,CAAA;AAClC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChE,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAMlD,mCAAmC;AACnC,eAAO,MAAM,QAAQ,EAAE,UAUrB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,cAAc,oBAAoB,CAAA;AAClC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChE,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAMlD,mCAAmC;AACnC,eAAO,MAAM,QAAQ,EAAE,UAUrB,CAAA"}
package/dist/index.js CHANGED
@@ -1,6 +1,25 @@
1
1
  /**
2
2
  * OpenAI (GPT) AI provider for molecule.dev.
3
3
  *
4
+ * @example
5
+ * ```typescript
6
+ * // npm install @molecule/api-ai-openai --workspace=api
7
+ * import { setProvider, requireProvider } from '@molecule/api-ai'
8
+ * import { provider } from '@molecule/api-ai-openai'
9
+ *
10
+ * // Named registration — several AI providers can be bonded side by side
11
+ * // (getProviderByName('openai') targets this one); the FIRST one
12
+ * // registered also answers requireProvider() (see @molecule/api-ai).
13
+ * setProvider('openai', provider) // reads OPENAI_API_KEY from the environment
14
+ *
15
+ * let reply = ''
16
+ * for await (const event of requireProvider().chat({
17
+ * messages: [{ role: 'user', content: 'Hello!' }],
18
+ * })) {
19
+ * if (event.type === 'text') reply += event.content // or forward the chunk to the client (SSE)
20
+ * }
21
+ * ```
22
+ *
4
23
  * @remarks
5
24
  * Config: `OPENAI_API_KEY` (SERVER-side only) plus an optional default model id/base URL.
6
25
  *
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EACV,UAAU,EAGV,SAAS,EAET,UAAU,EAEX,MAAM,kBAAkB,CAAA;AAQzB,OAAO,KAAK,EAAa,YAAY,EAAE,MAAM,YAAY,CAAA;AAkCzD;;GAEG;AACH,qBAAa,gBAAiB,YAAW,UAAU;IACjD,QAAQ,CAAC,IAAI,YAAW;IACxB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,WAAW,CAAC,CAAqB;IACzC,OAAO,CAAC,GAAG,CAAW;gBAEV,MAAM,GAAE,YAAiB;IAsBrC;;;;;;;;OAQG;IACH,OAAO,CAAC,wBAAwB;IAgEhC;;;;;OAKG;IACI,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC;IA6HzD;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,cAAc;I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qEzB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAEhE"}
package/dist/provider.js CHANGED
@@ -309,6 +309,11 @@ export class OpenaiAIProvider {
309
309
  if (toolResults.length > 0) {
310
310
  for (const tr of toolResults)
311
311
  out.push(tr);
312
+ // Non-tool parts of the SAME message (an image riding a tool result — the
313
+ // screenshot tool) must not be dropped: Chat Completions accepts a user
314
+ // message after the tool messages, so emit them instead of losing them.
315
+ if (parts.length > 0)
316
+ out.push({ role: m.role, content: parts });
312
317
  }
313
318
  else if (toolCalls.length > 0) {
314
319
  out.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-ai-openai",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "",
5
5
  "homepage": "https://www.molecule.dev/packages/api-ai-openai",
6
6
  "type": "module",