-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Improved so that the AI bot responds to personal messages and to messages in which it was mentioned #9334
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
base: develop
Are you sure you want to change the base?
Conversation
Connected to Huly®: UBERF-11731 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request refactors the AI bot response logic to improve the handling of personal messages and mentions while preserving existing direct message functionality. Key changes include:
- Extraction of helper functions (findAiBotSocialIdentity, findAiBotAllSocialIds, isThreadMessage, getMessageDoc, isDirectAvailable, isAiBotShouldReplay, and OnAiBotShouldReplay) to organize message processing logic.
- Update of message filtering and condition checks to decide when the AI bot should send a response.
- Removal of duplicate code and streamlining of direct and thread message handling.
Comments suppressed due to low confidence (1)
server-plugins/ai-bot-resources/src/index.ts:154
- [nitpick] Consider renaming 'isAiBotShouldReplay' to 'isAiBotShouldReply' to more clearly reflect its purpose of determining whether the AI bot should reply to a message.
): Promise<boolean> {
4917372
to
6179dba
Compare
…at mention it (hcengineering#9328) Signed-off-by: Evgeny Tarasenko <tarasenko.evgeny@gmail.com>
Signed-off-by: Evgeny Tarasenko <tarasenko.evgeny@gmail.com>
d245b1c
to
018d43c
Compare
const isDirect = | ||
messageDoc._class === chunter.class.DirectMessage && (await isDirectAvailable(messageDoc as DirectMessage, control)) | ||
const isAiBotPersonalChat = messageDoc._id === aiBotPersonId | ||
const isAiBotMentioned = message.message.includes(aiBotPersonId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not enough to check just includes(id)
. We need to ensure there's a mention node
and inspect its attributes to confirm it's indeed referencing ai
. You can look at how isDocMentioned
works in server-plugins/activity-resources/src/references.ts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, refactored with honest checking in references.
Signed-off-by: Evgeny Tarasenko <tarasenko.evgeny@gmail.com>
I would also suggest switching from the openai library to https://ai-sdk.dev in the ai-bot service so as not to depend on OpenAI as a provider, but I did not understand how to test the functionality of calling tools from the UI and I am afraid of breaking something.
Resolves #9328