mirror of
https://github.com/block/goose.git
synced 2026-07-09 16:09:22 +00:00
feat: askai bot hints for followups (#10291)
Some checks are pending
CI / changes (push) Waiting to run
CI / Check Rust Code Format (push) Blocked by required conditions
CI / Build and Test Rust Project (push) Blocked by required conditions
CI / Build Rust Project on Windows (push) Waiting to run
CI / Check MSRV (push) Blocked by required conditions
CI / Lint Rust Code (push) Blocked by required conditions
CI / Check Generated Schemas are Up-to-Date (push) Blocked by required conditions
CI / Test and Lint Electron Desktop App (push) Blocked by required conditions
Create Minor Release PR / check-version-bump-pr (push) Waiting to run
Create Minor Release PR / release (push) Blocked by required conditions
Live Provider Tests / check-fork (push) Waiting to run
Live Provider Tests / changes (push) Blocked by required conditions
Live Provider Tests / Build Binary (push) Blocked by required conditions
Live Provider Tests / Smoke Tests (push) Blocked by required conditions
Live Provider Tests / Smoke Tests (Code Execution) (push) Blocked by required conditions
Canary / Prepare Version (push) Waiting to run
Canary / build-cli (push) Blocked by required conditions
Canary / Upload Install Script (push) Blocked by required conditions
Canary / bundle-desktop (push) Blocked by required conditions
Canary / bundle-desktop-intel (push) Blocked by required conditions
Canary / bundle-desktop-linux (push) Blocked by required conditions
Canary / bundle-desktop-windows (push) Blocked by required conditions
Canary / bundle-desktop-windows-cuda (push) Blocked by required conditions
Canary / Release (push) Blocked by required conditions
Live Provider Tests / Compaction Tests (push) Blocked by required conditions
Publish Ask AI Bot Docker Image / docker (push) Waiting to run
Publish Docker Image / docker (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Some checks are pending
CI / changes (push) Waiting to run
CI / Check Rust Code Format (push) Blocked by required conditions
CI / Build and Test Rust Project (push) Blocked by required conditions
CI / Build Rust Project on Windows (push) Waiting to run
CI / Check MSRV (push) Blocked by required conditions
CI / Lint Rust Code (push) Blocked by required conditions
CI / Check Generated Schemas are Up-to-Date (push) Blocked by required conditions
CI / Test and Lint Electron Desktop App (push) Blocked by required conditions
Create Minor Release PR / check-version-bump-pr (push) Waiting to run
Create Minor Release PR / release (push) Blocked by required conditions
Live Provider Tests / check-fork (push) Waiting to run
Live Provider Tests / changes (push) Blocked by required conditions
Live Provider Tests / Build Binary (push) Blocked by required conditions
Live Provider Tests / Smoke Tests (push) Blocked by required conditions
Live Provider Tests / Smoke Tests (Code Execution) (push) Blocked by required conditions
Canary / Prepare Version (push) Waiting to run
Canary / build-cli (push) Blocked by required conditions
Canary / Upload Install Script (push) Blocked by required conditions
Canary / bundle-desktop (push) Blocked by required conditions
Canary / bundle-desktop-intel (push) Blocked by required conditions
Canary / bundle-desktop-linux (push) Blocked by required conditions
Canary / bundle-desktop-windows (push) Blocked by required conditions
Canary / bundle-desktop-windows-cuda (push) Blocked by required conditions
Canary / Release (push) Blocked by required conditions
Live Provider Tests / Compaction Tests (push) Blocked by required conditions
Publish Ask AI Bot Docker Image / docker (push) Waiting to run
Publish Docker Image / docker (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
This commit is contained in:
parent
af2c765c82
commit
f96f62d985
1 changed files with 49 additions and 0 deletions
|
|
@ -9,6 +9,48 @@ import { answerQuestion } from "../utils/ai";
|
|||
import { buildServerContext } from "../utils/discord/server-context";
|
||||
import { logger } from "../utils/logger";
|
||||
|
||||
async function shouldSendFollowUpHint(
|
||||
message: OmitPartialGroupDMChannel<Message<boolean>>,
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
const thread = message.channel;
|
||||
if (!thread.isThread()) return false;
|
||||
|
||||
const botId = message.client.user?.id || "";
|
||||
const starterMessage = await thread.fetchStarterMessage().catch(() => null);
|
||||
|
||||
const messages = await thread.messages.fetch({ limit: 20 });
|
||||
|
||||
let hasOtherHumanMessages = false;
|
||||
let botWasPingedOrRepliedTo = false;
|
||||
|
||||
for (const msg of messages.values()) {
|
||||
if (msg.author.bot) continue;
|
||||
if (starterMessage && msg.id === starterMessage.id) continue;
|
||||
if (msg.id === message.id) continue;
|
||||
|
||||
hasOtherHumanMessages = true;
|
||||
|
||||
if (msg.mentions.has(botId)) {
|
||||
botWasPingedOrRepliedTo = true;
|
||||
}
|
||||
|
||||
if (msg.reference?.messageId && !botWasPingedOrRepliedTo) {
|
||||
const referenced = await thread.messages
|
||||
.fetch(msg.reference.messageId)
|
||||
.catch(() => null);
|
||||
if (referenced?.author.bot) {
|
||||
botWasPingedOrRepliedTo = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return !hasOtherHumanMessages && !botWasPingedOrRepliedTo;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
event: Events.MessageCreate,
|
||||
handler: async (
|
||||
|
|
@ -56,6 +98,13 @@ export default {
|
|||
logger.verbose(
|
||||
`Ignoring thread message from ${message.author.username} (not mentioned or replied to)`,
|
||||
);
|
||||
|
||||
if (await shouldSendFollowUpHint(message)) {
|
||||
await message.channel.send(
|
||||
"To ask me a follow-up, please **reply to one of my messages** or **@mention me**. I won't see messages sent otherwise.",
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue