From bef1aef78407a50f6fb672e464f3043aa6cc0027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daphn=C3=A9=20Popin?= Date: Thu, 12 Oct 2023 10:28:55 +0200 Subject: [PATCH 1/5] User: introduce first and last name (#2065) * User: introduce first and last name * change logic get user name --- front/lib/models/user.ts | 10 ++++++++++ front/lib/user.ts | 15 +++++++++++++++ front/pages/api/login.ts | 16 ++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/front/lib/models/user.ts b/front/lib/models/user.ts index d2569fd77bde..45fb4ff52545 100644 --- a/front/lib/models/user.ts +++ b/front/lib/models/user.ts @@ -21,6 +21,8 @@ export class User extends Model< declare username: string; declare email: string; declare name: string; + declare firstName: string | null; + declare lastName: string | null; declare isDustSuperUser: CreationOptional; } @@ -61,6 +63,14 @@ User.init( type: DataTypes.STRING, allowNull: false, }, + firstName: { + type: DataTypes.STRING, + allowNull: true, + }, + lastName: { + type: DataTypes.STRING, + allowNull: true, + }, isDustSuperUser: { type: DataTypes.BOOLEAN, defaultValue: false, diff --git a/front/lib/user.ts b/front/lib/user.ts index 024b1e639a38..85396c6037c0 100644 --- a/front/lib/user.ts +++ b/front/lib/user.ts @@ -58,3 +58,18 @@ export function setUserMetadataFromClient(metadata: UserMetadataType) { } })(); } + +export const guessFirstandLastNameFromFullName = ( + fullName: string +): { firstName: string | null; lastName: string | null } => { + if (!fullName) return { firstName: null, lastName: null }; + + const nameParts = fullName.split(" "); + + if (nameParts.length === 1) return { firstName: fullName, lastName: null }; + + const firstName = nameParts.shift() || null; + const lastName = nameParts.join(" "); + + return { firstName, lastName }; +}; diff --git a/front/pages/api/login.ts b/front/pages/api/login.ts index 97d633085502..7db5995aec82 100644 --- a/front/pages/api/login.ts +++ b/front/pages/api/login.ts @@ -11,6 +11,7 @@ import { User, Workspace, } from "@app/lib/models"; +import { guessFirstandLastNameFromFullName } from "@app/lib/user"; import { generateModelSId } from "@app/lib/utils"; import { apiError, withLogging } from "@app/logger/withlogging"; @@ -129,18 +130,33 @@ async function handler( user.username = session.user.username; user.email = session.user.email; user.name = session.user.name; + + if (!user.firstName && !user.lastName) { + const { firstName, lastName } = guessFirstandLastNameFromFullName( + session.user.name + ); + user.firstName = firstName; + user.lastName = lastName; + } + await user.save(); } // The user does not exist. We create it and create a personal workspace if there is no invite // associated with the login request. if (!user) { + const { firstName, lastName } = guessFirstandLastNameFromFullName( + session.user.name + ); + user = await User.create({ provider: session.provider.provider, providerId: session.provider.id.toString(), username: session.user.username, email: session.user.email, name: session.user.name, + firstName, + lastName, }); // If there is no invte, we create a personal workspace for the user, otherwise the user From e1ad9f95b8742d24ebfc433593c52dbaa157bd3c Mon Sep 17 00:00:00 2001 From: Stanislas Polu Date: Thu, 12 Oct 2023 10:30:44 +0200 Subject: [PATCH 2/5] DustAppRun action block execution in UI (#2076) --- .../assistant/conversation/DustAppRunAction.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/front/components/assistant/conversation/DustAppRunAction.tsx b/front/components/assistant/conversation/DustAppRunAction.tsx index 5632b8265caf..af48322432cf 100644 --- a/front/components/assistant/conversation/DustAppRunAction.tsx +++ b/front/components/assistant/conversation/DustAppRunAction.tsx @@ -64,9 +64,16 @@ export default function DustAppRunAction({
{!dustAppRunAction.output ? (
-
- Executing {dustAppRunAction.appName}... -
+ {dustAppRunAction.runningBlock ? ( +
+ Executing app {dustAppRunAction.appName}: running block{" "} + {dustAppRunAction.runningBlock.name}... +
+ ) : ( +
+ Executing app {dustAppRunAction.appName}... +
+ )}
) : ( From fa6e60da50c2d26a71c65aebf2859bd8ec75f989 Mon Sep 17 00:00:00 2001 From: Stanislas Polu Date: Thu, 12 Oct 2023 10:52:20 +0200 Subject: [PATCH 3/5] Actually use useWorkspaceCredentials (#2078) --- front/lib/api/assistant/actions/dust_app_run.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/front/lib/api/assistant/actions/dust_app_run.ts b/front/lib/api/assistant/actions/dust_app_run.ts index 81949921c6ae..029e209439fa 100644 --- a/front/lib/api/assistant/actions/dust_app_run.ts +++ b/front/lib/api/assistant/actions/dust_app_run.ts @@ -400,6 +400,8 @@ export async function* runDustApp( useLocalInDev: true, }); + // As we run the app (using a system API key here), we do force using the workspace credentials so + // that the app executes in the exact same conditions in which they were developed. const runRes = await api.runAppStreamed( { workspaceId: c.appWorkspaceId, @@ -407,7 +409,8 @@ export async function* runDustApp( appHash: "latest", }, appConfig, - [params] + [params], + { useWorkspaceCredentials: true } ); if (runRes.isErr()) { From 2f23dbb8a50131d3bdae8a2fe0a9e2c2cede57cf Mon Sep 17 00:00:00 2001 From: Stanislas Polu Date: Thu, 12 Oct 2023 11:04:01 +0200 Subject: [PATCH 4/5] hotfix query variable --- front/pages/api/v1/w/[wId]/apps/[aId]/runs/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/pages/api/v1/w/[wId]/apps/[aId]/runs/index.ts b/front/pages/api/v1/w/[wId]/apps/[aId]/runs/index.ts index 7e871106b100..40365f7ae39d 100644 --- a/front/pages/api/v1/w/[wId]/apps/[aId]/runs/index.ts +++ b/front/pages/api/v1/w/[wId]/apps/[aId]/runs/index.ts @@ -120,7 +120,7 @@ async function handler( // This variable is used in the context of the DustAppRun action to use the workspace credentials // instead of our managed credentials when running an app with a system API key. - const useWorkspaceCredentials = !!req.query.useWorkspaceCredentials; + const useWorkspaceCredentials = !!req.query["use_workspace_credentials"]; switch (req.method) { case "POST": From 289a80321df818043386e361ffc155fc4ef806cc Mon Sep 17 00:00:00 2001 From: Edouard Wautier <4435185+Duncid@users.noreply.github.com> Date: Thu, 12 Oct 2023 11:38:50 +0200 Subject: [PATCH 5/5] Sparkle24 (#2079) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bumping front's version of Sparkle * Sparkle Bump --------- Co-authored-by: édouard wautier --- front/package-lock.json | 8 ++++---- front/package.json | 2 +- sparkle/package-lock.json | 4 ++-- sparkle/package.json | 2 +- sparkle/src/components/Page.tsx | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/front/package-lock.json b/front/package-lock.json index 0651da3a9a34..1da69435461d 100644 --- a/front/package-lock.json +++ b/front/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@dust-tt/sparkle": "0.2.2", + "@dust-tt/sparkle": "0.2.4", "@emoji-mart/data": "^1.1.2", "@emoji-mart/react": "^1.1.1", "@headlessui/react": "^1.7.7", @@ -727,9 +727,9 @@ "license": "Apache-2.0" }, "node_modules/@dust-tt/sparkle": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/@dust-tt/sparkle/-/sparkle-0.2.2.tgz", - "integrity": "sha512-95Dyj5o2uRtBqVOMSrk1q0fUdRASPXKY2csvvW9tZ4rteuUdQcYuURA4Tf/htPXNu8q/Tmxb4zNUFlKSE9IXbg==", + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/@dust-tt/sparkle/-/sparkle-0.2.4.tgz", + "integrity": "sha512-l5GucAfTOpnncEHNwAbp+2nPC80tuu1EdW0DKaR6os5dz/ZRqqMYhmFGxMaDD7A6/i0kB5qhhvAllUJgfwMckA==", "dependencies": { "@headlessui/react": "^1.7.17" }, diff --git a/front/package.json b/front/package.json index 50be633185ad..16e85c71df19 100644 --- a/front/package.json +++ b/front/package.json @@ -13,7 +13,7 @@ "initdb": "env $(cat .env.local) npx tsx admin/db.ts" }, "dependencies": { - "@dust-tt/sparkle": "0.2.2", + "@dust-tt/sparkle": "0.2.4", "@emoji-mart/data": "^1.1.2", "@emoji-mart/react": "^1.1.1", "@headlessui/react": "^1.7.7", diff --git a/sparkle/package-lock.json b/sparkle/package-lock.json index 96d7b6e879a4..fae12a2139ba 100644 --- a/sparkle/package-lock.json +++ b/sparkle/package-lock.json @@ -1,12 +1,12 @@ { "name": "@dust-tt/sparkle", - "version": "0.2.4", + "version": "0.2.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@dust-tt/sparkle", - "version": "0.2.4", + "version": "0.2.5", "license": "ISC", "dependencies": { "@headlessui/react": "^1.7.17" diff --git a/sparkle/package.json b/sparkle/package.json index a42cad0b0a47..63d218a4b392 100644 --- a/sparkle/package.json +++ b/sparkle/package.json @@ -1,6 +1,6 @@ { "name": "@dust-tt/sparkle", - "version": "0.2.4", + "version": "0.2.5", "scripts": { "build": "rm -rf dist && rollup -c", "build:with-tw-base": "rollup -c --environment INCLUDE_TW_BASE:true", diff --git a/sparkle/src/components/Page.tsx b/sparkle/src/components/Page.tsx index 023edd48be23..0c841176e4b7 100644 --- a/sparkle/src/components/Page.tsx +++ b/sparkle/src/components/Page.tsx @@ -30,7 +30,7 @@ Page.Header = function ({ title, description, icon }: PageHeaderProps) { return ( - {title} + {title} {description && {description}} );