mirror of
https://github.com/Expand-sys/expandchatbotv2
synced 2026-03-22 12:27:11 +11:00
changes
This commit is contained in:
parent
18b175e34e
commit
6c6e8bc129
16 changed files with 67 additions and 12732 deletions
BIN
bun.lockb
Executable file
BIN
bun.lockb
Executable file
Binary file not shown.
|
|
@ -1,52 +0,0 @@
|
||||||
const deepai = require('deepai')
|
|
||||||
deepai.setApiKey(process.env.DEEPAI_API)
|
|
||||||
const https = require("https")
|
|
||||||
const http = require("http")
|
|
||||||
const fs = require("fs")
|
|
||||||
const { CommandInteraction, ApplicationCommandType, ApplicationCommandOptionType, EmbedBuilder } = require ('discord.js');
|
|
||||||
const { sendResponse, sendReply } = require ('../../../utils/utils');
|
|
||||||
const { Embed } = require ("@discordjs/builders");
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
name: `deepdream`,
|
|
||||||
description: `deep dream an image`,
|
|
||||||
cooldown: 5,
|
|
||||||
type: ApplicationCommandType.ChatInput,
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: `image`,
|
|
||||||
description: `your image to be edited by image generator`,
|
|
||||||
type: ApplicationCommandOptionType.Attachment,
|
|
||||||
required: true,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
/**
|
|
||||||
* @param {CommandInteraction} interaction
|
|
||||||
*/
|
|
||||||
async execute(interaction) {
|
|
||||||
let image_url = null
|
|
||||||
let imageurl = interaction.options.getAttachment("image").url
|
|
||||||
await interaction.deferReply()
|
|
||||||
|
|
||||||
var resp = await deepai.callStandardApi("deepdream", {
|
|
||||||
image: `${imageurl}`,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
let embed = await new Embed({
|
|
||||||
"type": "rich",
|
|
||||||
"title": ``,
|
|
||||||
"description": "",
|
|
||||||
"color": 0xa70909,
|
|
||||||
"image": {
|
|
||||||
"url": `${resp.output_url}`,
|
|
||||||
"height": 0,
|
|
||||||
"width": 0
|
|
||||||
},
|
|
||||||
|
|
||||||
})
|
|
||||||
await interaction.editReply({embeds: [embed]})
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
const deepai = require('deepai')
|
|
||||||
deepai.setApiKey(process.env.DEEPAI_API)
|
|
||||||
const https = require("https")
|
|
||||||
const http = require("http")
|
|
||||||
const fs = require("fs")
|
|
||||||
const { CommandInteraction, ApplicationCommandType, ApplicationCommandOptionType, EmbedBuilder } = require ('discord.js');
|
|
||||||
const { sendResponse, sendReply } = require ('../../../utils/utils');
|
|
||||||
const { Embed } = require ("@discordjs/builders");
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
name: `editimage`,
|
|
||||||
description: `Generate an image`,
|
|
||||||
cooldown: 5,
|
|
||||||
type: ApplicationCommandType.ChatInput,
|
|
||||||
options: [{
|
|
||||||
name: `prompt`,
|
|
||||||
description: `your prompt for the edit to image by the image generator`,
|
|
||||||
type: ApplicationCommandOptionType.String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: `image`,
|
|
||||||
description: `your image to be edited by image generator`,
|
|
||||||
type: ApplicationCommandOptionType.Attachment,
|
|
||||||
required: true,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
/**
|
|
||||||
* @param {CommandInteraction} interaction
|
|
||||||
*/
|
|
||||||
async execute(interaction) {
|
|
||||||
let image_url = null
|
|
||||||
let imageurl = interaction.options.getAttachment("image").url
|
|
||||||
console.log(interaction.options.getString("prompt"))
|
|
||||||
let prompt = interaction.options.getString("prompt")
|
|
||||||
await interaction.deferReply()
|
|
||||||
|
|
||||||
var resp = await deepai.callStandardApi("image-editor", {
|
|
||||||
image: `${imageurl}`,
|
|
||||||
text: `${prompt}`,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
let embed = await new Embed({
|
|
||||||
"type": "rich",
|
|
||||||
"title": `Prompt: ${interaction.options.getString("prompt")}`,
|
|
||||||
"description": "",
|
|
||||||
"color": 0xa70909,
|
|
||||||
"image": {
|
|
||||||
"url": `${resp.output_url}`,
|
|
||||||
"height": 0,
|
|
||||||
"width": 0
|
|
||||||
},
|
|
||||||
|
|
||||||
})
|
|
||||||
await interaction.editReply({embeds: [embed]})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
const { Configuration, OpenAIApi } = require("openai");
|
|
||||||
const configuration = new Configuration({
|
|
||||||
apiKey: process.env.OPENAI_API_KEY,
|
|
||||||
});
|
|
||||||
const openai = new OpenAIApi(configuration);
|
|
||||||
const { CommandInteraction, ApplicationCommandType, ApplicationCommandOptionType, EmbedBuilder } = require('discord.js');
|
|
||||||
const { sendResponse, sendReply } = require('../../../utils/utils');
|
|
||||||
const path = require('path');
|
|
||||||
const { send } = require('process');
|
|
||||||
const { Embed } = require("@discordjs/builders");
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
name: `image`,
|
|
||||||
description: `Generate an image`,
|
|
||||||
cooldown: 5,
|
|
||||||
type: ApplicationCommandType.ChatInput,
|
|
||||||
options: [{
|
|
||||||
name: `prompt`,
|
|
||||||
description: `your prompt for the image generator`,
|
|
||||||
type: ApplicationCommandOptionType.String,
|
|
||||||
required: true,
|
|
||||||
}],
|
|
||||||
/**
|
|
||||||
* @param {CommandInteraction} interaction
|
|
||||||
*/
|
|
||||||
async execute(interaction) {
|
|
||||||
let image_url = null
|
|
||||||
let error = null
|
|
||||||
console.log("rice")
|
|
||||||
await interaction.deferReply()
|
|
||||||
console.log("beans")
|
|
||||||
try{
|
|
||||||
const response = await openai.createImage({
|
|
||||||
prompt: `${interaction.options.getString("prompt")}`,
|
|
||||||
n: 1,
|
|
||||||
size: "512x512",
|
|
||||||
});
|
|
||||||
image_url = response.data.data[0].url;
|
|
||||||
error = response
|
|
||||||
console.log(error)
|
|
||||||
let embed = new Embed({
|
|
||||||
"type": "rich",
|
|
||||||
"title": `Prompt: ${interaction.options.getString("prompt")}`,
|
|
||||||
"description": "",
|
|
||||||
"color": 0xa70909,
|
|
||||||
"image": {
|
|
||||||
"url": `${image_url}`,
|
|
||||||
"height": 0,
|
|
||||||
"width": 0
|
|
||||||
},
|
|
||||||
|
|
||||||
})
|
|
||||||
sendResponse(interaction, ``, [embed])
|
|
||||||
} catch(e){
|
|
||||||
error = e.response.data.error.message
|
|
||||||
sendResponse(interaction, e.response.data.error.message)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,131 +0,0 @@
|
||||||
const { Configuration, OpenAIApi } = require("openai");
|
|
||||||
const { grpc } = require("@improbable-eng/grpc-web")
|
|
||||||
const {NodeHttpTransport } = require("@improbable-eng/grpc-web-node-http-transport")
|
|
||||||
grpc.setDefaultTransport(NodeHttpTransport());
|
|
||||||
|
|
||||||
const GenerationService = require("../../../generation/generation_pb_service")
|
|
||||||
const Generation = require("../../../generation/generation_pb")
|
|
||||||
|
|
||||||
const { CommandInteraction, ApplicationCommandType, ApplicationCommandOptionType, EmbedBuilder } = require('discord.js');
|
|
||||||
const { sendResponse, sendReply } = require('../../../utils/utils');
|
|
||||||
const path = require('path');
|
|
||||||
const { send } = require('process');
|
|
||||||
const { Embed } = require("@discordjs/builders");
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
name: `image2`,
|
|
||||||
description: `Generate an image`,
|
|
||||||
cooldown: 5,
|
|
||||||
type: ApplicationCommandType.ChatInput,
|
|
||||||
options: [{
|
|
||||||
name: `prompt`,
|
|
||||||
description: `your prompt for the image generator`,
|
|
||||||
type: ApplicationCommandOptionType.String,
|
|
||||||
required: true,
|
|
||||||
}],
|
|
||||||
/**
|
|
||||||
* @param {CommandInteraction} interaction
|
|
||||||
*/
|
|
||||||
async execute(interaction) {
|
|
||||||
const imageParams = new Generation.ImageParameters();
|
|
||||||
let sfbuffer
|
|
||||||
await interaction.deferReply()
|
|
||||||
imageParams.setWidth(512);
|
|
||||||
imageParams.setHeight(512);
|
|
||||||
imageParams.addSeed(11223344);
|
|
||||||
imageParams.setSamples(1);
|
|
||||||
imageParams.setSteps(75);
|
|
||||||
|
|
||||||
// Use the `k-dpmpp-2` sampler
|
|
||||||
const transformType = new Generation.TransformType();
|
|
||||||
transformType.setDiffusion(Generation.DiffusionSampler.SAMPLER_K_DPMPP_2M);
|
|
||||||
imageParams.setTransform(transformType);
|
|
||||||
|
|
||||||
// Use Stable Diffusion 2.0
|
|
||||||
const request = new Generation.Request();
|
|
||||||
request.setEngineId("stable-diffusion-512-v2-1");
|
|
||||||
request.setRequestedType(Generation.ArtifactType.ARTIFACT_IMAGE);
|
|
||||||
request.setClassifier(new Generation.ClassifierParameters());
|
|
||||||
|
|
||||||
// Use a CFG scale of `13`
|
|
||||||
const samplerParams = new Generation.SamplerParameters();
|
|
||||||
samplerParams.setCfgScale(13);
|
|
||||||
|
|
||||||
const stepParams = new Generation.StepParameter();
|
|
||||||
const scheduleParameters = new Generation.ScheduleParameters();
|
|
||||||
|
|
||||||
// Set the schedule to `0`, this changes when doing an initial image generation
|
|
||||||
stepParams.setScaledStep(0);
|
|
||||||
stepParams.setSampler(samplerParams);
|
|
||||||
stepParams.setSchedule(scheduleParameters);
|
|
||||||
|
|
||||||
imageParams.addParameters(stepParams);
|
|
||||||
request.setImage(imageParams);
|
|
||||||
|
|
||||||
// Set our text prompt
|
|
||||||
const promptText = new Generation.Prompt();
|
|
||||||
promptText.setText(
|
|
||||||
`${interaction.options.getString("prompt")}`
|
|
||||||
);
|
|
||||||
|
|
||||||
request.addPrompt(promptText);
|
|
||||||
|
|
||||||
// Authenticate using your API key, don't commit your key to a public repository!
|
|
||||||
const metadata = new grpc.Metadata();
|
|
||||||
metadata.set("Authorization", "Bearer " + process.env.API_KEY);
|
|
||||||
|
|
||||||
// Create a generation client
|
|
||||||
const generationClient = new GenerationService.GenerationServiceClient(
|
|
||||||
"https://grpc.stability.ai",
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Send the request using the `metadata` with our key from earlier
|
|
||||||
const generation = generationClient.generate(request, metadata);
|
|
||||||
|
|
||||||
// Set up a callback to handle data being returned
|
|
||||||
generation.on("data", (data) => {
|
|
||||||
console.log(data)
|
|
||||||
data.getArtifactsList().forEach( async (artifact) => {
|
|
||||||
// Oh no! We were filtered by the NSFW classifier!
|
|
||||||
if (
|
|
||||||
artifact.getType() === Generation.ArtifactType.ARTIFACT_TEXT &&
|
|
||||||
artifact.getFinishReason() === Generation.FinishReason.FILTER
|
|
||||||
) {
|
|
||||||
return console.error("Your image was filtered by the NSFW classifier.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure we have an image
|
|
||||||
if (artifact.getType() !== Generation.ArtifactType.ARTIFACT_IMAGE) return;
|
|
||||||
|
|
||||||
// You can convert the raw binary into a base64 string
|
|
||||||
|
|
||||||
// Here's how you get the seed back if you set it to `0` (random)
|
|
||||||
const seed = artifact.getSeed();
|
|
||||||
let b64 = artifact.getBinary_asB64()
|
|
||||||
// We're done!
|
|
||||||
|
|
||||||
let embed = new Embed({
|
|
||||||
"type": "rich",
|
|
||||||
"title": `Prompt: ${interaction.options.getString("prompt")}`,
|
|
||||||
"description": "",
|
|
||||||
"color": 0xa70909,
|
|
||||||
})
|
|
||||||
|
|
||||||
sendResponse(interaction, "", [embed], [Buffer.from(b64, "base64")])
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Anything other than `status.code === 0` is an error
|
|
||||||
generation.on("status", (status) => {
|
|
||||||
if (status.code === 0) return;
|
|
||||||
sendResponse("beep boop something went fucky wucky")
|
|
||||||
console.error(
|
|
||||||
"Your image could not be generated. You might not have enough credits."
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
46
commands/slashcommands/utility/prompt.js
Normal file
46
commands/slashcommands/utility/prompt.js
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
const { CommandInteraction, ApplicationCommandType, ApplicationCommandOptionType, EmbedBuilder } = require('discord.js');
|
||||||
|
const { sendResponse } = require('../../../utils/utils');
|
||||||
|
const path = require('path');
|
||||||
|
const { Ollama } = require('ollama')
|
||||||
|
const ollama = new Ollama({host: 'http://localhost:11434'})
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: `prompt`,
|
||||||
|
description: `prompt the bot for for a snarky response`,
|
||||||
|
cooldown: 30,
|
||||||
|
type: ApplicationCommandType.ChatInput,
|
||||||
|
options: [{
|
||||||
|
name: `prompt`,
|
||||||
|
description: `The question you want to ask the ai`,
|
||||||
|
type: ApplicationCommandOptionType.String,
|
||||||
|
required: true,
|
||||||
|
}],
|
||||||
|
/**
|
||||||
|
* @param {CommandInteraction} interaction
|
||||||
|
*/
|
||||||
|
async execute(interaction) {
|
||||||
|
const { member, options } = interaction;
|
||||||
|
|
||||||
|
await interaction.deferReply({ ephemeral: false }).catch(err => console.error(`${path.basename(__filename)} There was a problem deferring an interaction: `, err));
|
||||||
|
console.log(options.get("prompt"))
|
||||||
|
let response = await ollama.chat({
|
||||||
|
model: 'llama2',
|
||||||
|
messages: [
|
||||||
|
{ role: "system", content: `You are a know it all bot who doesnt have a clue about social ettiquite please respond to users messages in a way that will make them hate you, the users name is '${member.user.displayName}' refer to them by their name`},
|
||||||
|
{ role: 'user', content: options.get("prompt").value},
|
||||||
|
|
||||||
|
],
|
||||||
|
stream: false,
|
||||||
|
options: {
|
||||||
|
num_predict: 128
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const responseout = new EmbedBuilder()
|
||||||
|
.setColor('#32BEA6')
|
||||||
|
.setAuthor({ name: `${member.user.displayName }`, iconURL: member.user.displayAvatarURL({ dynamic: true }) })
|
||||||
|
.setTitle("Prompt: " + options.get("prompt").value)
|
||||||
|
.setDescription(response.message.content)
|
||||||
|
sendResponse(interaction, ``, [responseout]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,42 +1,33 @@
|
||||||
const cronjob = require('cron').CronJob;
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { promisify } = require('util');
|
const { promisify } = require('util');
|
||||||
|
const { Ollama } = require('ollama')
|
||||||
const { glob } = require('glob');
|
const { glob } = require('glob');
|
||||||
const PG = promisify(glob);
|
const PG = promisify(glob);
|
||||||
const { Configuration, OpenAIApi } = require("openai");
|
|
||||||
const configuration = new Configuration({
|
|
||||||
apiKey: process.env.OPENAI_API_KEY,
|
|
||||||
});
|
|
||||||
const openai = new OpenAIApi(configuration);
|
|
||||||
|
|
||||||
|
|
||||||
|
const ollama = new Ollama({host: 'http://localhost:11434'})
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'messageCreate',
|
name: 'messageCreate',
|
||||||
once: false,
|
once: false,
|
||||||
async execute(message, client, Discord) {
|
async execute(message, client, Discord) {
|
||||||
if (message.mentions.members.first()){
|
|
||||||
if (message.mentions.members.first().user.id == 216882708012466176) {
|
|
||||||
console.log(message)
|
console.log(message)
|
||||||
let question = message.content.split(" ")
|
let random = Math.random()*150
|
||||||
question.shift()
|
if (message.content.includes("?") && message.member.id != "216882708012466176"){
|
||||||
question = question.join(" ")
|
let response = await ollama.chat({
|
||||||
|
model: 'llama2',
|
||||||
let response = await openai.createChatCompletion({
|
messages: [
|
||||||
model: "gpt-3.5-turbo",
|
{ role: "system", content: "You are a know it all bot who doesnt have a clue about social ettiquite please respond to users messages in a way that will make them hate you and do not offer help in any way"},
|
||||||
|
{ role: 'user', content: message.content},
|
||||||
messages: [{"role": "user", "content":`${question}`}],
|
|
||||||
temperature: 0.9,
|
|
||||||
max_tokens: 500,
|
|
||||||
top_p: 0.3,
|
|
||||||
frequency_penalty: 0.9,
|
|
||||||
presence_penalty: 0.0
|
|
||||||
}
|
|
||||||
)
|
|
||||||
console.log(response.data)
|
|
||||||
await message.reply(response.data.choices[0].message)
|
|
||||||
|
|
||||||
|
|
||||||
|
],
|
||||||
|
stream: false,
|
||||||
|
options: {
|
||||||
|
num_predict: 128
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
console.log(response)
|
||||||
|
await message.reply(response.message.content)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
27
generation/generation_grpc_pb.d.ts
vendored
27
generation/generation_grpc_pb.d.ts
vendored
|
|
@ -1,27 +0,0 @@
|
||||||
// GENERATED CODE -- DO NOT EDIT!
|
|
||||||
|
|
||||||
// package: gooseai
|
|
||||||
// file: generation.proto
|
|
||||||
|
|
||||||
import * as generation_pb from "./generation_pb";
|
|
||||||
import * as grpc from "grpc";
|
|
||||||
|
|
||||||
interface IGenerationServiceService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
|
|
||||||
generate: grpc.MethodDefinition<generation_pb.Request, generation_pb.Answer>;
|
|
||||||
chainGenerate: grpc.MethodDefinition<generation_pb.ChainRequest, generation_pb.Answer>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const GenerationServiceService: IGenerationServiceService;
|
|
||||||
|
|
||||||
export interface IGenerationServiceServer extends grpc.UntypedServiceImplementation {
|
|
||||||
generate: grpc.handleServerStreamingCall<generation_pb.Request, generation_pb.Answer>;
|
|
||||||
chainGenerate: grpc.handleServerStreamingCall<generation_pb.ChainRequest, generation_pb.Answer>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class GenerationServiceClient extends grpc.Client {
|
|
||||||
constructor(address: string, credentials: grpc.ChannelCredentials, options?: object);
|
|
||||||
generate(argument: generation_pb.Request, metadataOrOptions?: grpc.Metadata | grpc.CallOptions | null): grpc.ClientReadableStream<generation_pb.Answer>;
|
|
||||||
generate(argument: generation_pb.Request, metadata?: grpc.Metadata | null, options?: grpc.CallOptions | null): grpc.ClientReadableStream<generation_pb.Answer>;
|
|
||||||
chainGenerate(argument: generation_pb.ChainRequest, metadataOrOptions?: grpc.Metadata | grpc.CallOptions | null): grpc.ClientReadableStream<generation_pb.Answer>;
|
|
||||||
chainGenerate(argument: generation_pb.ChainRequest, metadata?: grpc.Metadata | null, options?: grpc.CallOptions | null): grpc.ClientReadableStream<generation_pb.Answer>;
|
|
||||||
}
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
// GENERATED CODE -- DO NOT EDIT!
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
var grpc = require('grpc');
|
|
||||||
var generation_pb = require('./generation_pb.js');
|
|
||||||
var google_protobuf_struct_pb = require('google-protobuf/google/protobuf/struct_pb.js');
|
|
||||||
var tensors_pb = require('./tensors_pb.js');
|
|
||||||
|
|
||||||
function serialize_gooseai_Answer(arg) {
|
|
||||||
if (!(arg instanceof generation_pb.Answer)) {
|
|
||||||
throw new Error('Expected argument of type gooseai.Answer');
|
|
||||||
}
|
|
||||||
return Buffer.from(arg.serializeBinary());
|
|
||||||
}
|
|
||||||
|
|
||||||
function deserialize_gooseai_Answer(buffer_arg) {
|
|
||||||
return generation_pb.Answer.deserializeBinary(new Uint8Array(buffer_arg));
|
|
||||||
}
|
|
||||||
|
|
||||||
function serialize_gooseai_ChainRequest(arg) {
|
|
||||||
if (!(arg instanceof generation_pb.ChainRequest)) {
|
|
||||||
throw new Error('Expected argument of type gooseai.ChainRequest');
|
|
||||||
}
|
|
||||||
return Buffer.from(arg.serializeBinary());
|
|
||||||
}
|
|
||||||
|
|
||||||
function deserialize_gooseai_ChainRequest(buffer_arg) {
|
|
||||||
return generation_pb.ChainRequest.deserializeBinary(new Uint8Array(buffer_arg));
|
|
||||||
}
|
|
||||||
|
|
||||||
function serialize_gooseai_Request(arg) {
|
|
||||||
if (!(arg instanceof generation_pb.Request)) {
|
|
||||||
throw new Error('Expected argument of type gooseai.Request');
|
|
||||||
}
|
|
||||||
return Buffer.from(arg.serializeBinary());
|
|
||||||
}
|
|
||||||
|
|
||||||
function deserialize_gooseai_Request(buffer_arg) {
|
|
||||||
return generation_pb.Request.deserializeBinary(new Uint8Array(buffer_arg));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// gRPC services
|
|
||||||
//
|
|
||||||
var GenerationServiceService = exports.GenerationServiceService = {
|
|
||||||
generate: {
|
|
||||||
path: '/gooseai.GenerationService/Generate',
|
|
||||||
requestStream: false,
|
|
||||||
responseStream: true,
|
|
||||||
requestType: generation_pb.Request,
|
|
||||||
responseType: generation_pb.Answer,
|
|
||||||
requestSerialize: serialize_gooseai_Request,
|
|
||||||
requestDeserialize: deserialize_gooseai_Request,
|
|
||||||
responseSerialize: serialize_gooseai_Answer,
|
|
||||||
responseDeserialize: deserialize_gooseai_Answer,
|
|
||||||
},
|
|
||||||
chainGenerate: {
|
|
||||||
path: '/gooseai.GenerationService/ChainGenerate',
|
|
||||||
requestStream: false,
|
|
||||||
responseStream: true,
|
|
||||||
requestType: generation_pb.ChainRequest,
|
|
||||||
responseType: generation_pb.Answer,
|
|
||||||
requestSerialize: serialize_gooseai_ChainRequest,
|
|
||||||
requestDeserialize: deserialize_gooseai_ChainRequest,
|
|
||||||
responseSerialize: serialize_gooseai_Answer,
|
|
||||||
responseDeserialize: deserialize_gooseai_Answer,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.GenerationServiceClient = grpc.makeGenericClientConstructor(GenerationServiceService);
|
|
||||||
File diff suppressed because it is too large
Load diff
66
generation/generation_pb_service.d.ts
vendored
66
generation/generation_pb_service.d.ts
vendored
|
|
@ -1,66 +0,0 @@
|
||||||
// package: gooseai
|
|
||||||
// file: generation.proto
|
|
||||||
|
|
||||||
import * as generation_pb from "./generation_pb";
|
|
||||||
import {grpc} from "@improbable-eng/grpc-web";
|
|
||||||
|
|
||||||
type GenerationServiceGenerate = {
|
|
||||||
readonly methodName: string;
|
|
||||||
readonly service: typeof GenerationService;
|
|
||||||
readonly requestStream: false;
|
|
||||||
readonly responseStream: true;
|
|
||||||
readonly requestType: typeof generation_pb.Request;
|
|
||||||
readonly responseType: typeof generation_pb.Answer;
|
|
||||||
};
|
|
||||||
|
|
||||||
type GenerationServiceChainGenerate = {
|
|
||||||
readonly methodName: string;
|
|
||||||
readonly service: typeof GenerationService;
|
|
||||||
readonly requestStream: false;
|
|
||||||
readonly responseStream: true;
|
|
||||||
readonly requestType: typeof generation_pb.ChainRequest;
|
|
||||||
readonly responseType: typeof generation_pb.Answer;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class GenerationService {
|
|
||||||
static readonly serviceName: string;
|
|
||||||
static readonly Generate: GenerationServiceGenerate;
|
|
||||||
static readonly ChainGenerate: GenerationServiceChainGenerate;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ServiceError = { message: string, code: number; metadata: grpc.Metadata }
|
|
||||||
export type Status = { details: string, code: number; metadata: grpc.Metadata }
|
|
||||||
|
|
||||||
interface UnaryResponse {
|
|
||||||
cancel(): void;
|
|
||||||
}
|
|
||||||
interface ResponseStream<T> {
|
|
||||||
cancel(): void;
|
|
||||||
on(type: 'data', handler: (message: T) => void): ResponseStream<T>;
|
|
||||||
on(type: 'end', handler: (status?: Status) => void): ResponseStream<T>;
|
|
||||||
on(type: 'status', handler: (status: Status) => void): ResponseStream<T>;
|
|
||||||
}
|
|
||||||
interface RequestStream<T> {
|
|
||||||
write(message: T): RequestStream<T>;
|
|
||||||
end(): void;
|
|
||||||
cancel(): void;
|
|
||||||
on(type: 'end', handler: (status?: Status) => void): RequestStream<T>;
|
|
||||||
on(type: 'status', handler: (status: Status) => void): RequestStream<T>;
|
|
||||||
}
|
|
||||||
interface BidirectionalStream<ReqT, ResT> {
|
|
||||||
write(message: ReqT): BidirectionalStream<ReqT, ResT>;
|
|
||||||
end(): void;
|
|
||||||
cancel(): void;
|
|
||||||
on(type: 'data', handler: (message: ResT) => void): BidirectionalStream<ReqT, ResT>;
|
|
||||||
on(type: 'end', handler: (status?: Status) => void): BidirectionalStream<ReqT, ResT>;
|
|
||||||
on(type: 'status', handler: (status: Status) => void): BidirectionalStream<ReqT, ResT>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class GenerationServiceClient {
|
|
||||||
readonly serviceHost: string;
|
|
||||||
|
|
||||||
constructor(serviceHost: string, options?: grpc.RpcOptions);
|
|
||||||
generate(requestMessage: generation_pb.Request, metadata?: grpc.Metadata): ResponseStream<generation_pb.Answer>;
|
|
||||||
chainGenerate(requestMessage: generation_pb.ChainRequest, metadata?: grpc.Metadata): ResponseStream<generation_pb.Answer>;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,117 +0,0 @@
|
||||||
// package: gooseai
|
|
||||||
// file: generation.proto
|
|
||||||
|
|
||||||
var generation_pb = require("./generation_pb");
|
|
||||||
var grpc = require("@improbable-eng/grpc-web").grpc;
|
|
||||||
|
|
||||||
var GenerationService = (function () {
|
|
||||||
function GenerationService() {}
|
|
||||||
GenerationService.serviceName = "gooseai.GenerationService";
|
|
||||||
return GenerationService;
|
|
||||||
}());
|
|
||||||
|
|
||||||
GenerationService.Generate = {
|
|
||||||
methodName: "Generate",
|
|
||||||
service: GenerationService,
|
|
||||||
requestStream: false,
|
|
||||||
responseStream: true,
|
|
||||||
requestType: generation_pb.Request,
|
|
||||||
responseType: generation_pb.Answer
|
|
||||||
};
|
|
||||||
|
|
||||||
GenerationService.ChainGenerate = {
|
|
||||||
methodName: "ChainGenerate",
|
|
||||||
service: GenerationService,
|
|
||||||
requestStream: false,
|
|
||||||
responseStream: true,
|
|
||||||
requestType: generation_pb.ChainRequest,
|
|
||||||
responseType: generation_pb.Answer
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.GenerationService = GenerationService;
|
|
||||||
|
|
||||||
function GenerationServiceClient(serviceHost, options) {
|
|
||||||
this.serviceHost = serviceHost;
|
|
||||||
this.options = options || {};
|
|
||||||
}
|
|
||||||
|
|
||||||
GenerationServiceClient.prototype.generate = function generate(requestMessage, metadata) {
|
|
||||||
var listeners = {
|
|
||||||
data: [],
|
|
||||||
end: [],
|
|
||||||
status: []
|
|
||||||
};
|
|
||||||
var client = grpc.invoke(GenerationService.Generate, {
|
|
||||||
request: requestMessage,
|
|
||||||
host: this.serviceHost,
|
|
||||||
metadata: metadata,
|
|
||||||
transport: this.options.transport,
|
|
||||||
debug: this.options.debug,
|
|
||||||
onMessage: function (responseMessage) {
|
|
||||||
listeners.data.forEach(function (handler) {
|
|
||||||
handler(responseMessage);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onEnd: function (status, statusMessage, trailers) {
|
|
||||||
listeners.status.forEach(function (handler) {
|
|
||||||
handler({ code: status, details: statusMessage, metadata: trailers });
|
|
||||||
});
|
|
||||||
listeners.end.forEach(function (handler) {
|
|
||||||
handler({ code: status, details: statusMessage, metadata: trailers });
|
|
||||||
});
|
|
||||||
listeners = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
on: function (type, handler) {
|
|
||||||
listeners[type].push(handler);
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
cancel: function () {
|
|
||||||
listeners = null;
|
|
||||||
client.close();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
GenerationServiceClient.prototype.chainGenerate = function chainGenerate(requestMessage, metadata) {
|
|
||||||
var listeners = {
|
|
||||||
data: [],
|
|
||||||
end: [],
|
|
||||||
status: []
|
|
||||||
};
|
|
||||||
var client = grpc.invoke(GenerationService.ChainGenerate, {
|
|
||||||
request: requestMessage,
|
|
||||||
host: this.serviceHost,
|
|
||||||
metadata: metadata,
|
|
||||||
transport: this.options.transport,
|
|
||||||
debug: this.options.debug,
|
|
||||||
onMessage: function (responseMessage) {
|
|
||||||
listeners.data.forEach(function (handler) {
|
|
||||||
handler(responseMessage);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onEnd: function (status, statusMessage, trailers) {
|
|
||||||
listeners.status.forEach(function (handler) {
|
|
||||||
handler({ code: status, details: statusMessage, metadata: trailers });
|
|
||||||
});
|
|
||||||
listeners.end.forEach(function (handler) {
|
|
||||||
handler({ code: status, details: statusMessage, metadata: trailers });
|
|
||||||
});
|
|
||||||
listeners = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
on: function (type, handler) {
|
|
||||||
listeners[type].push(handler);
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
cancel: function () {
|
|
||||||
listeners = null;
|
|
||||||
client.close();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.GenerationServiceClient = GenerationServiceClient;
|
|
||||||
|
|
||||||
172
generation/tensors_pb.d.ts
vendored
172
generation/tensors_pb.d.ts
vendored
|
|
@ -1,172 +0,0 @@
|
||||||
// package: tensors
|
|
||||||
// file: tensors.proto
|
|
||||||
|
|
||||||
import * as jspb from "google-protobuf";
|
|
||||||
|
|
||||||
export class Tensor extends jspb.Message {
|
|
||||||
getDtype(): DtypeMap[keyof DtypeMap];
|
|
||||||
setDtype(value: DtypeMap[keyof DtypeMap]): void;
|
|
||||||
|
|
||||||
clearShapeList(): void;
|
|
||||||
getShapeList(): Array<number>;
|
|
||||||
setShapeList(value: Array<number>): void;
|
|
||||||
addShape(value: number, index?: number): number;
|
|
||||||
|
|
||||||
getData(): Uint8Array | string;
|
|
||||||
getData_asU8(): Uint8Array;
|
|
||||||
getData_asB64(): string;
|
|
||||||
setData(value: Uint8Array | string): void;
|
|
||||||
|
|
||||||
hasAttrType(): boolean;
|
|
||||||
clearAttrType(): void;
|
|
||||||
getAttrType(): AttributeTypeMap[keyof AttributeTypeMap];
|
|
||||||
setAttrType(value: AttributeTypeMap[keyof AttributeTypeMap]): void;
|
|
||||||
|
|
||||||
serializeBinary(): Uint8Array;
|
|
||||||
toObject(includeInstance?: boolean): Tensor.AsObject;
|
|
||||||
static toObject(includeInstance: boolean, msg: Tensor): Tensor.AsObject;
|
|
||||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
|
||||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
|
||||||
static serializeBinaryToWriter(message: Tensor, writer: jspb.BinaryWriter): void;
|
|
||||||
static deserializeBinary(bytes: Uint8Array): Tensor;
|
|
||||||
static deserializeBinaryFromReader(message: Tensor, reader: jspb.BinaryReader): Tensor;
|
|
||||||
}
|
|
||||||
|
|
||||||
export namespace Tensor {
|
|
||||||
export type AsObject = {
|
|
||||||
dtype: DtypeMap[keyof DtypeMap],
|
|
||||||
shapeList: Array<number>,
|
|
||||||
data: Uint8Array | string,
|
|
||||||
attrType: AttributeTypeMap[keyof AttributeTypeMap],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Attribute extends jspb.Message {
|
|
||||||
getName(): string;
|
|
||||||
setName(value: string): void;
|
|
||||||
|
|
||||||
hasModule(): boolean;
|
|
||||||
clearModule(): void;
|
|
||||||
getModule(): Module | undefined;
|
|
||||||
setModule(value?: Module): void;
|
|
||||||
|
|
||||||
hasTensor(): boolean;
|
|
||||||
clearTensor(): void;
|
|
||||||
getTensor(): Tensor | undefined;
|
|
||||||
setTensor(value?: Tensor): void;
|
|
||||||
|
|
||||||
hasString(): boolean;
|
|
||||||
clearString(): void;
|
|
||||||
getString(): string;
|
|
||||||
setString(value: string): void;
|
|
||||||
|
|
||||||
hasInt64(): boolean;
|
|
||||||
clearInt64(): void;
|
|
||||||
getInt64(): number;
|
|
||||||
setInt64(value: number): void;
|
|
||||||
|
|
||||||
hasFloat(): boolean;
|
|
||||||
clearFloat(): void;
|
|
||||||
getFloat(): number;
|
|
||||||
setFloat(value: number): void;
|
|
||||||
|
|
||||||
hasBool(): boolean;
|
|
||||||
clearBool(): void;
|
|
||||||
getBool(): boolean;
|
|
||||||
setBool(value: boolean): void;
|
|
||||||
|
|
||||||
getValueCase(): Attribute.ValueCase;
|
|
||||||
serializeBinary(): Uint8Array;
|
|
||||||
toObject(includeInstance?: boolean): Attribute.AsObject;
|
|
||||||
static toObject(includeInstance: boolean, msg: Attribute): Attribute.AsObject;
|
|
||||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
|
||||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
|
||||||
static serializeBinaryToWriter(message: Attribute, writer: jspb.BinaryWriter): void;
|
|
||||||
static deserializeBinary(bytes: Uint8Array): Attribute;
|
|
||||||
static deserializeBinaryFromReader(message: Attribute, reader: jspb.BinaryReader): Attribute;
|
|
||||||
}
|
|
||||||
|
|
||||||
export namespace Attribute {
|
|
||||||
export type AsObject = {
|
|
||||||
name: string,
|
|
||||||
module?: Module.AsObject,
|
|
||||||
tensor?: Tensor.AsObject,
|
|
||||||
string: string,
|
|
||||||
int64: number,
|
|
||||||
pb_float: number,
|
|
||||||
bool: boolean,
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum ValueCase {
|
|
||||||
VALUE_NOT_SET = 0,
|
|
||||||
MODULE = 3,
|
|
||||||
TENSOR = 4,
|
|
||||||
STRING = 5,
|
|
||||||
INT64 = 6,
|
|
||||||
FLOAT = 7,
|
|
||||||
BOOL = 8,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Module extends jspb.Message {
|
|
||||||
getName(): string;
|
|
||||||
setName(value: string): void;
|
|
||||||
|
|
||||||
clearNamesList(): void;
|
|
||||||
getNamesList(): Array<string>;
|
|
||||||
setNamesList(value: Array<string>): void;
|
|
||||||
addNames(value: string, index?: number): string;
|
|
||||||
|
|
||||||
clearAttributesList(): void;
|
|
||||||
getAttributesList(): Array<Attribute>;
|
|
||||||
setAttributesList(value: Array<Attribute>): void;
|
|
||||||
addAttributes(value?: Attribute, index?: number): Attribute;
|
|
||||||
|
|
||||||
serializeBinary(): Uint8Array;
|
|
||||||
toObject(includeInstance?: boolean): Module.AsObject;
|
|
||||||
static toObject(includeInstance: boolean, msg: Module): Module.AsObject;
|
|
||||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
|
||||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
|
||||||
static serializeBinaryToWriter(message: Module, writer: jspb.BinaryWriter): void;
|
|
||||||
static deserializeBinary(bytes: Uint8Array): Module;
|
|
||||||
static deserializeBinaryFromReader(message: Module, reader: jspb.BinaryReader): Module;
|
|
||||||
}
|
|
||||||
|
|
||||||
export namespace Module {
|
|
||||||
export type AsObject = {
|
|
||||||
name: string,
|
|
||||||
namesList: Array<string>,
|
|
||||||
attributesList: Array<Attribute.AsObject>,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DtypeMap {
|
|
||||||
DT_INVALID: 0;
|
|
||||||
DT_FLOAT32: 1;
|
|
||||||
DT_FLOAT64: 2;
|
|
||||||
DT_FLOAT16: 3;
|
|
||||||
DT_BFLOAT16: 4;
|
|
||||||
DT_COMPLEX32: 5;
|
|
||||||
DT_COMPLEX64: 6;
|
|
||||||
DT_COMPLEX128: 7;
|
|
||||||
DT_UINT8: 8;
|
|
||||||
DT_INT8: 9;
|
|
||||||
DT_INT16: 10;
|
|
||||||
DT_INT32: 11;
|
|
||||||
DT_INT64: 12;
|
|
||||||
DT_BOOL: 13;
|
|
||||||
DT_QUINT8: 14;
|
|
||||||
DT_QINT8: 15;
|
|
||||||
DT_QINT32: 16;
|
|
||||||
DT_QUINT4_2: 17;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const Dtype: DtypeMap;
|
|
||||||
|
|
||||||
export interface AttributeTypeMap {
|
|
||||||
AT_PARAMETER: 0;
|
|
||||||
AT_BUFFER: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const AttributeType: AttributeTypeMap;
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load diff
5
index.js
5
index.js
|
|
@ -1,12 +1,7 @@
|
||||||
console.time('Time to online');
|
|
||||||
require("dotenv").config();
|
require("dotenv").config();
|
||||||
const Discord = require("discord.js");
|
const Discord = require("discord.js");
|
||||||
const client = new Discord.Client({ intents: [Discord.GatewayIntentBits.Guilds, Discord.GatewayIntentBits.GuildMessages, Discord.GatewayIntentBits.MessageContent], partials: [Discord.Partials.Channel] });
|
const client = new Discord.Client({ intents: [Discord.GatewayIntentBits.Guilds, Discord.GatewayIntentBits.GuildMessages, Discord.GatewayIntentBits.MessageContent], partials: [Discord.Partials.Channel] });
|
||||||
|
|
||||||
require('console-stamp')(console, {
|
|
||||||
format: ':date(dd mmmm yyyy HH:MM:ss) :label'
|
|
||||||
});
|
|
||||||
|
|
||||||
client.setMaxListeners(0);
|
client.setMaxListeners(0);
|
||||||
client.commands = new Discord.Collection();
|
client.commands = new Discord.Collection();
|
||||||
client.events = new Discord.Collection();
|
client.events = new Discord.Collection();
|
||||||
|
|
|
||||||
|
|
@ -17,16 +17,17 @@
|
||||||
"@discordjs/voice": "^0.8.0",
|
"@discordjs/voice": "^0.8.0",
|
||||||
"@improbable-eng/grpc-web": "^0.15.0",
|
"@improbable-eng/grpc-web": "^0.15.0",
|
||||||
"@improbable-eng/grpc-web-node-http-transport": "^0.15.0",
|
"@improbable-eng/grpc-web-node-http-transport": "^0.15.0",
|
||||||
"console-stamp": "^3.0.4",
|
"console-stamp": "^3.1.2",
|
||||||
"cron": "^1.8.2",
|
"cron": "^1.8.2",
|
||||||
"deepai": "^1.0.21",
|
"deepai": "^1.0.21",
|
||||||
"discord-api-types": "^0.20.2",
|
"discord-api-types": "^0.20.2",
|
||||||
"discord.js": "^14.7.1",
|
"discord.js": "^14.13.0",
|
||||||
"dotenv": "^9.0.2",
|
"dotenv": "^9.0.2",
|
||||||
"gifencoder": "^2.0.1",
|
"gifencoder": "^2.0.1",
|
||||||
"glob": "^7.2.0",
|
"glob": "^7.2.0",
|
||||||
"got": "^12.5.3",
|
"got": "^12.5.3",
|
||||||
"nodemon": "^2.0.19",
|
"nodemon": "^2.0.19",
|
||||||
|
"ollama": "^0.5.0",
|
||||||
"openai": "^3.2.1",
|
"openai": "^3.2.1",
|
||||||
"os": "^0.1.2",
|
"os": "^0.1.2",
|
||||||
"pm2": "^5.1.2"
|
"pm2": "^5.1.2"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue