Compare commits
2 commits
02a5b0f7b9
...
74359067d0
Author | SHA1 | Date | |
---|---|---|---|
74359067d0 | |||
24e85f535a |
4 changed files with 21 additions and 2 deletions
|
@ -17,3 +17,4 @@ RUN npx tsc
|
|||
|
||||
# Run the app
|
||||
CMD ["node", "dist/src/index.js"]
|
||||
STOPSIGNAL SIGINT
|
||||
|
|
|
@ -246,7 +246,7 @@ async function executeFromQueue(channel: string) {
|
|||
...config.chatCompletionParams,
|
||||
messages: OpenAImessages,
|
||||
// FIXME: don't use new instance of FunctionManager
|
||||
functions: new FunctionManager().getFunctions(),
|
||||
functions: new FunctionManager().getFunctionsForOpenAi(),
|
||||
});
|
||||
|
||||
logUsedTokens(answer, message, ++functionRanCounter);
|
||||
|
|
|
@ -62,6 +62,11 @@ export default class FunctionManager {
|
|||
return rvalue;
|
||||
}
|
||||
|
||||
public getFunctionsForOpenAi(): ChatCompletionFunctions[] | undefined {
|
||||
const rvalue = this.getFunctions();
|
||||
return rvalue.length > 0 ? rvalue : undefined;
|
||||
}
|
||||
|
||||
public handleFunction(request: ChatCompletionFunctionCall): ChatCompletionMessageParam {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let parsedArguments: any;
|
||||
|
|
15
src/index.ts
15
src/index.ts
|
@ -63,4 +63,17 @@ discord.on("messageCreate", message => {
|
|||
return queueRequest(message);
|
||||
});
|
||||
|
||||
if (require.main === module) void discord.login(config.tokens.Discord);
|
||||
if (require.main === module) {
|
||||
void discord.login(config.tokens.Discord);
|
||||
process.on("SIGINT", () => {
|
||||
console.log("got SIGINT, exiting");
|
||||
//FIXME: finish executing requests then exit
|
||||
discord.destroy()
|
||||
.then(() => process.exit())
|
||||
.catch((e) => {
|
||||
console.error("Failed to gracefully exit");
|
||||
console.error(e);
|
||||
process.exit();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue