Skip to content

Commit e7625a9

Browse files
committed
Fixed compiler errors & deleted code for diagrams for now
1 parent b87491b commit e7625a9

File tree

6 files changed

+50
-71
lines changed

6 files changed

+50
-71
lines changed

ai-assistant/src/commands/DiagramCommand.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from "@rocket.chat/apps-engine/definition/slashcommands";
1010

1111
import { Neo4j } from "../core/db/neo4j";
12-
import { renderDiagramToBase64URI } from "../core/diagram";
12+
// import { renderDiagramToBase64URI } from "../core/diagram";
1313
import { MiniLML6 } from "../core/embeddings/minilml6";
1414
import { Llama3_70B } from "../core/llm/llama3_70B";
1515
import { PromptFactory } from "../core/prompt/prompt.factory";
@@ -71,8 +71,8 @@ export class DiagramCommand implements ISlashCommand {
7171
.trim();
7272
console.log("DIAGRAM:\n", diagramContent);
7373

74-
const base64Diagram = await renderDiagramToBase64URI(diagramContent);
75-
return base64Diagram;
74+
// const base64Diagram = await renderDiagramToBase64URI(diagramContent);
75+
return "";
7676
}
7777

7878
public async executor(

ai-assistant/src/commands/WhyUsedCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from "@rocket.chat/apps-engine/definition/slashcommands";
1010
import { writeFileSync } from "fs";
1111
import { Neo4j } from "../core/db/neo4j";
12-
import { renderDiagramToBase64URI } from "../core/diagram";
12+
// import { renderDiagramToBase64URI } from "../core/diagram";
1313
import { MiniLML6 } from "../core/embeddings/minilml6";
1414
import { Llama3_70B } from "../core/llm/llama3_70B";
1515
import { PromptFactory } from "../core/prompt/prompt.factory";
@@ -93,7 +93,7 @@ export class WhyUsedCommand implements ISlashCommand {
9393
.trim();
9494
writeFileSync("output.txt", parsedDiagram);
9595
try {
96-
data.diagram = await renderDiagramToBase64URI(parsedDiagram);
96+
// data.diagram = await renderDiagramToBase64URI(parsedDiagram);
9797
} catch {}
9898
}
9999

ai-assistant/src/core/diagram.ts

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,47 @@
1-
import { exec } from "child_process";
2-
// import { randomUUID } from "crypto"
3-
import { unlinkSync, writeFileSync } from "fs";
1+
export default {}
2+
// import { exec } from "child_process";
3+
// // import { randomUUID } from "crypto"
4+
// import { unlinkSync, writeFileSync } from "fs";
45

5-
export async function renderDiagramToBase64URI(
6-
diagram: string
7-
): Promise<string> {
8-
const diagramID = "diagram";
9-
// ?? randomUUID()
10-
const diagramSourceFileName = `${diagramID}.txt`;
11-
const diagramSVGFileName = `${diagramID}.svg`;
6+
// export async function renderDiagramToBase64URI(
7+
// diagram: string
8+
// ): Promise<string> {
9+
// const diagramID = "diagram";
10+
// // ?? randomUUID()
11+
// const diagramSourceFileName = `${diagramID}.txt`;
12+
// const diagramSVGFileName = `${diagramID}.svg`;
1213

13-
writeFileSync(diagramSourceFileName, diagram);
14+
// writeFileSync(diagramSourceFileName, diagram);
1415

15-
await new Promise<void>((resolve, reject) => {
16-
const diagram = exec(
17-
`npx mmdc -i ${diagramSourceFileName} -o ${diagramSVGFileName}`,
18-
{
19-
cwd: process.cwd(),
20-
timeout: 10000,
21-
}
22-
);
16+
// await new Promise<void>((resolve, reject) => {
17+
// const diagram = exec(
18+
// `npx mmdc -i ${diagramSourceFileName} -o ${diagramSVGFileName}`,
19+
// {
20+
// cwd: process.cwd(),
21+
// timeout: 10000,
22+
// }
23+
// );
2324

24-
diagram.on("exit", async (code) => {
25-
// unlinkSync(diagramSourceFileName)
26-
if (code === 0) {
27-
resolve();
28-
} else {
29-
console.log(`Error: ${code}`);
30-
reject();
31-
}
32-
});
33-
});
25+
// diagram.on("exit", async (code) => {
26+
// // unlinkSync(diagramSourceFileName)
27+
// if (code === 0) {
28+
// resolve();
29+
// } else {
30+
// console.log(`Error: ${code}`);
31+
// reject();
32+
// }
33+
// });
34+
// });
3435

35-
const base64 = await new Promise<string>((resolve, reject) => {
36-
exec(`base64 ${diagramSVGFileName}`, async (err, stdout) => {
37-
unlinkSync(diagramSVGFileName);
38-
if (err) reject(err);
39-
resolve(stdout);
40-
});
41-
});
36+
// const base64 = await new Promise<string>((resolve, reject) => {
37+
// exec(`base64 ${diagramSVGFileName}`, async (err, stdout) => {
38+
// unlinkSync(diagramSVGFileName);
39+
// if (err) reject(err);
40+
// resolve(stdout);
41+
// });
42+
// });
4243

43-
const uri = `data:image/svg+xml;base64,${base64.trim()}`;
44+
// const uri = `data:image/svg+xml;base64,${base64.trim()}`;
4445

45-
return uri;
46-
}
46+
// return uri;
47+
// }

ai-assistant/src/core/prompt/prompt.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export class Prompt {
2121
}
2222

2323
static processOutput(output: string): string {
24-
return (output.split("[/INST] Assistant:\n").at(-1) ?? "").trim();
24+
const segments = output.split("[/INST] Assistant:\n")
25+
if (!segments.length) return "";
26+
27+
return segments[segments.length - 1].trim();
2528
}
2629
}

ai-assistant/src/utils/requestServer.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

ai-assistant/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "ES2022",
3+
"target": "ES2017",
44
"module": "commonjs",
55
"moduleResolution": "node",
66
"declaration": false,

0 commit comments

Comments
 (0)