@agentica/core 0.16.4 → 0.16.7-fix-for-wrtn

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.
@@ -9,7 +9,6 @@ import { call } from "./call";
9
9
  import { cancel } from "./cancel";
10
10
  import { describe } from "./describe";
11
11
  import { initialize } from "./initialize";
12
- import { cancelFunction } from "./internal/cancelFunction";
13
12
  import { select } from "./select";
14
13
 
15
14
  export function execute<Model extends ILlmSchema.Model>(executor: Partial<IAgenticaExecutor<Model>> | null) {
@@ -64,12 +63,6 @@ export function execute<Model extends ILlmSchema.Model>(executor: Partial<IAgent
64
63
  const executes: AgenticaExecuteHistory<Model>[] = prompts.filter(
65
64
  prompt => prompt.type === "execute",
66
65
  );
67
- for (const e of executes) {
68
- await cancelFunction(ctx, {
69
- reason: "completed",
70
- name: e.operation.name,
71
- });
72
- }
73
66
  histories.push(
74
67
  ...(await (
75
68
  executor?.describe ?? describe
@@ -10,10 +10,10 @@ import { createOperationSelection } from "../../factory/operations";
10
10
  /**
11
11
  * @internal
12
12
  */
13
- export async function cancelFunction<Model extends ILlmSchema.Model>(
13
+ export function cancelFunction<Model extends ILlmSchema.Model>(
14
14
  ctx: AgenticaContext<Model>,
15
15
  reference: __IChatFunctionReference,
16
- ): Promise<AgenticaOperationSelection<Model> | null> {
16
+ ): AgenticaOperationSelection<Model> | null {
17
17
  const index: number = ctx.stack.findIndex(
18
18
  item => item.operation.name === reference.name,
19
19
  );
@@ -23,13 +23,13 @@ export async function cancelFunction<Model extends ILlmSchema.Model>(
23
23
 
24
24
  const item: AgenticaOperationSelection<Model> = ctx.stack[index]!;
25
25
  ctx.stack.splice(index, 1);
26
- await ctx.dispatch(
26
+ ctx.dispatch(
27
27
  createCancelEvent({
28
28
  selection: createOperationSelection({
29
29
  operation: item.operation,
30
30
  reason: reference.reason,
31
31
  }),
32
32
  }),
33
- );
33
+ ).catch(() => {});
34
34
  return item;
35
35
  }
@@ -3,20 +3,21 @@ import type {
3
3
  ChatCompletionChunk,
4
4
  ChatCompletionMessage,
5
5
  ChatCompletionMessageToolCall,
6
- CompletionUsage,
7
6
  } from "openai/resources";
8
7
 
9
- import { json } from "typia";
10
-
8
+ // import typia from "typia";
11
9
  import { ByteArrayUtil } from "./ByteArrayUtil";
12
10
  import { ChatGptTokenUsageAggregator } from "./ChatGptTokenUsageAggregator";
13
11
 
14
12
  function transformCompletionChunk(source: string | Uint8Array): ChatCompletionChunk {
15
13
  const str
16
14
  = source instanceof Uint8Array ? ByteArrayUtil.toUtf8(source) : source;
17
- return json.assertParse<
18
- ChatCompletionChunk & { usage: CompletionUsage | null | undefined }
19
- >(str);
15
+ const result: ChatCompletionChunk = JSON.parse(str) as ChatCompletionChunk;
16
+ // const valid = typia.validate<ChatCompletionChunk>(result);
17
+ // if (valid.success === false) {
18
+ // console.error("Invalid ChatCompletionChunk", valid.errors);
19
+ // }
20
+ return result;
20
21
  }
21
22
 
22
23
  function accumulate(origin: ChatCompletion, chunk: ChatCompletionChunk): ChatCompletion {