-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6555fcc
commit 0ef6bdd
Showing
10 changed files
with
352 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import * as types from "./main.d.ts"; | ||
|
||
import { build } from "https://deno.land/x/[email protected]/mod.js" | ||
import { build } from "https://deno.land/x/[email protected]/mod.js"; | ||
|
||
export default async function importLLMFile(modulePath: string) { | ||
try { | ||
|
@@ -12,32 +12,30 @@ export default async function importLLMFile(modulePath: string) { | |
|
||
const tsCode = await Deno.readTextFile(Deno.cwd() + `/${modulePath}`); | ||
|
||
const { outputFiles } = await build({ | ||
stdin: { | ||
contents: tsCode, | ||
loader: "ts", | ||
}, | ||
bundle: true, | ||
write: false, | ||
format: "esm", // Specify output format as ESM | ||
}); | ||
const { outputFiles } = await build({ | ||
stdin: { | ||
contents: tsCode, | ||
loader: "ts", | ||
}, | ||
bundle: true, | ||
write: false, | ||
format: "esm", // Specify output format as ESM | ||
}); | ||
|
||
const jsCode = outputFiles[0].text; | ||
const jsCode = outputFiles[0].text; | ||
|
||
const base64Data = btoa(jsCode); | ||
|
||
// Create the Data URL | ||
const dataURL = `data:text/plain;base64,${base64Data}`; | ||
|
||
const module: types.llmFile = await import(dataURL) | ||
const base64Data = btoa(jsCode); | ||
|
||
// Create the Data URL | ||
const dataURL = `data:text/plain;base64,${base64Data}`; | ||
|
||
const module: types.llmFile = await import(dataURL); | ||
|
||
if (module && module.information && typeof module.send === "function") { | ||
globalThis.availableLLMs[module.information.id] = { | ||
information: module.information, | ||
send: module.send, | ||
} | ||
}; | ||
|
||
return module.information; // Return the information object | ||
} else { | ||
|
@@ -47,7 +45,9 @@ const dataURL = `data:text/plain;base64,${base64Data}`; | |
return null; // Return null if the module doesn't have the required exports | ||
} | ||
} catch (error) { | ||
if (Deno.env.get("debug") === "true") console.error(`Error importing module ${modulePath}':`, error); | ||
if (Deno.env.get("debug") === "true") { | ||
console.error(`Error importing module ${modulePath}':`, error); | ||
} | ||
return null; // Return null if there's an error importing the module | ||
} | ||
} |
Oops, something went wrong.