-
Notifications
You must be signed in to change notification settings - Fork 216
Fix/nao admin bug 1145 #1209
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
Fix/nao admin bug 1145 #1209
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ import { buildImageUrl } from '../utils/image'; | |
| interface HandleAgentMessageInput extends AgentRequest { | ||
| userId: string; | ||
| projectId: string | undefined; | ||
| isProjectAdmin: boolean; | ||
| } | ||
|
|
||
| interface HandleAgentMessageResult { | ||
|
|
@@ -25,14 +26,19 @@ interface HandleAgentMessageResult { | |
| } | ||
|
|
||
| export const handleAgentRoute = async (opts: HandleAgentMessageInput): Promise<HandleAgentMessageResult> => { | ||
| const { userId, message, messageToEditId, model, mentions, projectId, adminMode } = opts; | ||
| const { userId, message, messageToEditId, model, mentions, projectId, isProjectAdmin } = opts; | ||
|
|
||
| if (!projectId) { | ||
| throw new HandlerError('BAD_REQUEST', noProjectMessage()); | ||
| } | ||
|
|
||
| await agentService.assertBudget(projectId, model); | ||
|
|
||
| let adminMode = opts.adminMode ?? false; | ||
| if (opts.adminMode === undefined && isProjectAdmin && opts.chatId) { | ||
| adminMode = await chatQueries.wasLastUserMessageAdmin(opts.chatId); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: Follow-up admin messages with omitted Prompt for AI agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure if last user message or first user message should be considered, to me if the first message is source=admin then all the messages in the convo should be but the issue with this is that it forces it under the hood even if the user deactivate the admin mode in the frontend
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes actually that's what caused the issue. Whether that should be the first message or the last, I think most recent makes more sense |
||
| } | ||
|
|
||
| const source: MessageSource = adminMode ? 'admin' : 'web'; | ||
| let chatId = opts.chatId; | ||
| const isNewChat = !chatId; | ||
|
|
||
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.
unpack the adminMode if used twice