-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display the assistants last author picture and name in the feedback p…
…opover (#9032) * Display the assistants last author picture and name in the feedback popover * Update sparkle * lint
- Loading branch information
Showing
7 changed files
with
141 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
front/pages/api/w/[wId]/assistant/agent_configurations/[aId]/last_author.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import type { UserType, WithAPIErrorResponse } from "@dust-tt/types"; | ||
import type { NextApiRequest, NextApiResponse } from "next"; | ||
|
||
import { getAgentConfiguration } from "@app/lib/api/assistant/configuration"; | ||
import { withSessionAuthenticationForWorkspace } from "@app/lib/api/auth_wrappers"; | ||
import type { Authenticator } from "@app/lib/auth"; | ||
import { UserResource } from "@app/lib/resources/user_resource"; | ||
import { apiError } from "@app/logger/withlogging"; | ||
|
||
export type GetAgentLastAuthorResponseBody = { | ||
user: UserType | null; | ||
}; | ||
|
||
async function handler( | ||
req: NextApiRequest, | ||
res: NextApiResponse<WithAPIErrorResponse<GetAgentLastAuthorResponseBody>>, | ||
auth: Authenticator | ||
): Promise<void> { | ||
switch (req.method) { | ||
case "GET": | ||
const agentConfiguration = await getAgentConfiguration( | ||
auth, | ||
req.query.aId as string | ||
); | ||
if (!agentConfiguration) { | ||
return apiError(req, res, { | ||
status_code: 404, | ||
api_error: { | ||
type: "agent_configuration_not_found", | ||
message: "The Assistant you're trying to access was not found.", | ||
}, | ||
}); | ||
} | ||
|
||
if (!agentConfiguration.versionAuthorId) { | ||
return apiError(req, res, { | ||
status_code: 404, | ||
api_error: { | ||
type: "agent_last_author_not_found", | ||
message: "The last author of this assistant was not found.", | ||
}, | ||
}); | ||
} | ||
|
||
const agentLastAuthor = await UserResource.fetchByModelIds([ | ||
agentConfiguration.versionAuthorId, | ||
]); | ||
|
||
return res.status(200).json({ | ||
user: agentLastAuthor[0] ? agentLastAuthor[0].toJSON() : null, | ||
}); | ||
|
||
default: | ||
return apiError(req, res, { | ||
status_code: 405, | ||
api_error: { | ||
type: "method_not_supported_error", | ||
message: "The method passed is not supported, POST is expected.", | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
export default withSessionAuthenticationForWorkspace(handler); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters