-
Notifications
You must be signed in to change notification settings - Fork 1
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
150d68e
commit b7b4cc6
Showing
11 changed files
with
426 additions
and
126 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,48 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/package.json", | ||
"name": "spongechat", | ||
"version": "2.0.1", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"lint": "prettier --check . && eslint --ext .js,.mjs,.cjs --format=pretty src", | ||
"format": "prettier --write . && eslint --ext .js,.mjs,.cjs --fix --format=pretty src", | ||
"start": "node --require dotenv/config src/index.js", | ||
"cmd:undeploy": "node --require dotenv/config src/util/deploy/cli.js undeploy", | ||
"cmd:deploy": "node --require dotenv/config src/util/deploy/cli.js deploy", | ||
"ci:release": "dotenv -e .env -- release-it --config .release-it.cjs" | ||
}, | ||
"_moduleAliases": { | ||
"@": "./src", | ||
"@util": "./src/util", | ||
"@events": "./src/events", | ||
"@commands": "./src/commands" | ||
}, | ||
"dependencies": { | ||
"@discordjs/core": "^1.1.0", | ||
"@redis/json": "^1.0.6", | ||
"chalk": "4", | ||
"discord.js": "^14.15.2", | ||
"dotenv": "^16.3.1", | ||
"luxon": "^3.4.4", | ||
"module-alias": "^2.2.3", | ||
"redis": "^4.6.13", | ||
"temporal-polyfill": "^0.2.4", | ||
"undici": "^6.16.1", | ||
"uuid": "^9.0.1" | ||
}, | ||
"devDependencies": { | ||
"@release-it/conventional-changelog": "^8.0.1", | ||
"all-contributors-cli": "^6.26.1", | ||
"dotenv-cli": "^7.4.2", | ||
"eslint": "^8.53.0", | ||
"eslint-config-neon": "^0.1.57", | ||
"eslint-formatter-pretty": "^5.0.0", | ||
"execa": "^9.1.0", | ||
"prettier": "^3.0.3", | ||
"release-it": "^17" | ||
} | ||
"$schema": "https://json.schemastore.org/package.json", | ||
"name": "spongechat", | ||
"version": "2.0.1", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"lint": "prettier --check . && eslint --ext .js,.mjs,.cjs --format=pretty src", | ||
"format": "prettier --write . && eslint --ext .js,.mjs,.cjs --fix --format=pretty src", | ||
"start": "node --require dotenv/config src/index.js", | ||
"cmd:undeploy": "node --require dotenv/config src/util/deploy/cli.js undeploy", | ||
"cmd:deploy": "node --require dotenv/config src/util/deploy/cli.js deploy", | ||
"ci:release": "dotenv -e .env -- release-it --config .release-it.cjs" | ||
}, | ||
"_moduleAliases": { | ||
"@": "./src", | ||
"@util": "./src/util", | ||
"@events": "./src/events", | ||
"@commands": "./src/commands" | ||
}, | ||
"dependencies": { | ||
"@ai-sdk/openai": "^0.0.13", | ||
"@discordjs/core": "^1.1.0", | ||
"@redis/json": "^1.0.6", | ||
"ai": "^3.1.12", | ||
"chalk": "4", | ||
"discord.js": "^14.15.2", | ||
"dotenv": "^16.3.1", | ||
"luxon": "^3.4.4", | ||
"module-alias": "^2.2.3", | ||
"redis": "^4.6.13", | ||
"temporal-polyfill": "^0.2.4", | ||
"undici": "^6.16.1", | ||
"uuid": "^9.0.1", | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@release-it/conventional-changelog": "^8.0.1", | ||
"all-contributors-cli": "^6.26.1", | ||
"dotenv-cli": "^7.4.2", | ||
"eslint": "^8.53.0", | ||
"eslint-config-neon": "^0.1.57", | ||
"eslint-formatter-pretty": "^5.0.0", | ||
"execa": "^9.1.0", | ||
"prettier": "^3.0.3", | ||
"release-it": "^17" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { tool } from "ai"; | ||
import { z } from "zod"; | ||
|
||
export class Integration { | ||
constructor({ name, description, parameters, stage }) { | ||
this.tool = tool({ | ||
description, | ||
parameters, | ||
}); | ||
|
||
this.executionLevel = stage; | ||
} | ||
|
||
get stage() { | ||
return this.executionLevel; | ||
} | ||
|
||
// pre-runner integrations run before the model call and can ONLY return a conversation-based output; () => Promise<Object> | ||
// post-runner integrations run after the model call and can only return file-based outputs; () => Promise<Buffer> | ||
async call() { | ||
return {}; | ||
} | ||
} | ||
|
||
export class ImagineIntegration extends Integration { | ||
constructor({ workersAI }) { | ||
super({ | ||
name: "imagine", | ||
description: "Generate an image with the given prompt", | ||
parameters: z.object({ | ||
prompt: z.string().describe("The prompt to use for generating the image"), | ||
}), | ||
stage: "post", | ||
}); | ||
|
||
this.workersAI = workersAI; | ||
} | ||
|
||
async call({ prompt }, ctx) { | ||
const callToModel = await this.workersAI | ||
.callModel( | ||
{ | ||
model: "@cf/lykon/dreamshaper-8-lcm", | ||
input: { | ||
prompt, | ||
}, | ||
}, | ||
true, | ||
) | ||
.then((r) => r.arrayBuffer()) | ||
.catch(() => (e) => { | ||
console.error(e); | ||
return null; | ||
}); | ||
|
||
if (callToModel === null) return null; | ||
|
||
const buffer = Buffer.from(callToModel); | ||
|
||
return buffer; | ||
} | ||
} | ||
|
||
export class QoTDIntegration extends Integration { | ||
constructor() { | ||
super({ | ||
name: "qotd", | ||
description: "Get the quote of the day", | ||
parameters: z.object({ | ||
luckyWord: z.string().describe("The lucky word to randomise the quote with"), | ||
}), | ||
stage: "pre", | ||
}); | ||
} | ||
|
||
async call({ prompt }, ctx) { | ||
return { | ||
role: "system", | ||
content: "[Function call to QOTD]: The quote of the day is skeebeedee guyatt toilet.", | ||
}; | ||
} | ||
} |
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
Oops, something went wrong.