From 6a1f6bacff2f852f3f7cef81181236b9faf3a4da Mon Sep 17 00:00:00 2001 From: Saravanan Date: Wed, 6 Nov 2024 15:19:56 +0530 Subject: [PATCH 1/2] chore: add isModelDoc Attribute for AI learning --- .../src/lib/altimate/altimate-components.d.ts | 3 +- webview_panels/src/lib/altimate/main.js | 71 ++++++++++--------- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/webview_panels/src/lib/altimate/altimate-components.d.ts b/webview_panels/src/lib/altimate/altimate-components.d.ts index a8afde858..4737e7351 100644 --- a/webview_panels/src/lib/altimate/altimate-components.d.ts +++ b/webview_panels/src/lib/altimate/altimate-components.d.ts @@ -66,7 +66,7 @@ export declare interface CoachAiResponse { personalizationScope: string; } -export declare const CoachForm: ({ taskLabel, context, onClose }: Props_10) => JSX_2.Element; +export declare const CoachForm: ({ taskLabel, context, onClose, extra }: Props_10) => JSX_2.Element; export declare const CoachFormButton: ({}: Props_11) => JSX_2.Element; @@ -286,6 +286,7 @@ declare interface Props extends ButtonHTMLAttributes { declare interface Props_10 { taskLabel: keyof typeof TaskLabels; context?: Record; + extra?: Record; onClose: () => void; } diff --git a/webview_panels/src/lib/altimate/main.js b/webview_panels/src/lib/altimate/main.js index 7d9394862..98320eae8 100644 --- a/webview_panels/src/lib/altimate/main.js +++ b/webview_panels/src/lib/altimate/main.js @@ -24710,45 +24710,46 @@ const Kc = () => { }, {}); }, Jx = pt.object({ content: pt.string().min(10, { message: "Feedback must be at least 10 characters" }).max(500, { message: "Feedback must not exceed 500 characters" }).min(1, { message: "Feedback is required" }) -}), rA = ({ taskLabel: e, context: t, onClose: n }) => { - const [o, r] = ue(), [a, i] = ue(!1), l = (b) => { - r(b); - }, s = () => { - i(!0); +}), rA = ({ taskLabel: e, context: t, onClose: n, extra: o = {} }) => { + const [r, a] = ue(), [i, l] = ue(!1), s = (y) => { + a(y); }, u = () => { - i(!1); - }, c = async () => { - if (o) - return u(), await Pe.post( + l(!0); + }, c = () => { + l(!1); + }, d = async () => { + if (r) + return c(), await Pe.post( "coach/training/confirm", { - content: o.ai_response, - category: o.category, + content: r.ai_response, + category: r.category, taskLabel: e, - personalizationScope: o.personalizationScope, - metadata: t + personalizationScope: r.personalizationScope, + metadata: t, + ...o } ); }, { - mutate: d, - error: h, - loading: f, - data: m + mutate: h, + error: f, + loading: m, + data: b } = Wa({ // @ts-ignore - queryFn: c, + queryFn: d, onSuccess: () => { - i(!1); + l(!1); } }); - return m != null && m.frontend_url ? /* @__PURE__ */ p.jsxs(Us, { children: [ + return b != null && b.frontend_url ? /* @__PURE__ */ p.jsxs(Us, { children: [ "Thank you for coaching Datapilot. Click the link to", " ", /* @__PURE__ */ p.jsx( "a", { className: "alert-link", - href: `${m.frontend_url}/teammates/${e}?learning=${m.train_doc_uid}`, + href: `${b.frontend_url}/teammates/${e}?learning=${b.train_doc_uid}`, children: "View learnings" } ) @@ -24761,39 +24762,39 @@ const Kc = () => { onSubmit: () => { }, validate: Qx(Jx), - children: (b) => /* @__PURE__ */ p.jsx( + children: (y) => /* @__PURE__ */ p.jsx( Xx, { - ...b, + ...y, taskLabel: e, - onSuccess: l, + onSuccess: s, onCancel: n } ) } ), - o && /* @__PURE__ */ p.jsxs(sn, { className: "mt-4", children: [ + r && /* @__PURE__ */ p.jsxs(sn, { className: "mt-4", children: [ /* @__PURE__ */ p.jsxs(Rn, { children: [ /* @__PURE__ */ p.jsx("p", { children: "Below are the learnings by AI based on the entered instructions:" }), - /* @__PURE__ */ p.jsx("div", { children: a ? /* @__PURE__ */ p.jsx( + /* @__PURE__ */ p.jsx("div", { children: i ? /* @__PURE__ */ p.jsx( Ln, { type: "textarea", - value: o.ai_response, - onChange: (b) => { - r({ - ...o, - ai_response: b.target.value + value: r.ai_response, + onChange: (y) => { + a({ + ...r, + ai_response: y.target.value }); }, style: { fieldSizing: "content" } } - ) : o.ai_response }), - h && /* @__PURE__ */ p.jsx("div", { className: "text-danger", children: h.message }) + ) : r.ai_response }), + f && /* @__PURE__ */ p.jsx("div", { className: "text-danger", children: f.message }) ] }), /* @__PURE__ */ p.jsxs(M5, { className: "d-flex justify-content-end mt-2 gap-2 border-0", children: [ - a ? /* @__PURE__ */ p.jsx($e, { variant: "secondary", onClick: u, children: "Cancel" }) : /* @__PURE__ */ p.jsx($e, { variant: "secondary", onClick: s, children: "Edit" }), - /* @__PURE__ */ p.jsx($a, { loading: f, onClick: d, color: "primary", children: "Save" }) + i ? /* @__PURE__ */ p.jsx($e, { variant: "secondary", onClick: c, children: "Cancel" }) : /* @__PURE__ */ p.jsx($e, { variant: "secondary", onClick: u, children: "Edit" }), + /* @__PURE__ */ p.jsx($a, { loading: m, onClick: h, color: "primary", children: "Save" }) ] }) ] }) ] }); From a9c73b6339d53bec2273a33f326f9a2203d5f29b Mon Sep 17 00:00:00 2001 From: Saravanan Date: Wed, 6 Nov 2024 15:20:04 +0530 Subject: [PATCH 2/2] chore: add isModelDoc Attribute for AI learning --- .../src/modules/documentationEditor/DocumentationEditor.tsx | 5 ++++- .../documentationEditor/components/docGenerator/CoachAi.tsx | 3 +++ .../components/docGenerator/CoachAiIfModified.tsx | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/webview_panels/src/modules/documentationEditor/DocumentationEditor.tsx b/webview_panels/src/modules/documentationEditor/DocumentationEditor.tsx index 9548c9ffd..de88fc206 100644 --- a/webview_panels/src/modules/documentationEditor/DocumentationEditor.tsx +++ b/webview_panels/src/modules/documentationEditor/DocumentationEditor.tsx @@ -195,7 +195,10 @@ const DocumentationEditor = (): JSX.Element => { /> - + diff --git a/webview_panels/src/modules/documentationEditor/components/docGenerator/CoachAi.tsx b/webview_panels/src/modules/documentationEditor/components/docGenerator/CoachAi.tsx index 1d7b664fd..7d7ad2c05 100644 --- a/webview_panels/src/modules/documentationEditor/components/docGenerator/CoachAi.tsx +++ b/webview_panels/src/modules/documentationEditor/components/docGenerator/CoachAi.tsx @@ -7,8 +7,10 @@ import classes from "./coachAi.module.scss"; const CoachAi = ({ context, + extra, }: { context?: Record; + extra?: Record; }): JSX.Element | null => { const drawerRef = useRef(null); const { dispatch } = useTeamMateContext(); @@ -41,6 +43,7 @@ const CoachAi = ({ taskLabel="DocGen" context={context} onClose={() => drawerRef.current?.close()} + extra={extra} /> ); diff --git a/webview_panels/src/modules/documentationEditor/components/docGenerator/CoachAiIfModified.tsx b/webview_panels/src/modules/documentationEditor/components/docGenerator/CoachAiIfModified.tsx index 941974288..74b537ac6 100644 --- a/webview_panels/src/modules/documentationEditor/components/docGenerator/CoachAiIfModified.tsx +++ b/webview_panels/src/modules/documentationEditor/components/docGenerator/CoachAiIfModified.tsx @@ -6,9 +6,11 @@ import classes from "./coachAi.module.scss"; const CoachAiIfModified = ({ column, model, + extra, }: { column?: string; model?: string; + extra?: Record; }): JSX.Element | null => { const { state: { @@ -39,6 +41,7 @@ const CoachAiIfModified = ({ Do you want to coach datapilot? Click here{" "} );