@modular-prompt/process 0.1.22 → 0.1.24

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
@@ -10,6 +10,12 @@ npm install @modular-prompt/process
10
10
 
11
11
  ## ワークフロー
12
12
 
13
+ ### 基本ワークフロー
14
+
15
+ - **`defaultProcess`** - 最小のワークフロー(compile + driver.query)
16
+ - すべてのプロセスの基本形
17
+ - モジュールをコンパイルしてドライバーで実行するだけのシンプルな処理
18
+
13
19
  ### チャンク処理ワークフロー
14
20
 
15
21
  - **`streamProcess`** - ステートを保持しながらチャンクを逐次処理
@@ -30,6 +36,35 @@ npm install @modular-prompt/process
30
36
 
31
37
  ## 使用例
32
38
 
39
+ ### 基本ワークフロー
40
+
41
+ ```typescript
42
+ import { defaultProcess } from '@modular-prompt/process';
43
+ import type { PromptModule } from '@modular-prompt/core';
44
+ import { OpenAIDriver } from '@modular-prompt/driver';
45
+
46
+ const driver = new OpenAIDriver({
47
+ apiKey: process.env.OPENAI_API_KEY,
48
+ model: 'gpt-4o'
49
+ });
50
+
51
+ const module: PromptModule<{ query: string }> = {
52
+ objective: ['ユーザーの質問に回答する'],
53
+ instructions: [
54
+ (ctx) => `質問: ${ctx.query}`,
55
+ ],
56
+ };
57
+
58
+ const result = await defaultProcess(
59
+ driver,
60
+ module,
61
+ { query: 'TypeScriptとは何ですか?' },
62
+ { queryOptions: { temperature: 0.7 } }
63
+ );
64
+
65
+ console.log(result.output); // AIの応答
66
+ ```
67
+
33
68
  ### チャンク処理
34
69
 
35
70
  ```typescript
@@ -0,0 +1,15 @@
1
+ import type { PromptModule } from '@modular-prompt/core';
2
+ import type { QueryOptions } from '@modular-prompt/driver';
3
+ import { type AIDriver, type WorkflowResult } from './types.js';
4
+ /**
5
+ * Options for default workflow
6
+ */
7
+ export interface DefaultProcessOptions {
8
+ queryOptions?: Partial<QueryOptions>;
9
+ }
10
+ /**
11
+ * Default workflow - compiles a module with context and queries the driver.
12
+ * This is the simplest process, wrapping compile + driver.query().
13
+ */
14
+ export declare function defaultProcess<TContext extends Record<string, any>>(driver: AIDriver, module: PromptModule<TContext>, context: TContext, options?: DefaultProcessOptions): Promise<WorkflowResult<TContext>>;
15
+ //# sourceMappingURL=default-workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-workflow.d.ts","sourceRoot":"","sources":["../../src/workflows/default-workflow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAA0B,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAExF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,YAAY,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACvE,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,EAC9B,OAAO,EAAE,QAAQ,EACjB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAuBnC"}
@@ -0,0 +1,27 @@
1
+ import { compile } from '@modular-prompt/core';
2
+ import { WorkflowExecutionError } from './types.js';
3
+ /**
4
+ * Default workflow - compiles a module with context and queries the driver.
5
+ * This is the simplest process, wrapping compile + driver.query().
6
+ */
7
+ export async function defaultProcess(driver, module, context, options = {}) {
8
+ try {
9
+ const compiled = compile(module, context);
10
+ const result = await driver.query(compiled, options.queryOptions);
11
+ return {
12
+ output: result.content,
13
+ context,
14
+ metadata: {
15
+ iterations: 1,
16
+ tokensUsed: result.usage?.totalTokens,
17
+ toolCalls: result.toolCalls,
18
+ finishReason: result.finishReason,
19
+ usage: result.usage,
20
+ },
21
+ };
22
+ }
23
+ catch (error) {
24
+ throw new WorkflowExecutionError(error instanceof Error ? error : new Error(String(error)), context, { phase: 'query' });
25
+ }
26
+ }
27
+ //# sourceMappingURL=default-workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-workflow.js","sourceRoot":"","sources":["../../src/workflows/default-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,sBAAsB,EAAsC,MAAM,YAAY,CAAC;AASxF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAgB,EAChB,MAA8B,EAC9B,OAAiB,EACjB,UAAiC,EAAE;IAEnC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;QAElE,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,OAAO;YACtB,OAAO;YACP,QAAQ,EAAE;gBACR,UAAU,EAAE,CAAC;gBACb,UAAU,EAAE,MAAM,CAAC,KAAK,EAAE,WAAW;gBACrC,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,YAAY,EAAE,MAAM,CAAC,YAAY;gBACjC,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,sBAAsB,CAC9B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EACzD,OAAO,EACP,EAAE,KAAK,EAAE,OAAO,EAAE,CACnB,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -11,4 +11,6 @@ export { agenticProcess } from './agentic-workflow/index.js';
11
11
  export type { AgenticWorkflowContext, AgenticWorkflowOptions, ActionHandler } from './agentic-workflow/index.js';
12
12
  export { agentProcess } from './agent-workflow.js';
13
13
  export type { AgentWorkflowContext, AgentWorkflowOptions, AgentWorkflowActionHandler } from './agent-workflow.js';
14
+ export { defaultProcess } from './default-workflow.js';
15
+ export type { DefaultProcessOptions } from './default-workflow.js';
14
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workflows/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,QAAQ,EACR,cAAc,EACd,aAAa,EACb,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,YAAY,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAGlE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EACV,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,aAAa,EACd,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workflows/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,QAAQ,EACR,cAAc,EACd,aAAa,EACb,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,YAAY,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAGlE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EACV,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,aAAa,EACd,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,YAAY,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -10,4 +10,6 @@ export { concatProcess } from './concat-process-workflow.js';
10
10
  export { agenticProcess } from './agentic-workflow/index.js';
11
11
  // Simple agent workflow
12
12
  export { agentProcess } from './agent-workflow.js';
13
+ // Default workflow
14
+ export { defaultProcess } from './default-workflow.js';
13
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflows/index.ts"],"names":[],"mappings":"AAQA,kBAAkB;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,oBAAoB;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAMzD,qBAAqB;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAM3D,kBAAkB;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAM7D,mBAAmB;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAO7D,wBAAwB;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflows/index.ts"],"names":[],"mappings":"AAQA,kBAAkB;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,oBAAoB;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAMzD,qBAAqB;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAM3D,kBAAkB;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAM7D,mBAAmB;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAO7D,wBAAwB;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAOnD,mBAAmB;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-prompt/process",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "description": "Process module for modular prompt framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -24,8 +24,8 @@
24
24
  "README.md"
25
25
  ],
26
26
  "dependencies": {
27
- "@modular-prompt/core": "0.1.12",
28
- "@modular-prompt/driver": "0.8.0"
27
+ "@modular-prompt/core": "0.1.13",
28
+ "@modular-prompt/driver": "0.8.2"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@eslint/js": "^9.34.0",