even-pf 0.2.3 → 0.2.4
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 +9 -0
- package/package.json +1 -1
- package/src/index.ts +5 -1
- package/src/util/output-viewer.ts +23 -1
- package/src/workflow/analysis-workflow.ts +1 -0
- package/src/workflow/index.ts +3 -0
package/README.md
CHANGED
|
@@ -22,3 +22,12 @@ bun link
|
|
|
22
22
|
Make sure you have a config file in your home or current directory. Alternatively, you can set environment variable `EPF_CONFIG_URL`.
|
|
23
23
|
|
|
24
24
|
This project was created using `bun init` in bun v1.3.2. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
|
|
25
|
+
|
|
26
|
+
## Specs
|
|
27
|
+
### File-viewer Frontend
|
|
28
|
+
In consideration of the tool might be running at a remote server, for easily viewing the Markdown files, we will use a simple file-viewer frontend.
|
|
29
|
+
Data being sent to the frontend will be as encoded as an URL, using the following format:
|
|
30
|
+
```
|
|
31
|
+
https://yourfrontend.com/#name=...&comp=gzip&data=...
|
|
32
|
+
```
|
|
33
|
+
The `data` field is base64-encoded using compression algorithm specified in `comp` field. The frontend will decode the data and display it as a Markdown file.
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {CONFIG} from "./util/config.ts";
|
|
|
6
6
|
import {executeTestingWorkflow} from "./workflow/testing-workflow.ts";
|
|
7
7
|
import {executeAnalysisWorkflow} from "./workflow/analysis-workflow.ts";
|
|
8
8
|
import type {WorkflowDependencies} from "./workflow";
|
|
9
|
+
import {OutputViewer} from "./util/output-viewer.ts";
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
console.log("EPF index.ts");
|
|
@@ -14,7 +15,8 @@ const workflowDependencies: WorkflowDependencies = {
|
|
|
14
15
|
seed: Math.floor(Date.now() / 1000),
|
|
15
16
|
openRouter: new OpenRouter({
|
|
16
17
|
apiKey: CONFIG.vendors.openrouter.api_key,
|
|
17
|
-
})
|
|
18
|
+
}),
|
|
19
|
+
outputViewer: new OutputViewer(),
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
// Parallelize workflows with Promise.allSettled
|
|
@@ -52,4 +54,6 @@ if (failedIndices.length > 0) {
|
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
56
|
|
|
57
|
+
workflowDependencies.outputViewer.display();
|
|
58
|
+
|
|
55
59
|
console.log("index.ts done");
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
|
|
1
3
|
type FileRecord = {
|
|
2
4
|
type: "markdown" | "text";
|
|
3
5
|
content: string;
|
|
@@ -11,7 +13,7 @@ export class OutputViewer {
|
|
|
11
13
|
this.filesRecords[filename] = _;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
private serve(): void {
|
|
15
17
|
let files = Object.entries(this.filesRecords).sort((a, b) => a[0].localeCompare(b[0]));
|
|
16
18
|
|
|
17
19
|
let server = Bun.serve({
|
|
@@ -29,4 +31,24 @@ export class OutputViewer {
|
|
|
29
31
|
});
|
|
30
32
|
console.log(server.url);
|
|
31
33
|
}
|
|
34
|
+
|
|
35
|
+
display() {
|
|
36
|
+
if (Object.keys(this.filesRecords).length === 0) {
|
|
37
|
+
console.warn("No files to display");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
console.log("Click the following links to view the outputs in your browser:");
|
|
42
|
+
|
|
43
|
+
const FRONTEND_URL = "https://ta-tools-dashboard.vercel.app/tools/md-viewer"; //TODO: not hardcode this
|
|
44
|
+
let files = Object.entries(this.filesRecords).sort((a, b) => a[0].localeCompare(b[0]));
|
|
45
|
+
for (const [filename, fileRecord] of files) {
|
|
46
|
+
let params = new URLSearchParams();
|
|
47
|
+
params.set("name", filename);
|
|
48
|
+
params.set("comp", "gzip");
|
|
49
|
+
params.set("data", Bun.gzipSync(fileRecord.content).toBase64());
|
|
50
|
+
let url = `${FRONTEND_URL}#${params.toString()}`;
|
|
51
|
+
console.log(`${chalk.cyan(filename)}: ${url}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
32
54
|
}
|
|
@@ -56,4 +56,5 @@ export async function executeAnalysisWorkflow(workflow: typeof CONFIG.analysis_w
|
|
|
56
56
|
.replaceAll("[run]", runNum.toString());
|
|
57
57
|
await Bun.write(outputFileName, completion.text);
|
|
58
58
|
log(`Completion written to ${outputFileName}`);
|
|
59
|
+
deps.outputViewer.addFile(outputFileName, {type: "markdown", content: completion.text});
|
|
59
60
|
}
|
package/src/workflow/index.ts
CHANGED