Skip to content

Commit

Permalink
Everyone nearby me is going to rot
Browse files Browse the repository at this point in the history
  • Loading branch information
Erisfiregamer1 committed Apr 3, 2024
1 parent cd5a538 commit c8bc496
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
5 changes: 0 additions & 5 deletions bots/claude_3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ export async function send(

const resp: types.claudeResponse | types.Error = await res.json();

if (types.isError(resp)) {
// Fuck.
throw resp.error.message; // well at least they know why the fuck it crashed??
}

messages.push({ role: "assistant", content: resp.content[0].text });

const fresp = {
Expand Down
28 changes: 25 additions & 3 deletions importLLMFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,43 @@

import * as types from "./main.d.ts";

import { dynamicImport } from 'https://deno.land/x/import/mod.ts';
import { build } from "https://deno.land/x/[email protected]/mod.js"

export default async function importLLMFile(modulePath: string) {
try {
if (!globalThis.availableLLMs) {
globalThis.availableLLMs = {};
}

const module: types.llmFile = await dynamicImport(`${modulePath}`, { force: true });
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 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)



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 {
console.error(
Expand Down
4 changes: 1 addition & 3 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import client from "./client.ts";

import { walk, existsSync } from "https://deno.land/[email protected]/fs/mod.ts";

import * as path from "https://deno.land/[email protected]/path/mod.ts";

import importLLMFile from "./importLLMFile.ts";

if (!existsSync("./bots")) {
Expand All @@ -22,7 +20,7 @@ if (!existsSync("./bots")) {
for await (const entry of await walk("./bots")) {
if (entry.isFile && entry.name.endsWith(".ts")) {
await importLLMFile(
`./${entry.path}`
entry.path
);
}
}
Expand Down

0 comments on commit c8bc496

Please sign in to comment.