@codehz/ai 0.1.0 → 0.1.2

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/package.json CHANGED
@@ -17,7 +17,8 @@
17
17
  "test": "bun test",
18
18
  "example:basic": "bun run examples/basic.ts",
19
19
  "example:multi-turn": "bun run examples/multi-turn.ts",
20
- "example:tool-loop": "bun run examples/tool-loop.ts"
20
+ "example:tool-loop": "bun run examples/tool-loop.ts",
21
+ "prepack": "tsdown"
21
22
  },
22
23
  "devDependencies": {
23
24
  "@types/bun": "latest",
@@ -26,5 +27,5 @@
26
27
  "tsdown": "^0.22.3",
27
28
  "typescript": "^6"
28
29
  },
29
- "version": "0.1.0"
30
+ "version": "0.1.2"
30
31
  }
@@ -161,6 +161,7 @@ function ensureTextCompatibleBlocks(
161
161
  ): import("../index.js").ContentBlock[] {
162
162
  for (let i = 0; i < blocks.length; i++) {
163
163
  const block = blocks[i];
164
+ if (!block) continue;
164
165
  if (block.type !== "text" && block.type !== "json") {
165
166
  throw new AIRequestError(
166
167
  `chat-completions does not support ${field}[${i}] of type "${block.type}"; only text/json blocks are supported`,
@@ -6,6 +6,7 @@
6
6
  * - messages
7
7
  * - chat.completions
8
8
  * - ollama
9
+ * - mock
9
10
  *
10
11
  * 每个 adapter 实现 BackendAdapter 内部协议。
11
12
  */
@@ -18,3 +19,23 @@ export { ChatCompletionsAdapter } from "./chat-completions.js";
18
19
  export type { ChatCompletionsAdapterOptions } from "./chat-completions.js";
19
20
  export { OllamaAdapter } from "./ollama.js";
20
21
  export type { OllamaAdapterOptions } from "./ollama.js";
22
+ export { MockAdapter } from "./mock.js";
23
+ export type {
24
+ MockAdapterOptions,
25
+ MockInputExpectation,
26
+ MockRequestExpectation,
27
+ MockTurnContext,
28
+ MockTurnValidator,
29
+ MockWarningStep,
30
+ MockAuxiliaryStep,
31
+ MockMessageStep,
32
+ MockReasoningStep,
33
+ MockToolCallStep,
34
+ MockOutputStep,
35
+ MockCompleteStep,
36
+ MockErrorStep,
37
+ MockInterruptStep,
38
+ MockThrowStep,
39
+ MockStep,
40
+ MockTurn,
41
+ } from "./mock.js";
@@ -78,6 +78,7 @@ function ensureMessagesTextBlocks(
78
78
  ): import("../index.js").ContentBlock[] {
79
79
  for (let i = 0; i < blocks.length; i++) {
80
80
  const block = blocks[i];
81
+ if (!block) continue;
81
82
  if (block.type !== "text" && block.type !== "json") {
82
83
  throw new AIRequestError(
83
84
  `messages does not support ${field}[${i}] of type "${block.type}"; only text/json blocks are supported`,