@@ -178,12 +178,8 @@ my-project/
178178│ ├── flow.ts
179179│ ├── types.ts
180180│ └── utils/
181- │ ├── index.ts
182181│ ├── callLlm.ts
183182│ └── searchWeb.ts
184- ├── tests/
185- │ ├── flow.test.ts
186- │ └── nodes.test.ts
187183├── docs/
188184│ └── design.md
189185├── package.json
@@ -195,15 +191,14 @@ my-project/
195191- **`src/utils/`**: Contains all utility functions.
196192 - It's recommended to dedicate one TypeScript file to each API call, for example `callLlm.ts` or `searchWeb.ts`.
197193 - Each file should export functions that can be imported elsewhere in the project
198- - Include tests in the `tests` directory for each utility function
194+ - Include test cases for each utility function using `utilityFunctionName.test.ts`
199195- **`src/nodes.ts`**: Contains all the node definitions.
200196
201197 ```typescript
202198 // src/types.ts
203199 export interface QASharedStore {
204200 question?: string;
205201 answer?: string;
206- [key: string]: unknown;
207202 }
208203 ```
209204
@@ -212,9 +207,12 @@ my-project/
212207 import { Node } from "pocketflow";
213208 import { callLlm } from "./utils/callLlm";
214209 import { QASharedStore } from "./types";
210+ import PromptSync from "prompt-sync";
211+
212+ const prompt = PromptSync();
215213
216214 export class GetQuestionNode extends Node<QASharedStore> {
217- async exec(_: unknown ): Promise<string> {
215+ async exec(): Promise<string> {
218216 // Get question directly from user input
219217 const userQuestion = prompt("Enter your question: ") || "";
220218 return userQuestion;
@@ -260,6 +258,7 @@ my-project/
260258 // src/flow.ts
261259 import { Flow } from "pocketflow";
262260 import { GetQuestionNode, AnswerNode } from "./nodes";
261+ import { QASharedStore } from "./types";
263262
264263 export function createQaFlow(): Flow {
265264 // Create nodes
@@ -270,7 +269,7 @@ my-project/
270269 getQuestionNode.next(answerNode);
271270
272271 // Create flow starting with input node
273- return new Flow(getQuestionNode);
272+ return new Flow<QASharedStore> (getQuestionNode);
274273 }
275274 ```
276275
@@ -299,12 +298,6 @@ my-project/
299298 main().catch(console.error);
300299 ```
301300
302- - **`tests/`**: Contains test files that verify the functionality of your nodes, flows, and utilities.
303-
304- - Use a testing framework like Jest or Mocha
305- - Write tests for each node, flow, and utility function
306- - Consider using mock data and interfaces for testing
307-
308301- **`package.json`**: Contains project metadata and dependencies.
309302
310303- **`tsconfig.json`**: Contains TypeScript compiler configuration.
0 commit comments