Content-Length: 344854 | pFad | http://github.com/spongedsc/pathways/pull/100/commits/dd525244685057adfa9a58c0fdfcd75c8fb7bad9

F9 [rfc-implementation] Integrations by daniwasonline · Pull Request #100 · spongedsc/pathways · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rfc-implementation] Integrations #100

Draft
wants to merge 36 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
99b5f98
✨ Export __loader_exclude = true to exclude a file from loading
daniwasonline Jun 2, 2024
e1dffea
📝 Enforce namespace package ID format, finish documenting CallsystemS…
daniwasonline Jun 2, 2024
9dcd6af
✨ general changes to other things, related to integrations idk
daniwasonline Jun 3, 2024
ca00bd5
more changes to miscellaneous things with callsystems
daniwasonline Jun 3, 2024
5aac9b3
✨ Integrations (this code is such a mess dear god)
daniwasonline Jun 3, 2024
1331e31
🧑‍💻 use responseTransform instead of an inline ternary
daniwasonline Jun 3, 2024
2bb76de
✨ weather integration
daniwasonline Jun 3, 2024
434e260
➕ add vercel ai and zod
daniwasonline Jun 3, 2024
f75e679
🐛 fix no image response issues
daniwasonline Jun 3, 2024
3ebb0af
holy crack what the hell is going on with legacy
daniwasonline Jun 3, 2024
7dada7b
add response transformer defaults
daniwasonline Jun 3, 2024
793bfdc
button stuff in integrations
daniwasonline Jun 3, 2024
0e78af5
weather woohoo
daniwasonline Jun 3, 2024
f26e633
⬆️ Update discord.js to 14.15.3 (again)
daniwasonline Jul 17, 2024
4abede4
⏪ Attachment editing has been re-enabled, let's push this out again
daniwasonline Jul 17, 2024
8419caa
⚡️ (messily) migrate to workers AI for the integration caller
daniwasonline Jul 18, 2024
b386ec9
🐛 weather "object Object" fix
daniwasonline Jul 18, 2024
5ec83d2
🚸 Log number of integrations on start-up
daniwasonline Jul 18, 2024
b5ae756
⬆️ ➕ Add zod-to-json-schema
daniwasonline Jul 18, 2024
4d77008
🐛 Fix loads of bugs in the History algorithm
daniwasonline Jul 18, 2024
d3a5229
⚡️ Improve performance of non-Legacy models by removing image instruc…
daniwasonline Jul 19, 2024
2722c33
🎨 ✨ ⚡️ Multi-model chaining support, button customisation, code cleanup
daniwasonline Jul 19, 2024
4297837
📝 Update environment example with further info
daniwasonline Jul 19, 2024
a5c14e1
✨ Add and update integrations (imagine, sleep)
daniwasonline Jul 19, 2024
8ac9271
🚚 Maybe it shouldn't be called.. duct tape?
daniwasonline Jul 19, 2024
14b03de
🚸 Quality of life to Legacy for Integration fallback scenarios
daniwasonline Jul 19, 2024
bbc56a9
✨ Wikipedia integration
daniwasonline Jul 19, 2024
13767e5
✨ Wake up (and other improvements)
daniwasonline Jul 19, 2024
e07acc4
Add fallbacks for certain scenarios
daniwasonline Jul 19, 2024
e706afa
i forgot what was in here lol
daniwasonline Jul 19, 2024
ab7adf8
➕ HTML => Markdown and Wikipedia
daniwasonline Jul 19, 2024
3aeaa33
lockbun
daniwasonline Jul 19, 2024
cedd8be
🐛 Fix exception thrown when text overflow occurs
daniwasonline Jul 19, 2024
98eec27
🚸 add mod tags
daniwasonline Jul 19, 2024
dd52524
✨ 🚚 search instead of wikipedia
daniwasonline Jul 19, 2024
f7e553b
📝 perplexity toggle
daniwasonline Jul 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
✨ 🚚 search instead of wikipedia
  • Loading branch information
daniwasonline committed Jul 19, 2024
commit dd525244685057adfa9a58c0fdfcd75c8fb7bad9
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import wiki from "wikipedia";
import { tool } from "ai";
import dedent from "dedent";
import { NodeHtmlMarkdown } from "node-html-markdown";
import { Caller } from "../../../callsystems/spongedsc/integrations/models/openai.js";
export default class HelloWorld extends Integration {
constructor(opts) {
const { env, message, client, std, provider } = opts || {};
Expand All @@ -26,11 +27,12 @@ export default class HelloWorld extends Integration {
return {
type: "function",
function: tool({
name: "wikipedia",
name: "search",
description:
"Get information about a topic from Wikipedia. Trigger this integration when a user asks you to look up something on Wikipedia.",
"Get information about a topic. Trigger this integration when a user asks you to look up something on Wikipedia.",
parameters: z.object({
topic: z.string().describe("The topic to look up on Wikipedia."),
topic: z.string().describe("The topic to look up."),
question: z.string().describe("Describe or ask what you want to know."),
full: z
.boolean()
.describe(
Expand All @@ -47,12 +49,7 @@ export default class HelloWorld extends Integration {
return new Date("2024-07-18");
}

/**
* This function is called when the integration is activated by the Integrations callsystem.
* @param {object[]} arguments The arguments passed to the integration.
* @returns {Promise<IntegrationResponse>} The response to the activation request.
*/
async activate({ arguments: args }) {
async wikipedia(args) {
const { env, message, client } = this;

const search = await wiki
Expand Down Expand Up @@ -99,4 +96,66 @@ export default class HelloWorld extends Integration {
},
};
}

async perplexity(args) {
const { env, message, client } = this;

const caller = new Caller({
key: env.OPENROUTER_ACCOUNT_TOKEN,
apiUrl: "https://openrouter.ai/api/v1",
});

const search = await caller
.call({
model: "perplexity/llama-3-sonar-small-32k-online",
messages: [
{
role: "system",
content: "This is the topic that the user is looking for: " + args.topic,
},
{
role: "user",
content: args.question,
},
],
})
.then((r) => r.text)
.catch((e) => {
return false;
});

if (search === false) return await this.wikipedia(args);

return {
success: true,
messages: [
{
role: "tool",
content: dedent`
Perplexity returned the following result:
${search}
`,
},
],
data: {
buttonUrl: "https://perplexity.ai/search?q=" + args.topic.replaceAll(" ", "%20"),
buttonText: `Perplexity: ${args.question}`.slice(0, 50),
},
};
}

/**
* This function is called when the integration is activated by the Integrations callsystem.
* @param {object[]} arguments The arguments passed to the integration.
* @returns {Promise<IntegrationResponse>} The response to the activation request.
*/
async activate({ arguments: args }) {
const { env, message, client } = this;

if (!args.question || env.GM_PERPLEXITY === "true") {
return await this.perplexity(args);
} else {
return await this.wikipedia(args);
}
}
}








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/spongedsc/pathways/pull/100/commits/dd525244685057adfa9a58c0fdfcd75c8fb7bad9

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy