Skip to content
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

Epic: Jovu Phase 2 #8341

Merged
merged 48 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
492bfb4
fix(client):update text
yuval-hazaz Apr 24, 2024
ea730ee
style(client):temp jovu logo
yuval-hazaz Apr 28, 2024
ad57245
feat(server): add plugin catalog data for Jovu
yuval-hazaz Apr 28, 2024
9e1fa87
feat(server):install plugin from jovu
yuval-hazaz Apr 28, 2024
5b10155
feat(server): create multiple plugins
yuval-hazaz Apr 28, 2024
51cfe22
feat(server):add module functions for assistant service
yuval-hazaz Apr 28, 2024
846ed70
feat(server):Jovu create dto
yuval-hazaz Apr 29, 2024
611aff7
feat(client):decrease the size of description field
yuval-hazaz Apr 29, 2024
7abdd11
feat(client):improve dto UX
yuval-hazaz Apr 29, 2024
efb1e4a
fix(server):initialize properties
yuval-hazaz Apr 29, 2024
5fb3c0b
feat(client):auto select module navigation item
yuval-hazaz Apr 29, 2024
d836cc1
fix(client):remove unused imports
yuval-hazaz Apr 29, 2024
d562be5
fix(server): fix flow
yuval-hazaz Apr 29, 2024
82e68d6
Merge branch 'next' into feat/jovu-plugins
yuval-hazaz Apr 29, 2024
4bc0516
Merge branch 'feat/jovu-plugins' into feat/jovu-api
yuval-hazaz Apr 29, 2024
71b16b1
fix(client):expand navigation item on URL change
yuval-hazaz Apr 29, 2024
9f2b7ec
fix(server):plugins url
yuval-hazaz Apr 29, 2024
43c5ff9
Merge branch 'feat/jovu-plugins' of https://github.com/amplication/am…
yuval-hazaz Apr 29, 2024
dae8f5f
Merge branch 'feat/jovu-plugins' into feat/jovu-api
yuval-hazaz Apr 29, 2024
eedd314
Merge branch 'feat/jovu-api' into style/dto-properties-ux
yuval-hazaz Apr 29, 2024
7b1e37f
style(client):remove left padding
yuval-hazaz Apr 29, 2024
f625f58
Merge branch 'style/dto-properties-ux' of https://github.com/amplicat…
yuval-hazaz Apr 29, 2024
4ba7858
feast(server):jovu create enum
yuval-hazaz Apr 29, 2024
54f14b4
feat(server):add support to get a list of actions in the assistant
yuval-hazaz Apr 29, 2024
b21c97c
feat(server):create action with jovu
yuval-hazaz Apr 29, 2024
0fb6591
feat(server):force jovu limitations
yuval-hazaz Apr 30, 2024
8900de2
feat(client):force jovu limitations
yuval-hazaz Apr 30, 2024
8ccf278
test(server):fix test
yuval-hazaz May 1, 2024
e5a32e0
Merge branch 'feat/jovu-create-enum' into feat/jovu-get-actions
yuval-hazaz May 1, 2024
83bc41b
Merge branch 'feat/jovu-get-actions' into feat/jovu-create-action
yuval-hazaz May 1, 2024
d0bba09
Merge branch 'feat/jovu-create-action' into feat/jovu-usage-limits
yuval-hazaz May 1, 2024
eccde6d
feat(client):update contact us URL
yuval-hazaz May 1, 2024
dda7577
Merge branch 'feat/jovu-usage-limits' of https://github.com/amplicati…
yuval-hazaz May 1, 2024
49f472c
Merge pull request #8350 from amplication/feat/jovu-create-action
yuval-hazaz May 1, 2024
882dc1e
Merge pull request #8348 from amplication/feat/jovu-get-actions
yuval-hazaz May 1, 2024
825d6cb
Merge pull request #8343 from amplication/style/dto-properties-ux
yuval-hazaz May 1, 2024
1e6d764
Merge pull request #8346 from amplication/feat/jovu-create-enum
yuval-hazaz May 1, 2024
fe5e734
Merge pull request #8342 from amplication/feat/jovu-api
yuval-hazaz May 1, 2024
041bd60
Merge branch 'next' into feat/jovu-plugins
yuval-hazaz May 1, 2024
dca1a30
chore(server):remove unused code
yuval-hazaz May 1, 2024
b90216d
test(server):create test for assistant service
yuval-hazaz May 1, 2024
4336414
test(server):add test
yuval-hazaz May 1, 2024
3ea8571
test(server):test function execution
yuval-hazaz May 1, 2024
281157a
test(server):test function execution
yuval-hazaz May 1, 2024
9484883
Merge pull request #8358 from amplication/feat/jovu-usage-limits
yuval-hazaz May 1, 2024
f52db31
test(server):use beforeAll
yuval-hazaz May 2, 2024
63ad873
Merge pull request #8365 from amplication/test/assistant-service
yuval-hazaz May 2, 2024
f4c739d
Merge branch 'next' into feat/jovu-plugins
yuval-hazaz May 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"Formik",
"IBLOCK",
"isequalwith",
"jovu",
"kafkajs",
"linkcode",
"logform",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
resize: none;
}

textarea.text-input__textarea--small {
height: var(--textarea-height-small);
}

&--has-error {
input,
textarea {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type Props = React.HTMLProps<HTMLTextAreaElement | HTMLInputElement> & {
hideLabel?: boolean;
hasError?: boolean;
textarea?: boolean;
textareaSize?: "small" | "large";
labelType?: LabelTypes;
inputToolTip?: InputToolTipProps | undefined;
};
Expand All @@ -28,6 +29,7 @@ export function TextInput({
textarea,
labelType,
inputToolTip,
textareaSize = "large",
...rest
}: Props) {
const key = rest.key || rest.autoFocus?.toString();
Expand All @@ -48,6 +50,7 @@ export function TextInput({
<textarea
{...rest}
ref={inputRef as React.Ref<HTMLTextAreaElement>}
className={`${CLASS_NAME}__textarea--${textareaSize}`}
/>
) : (
<input
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback } from "react";
import { NavLink } from "react-router-dom";
import React, { useCallback, useEffect } from "react";
import { NavLink, useRouteMatch } from "react-router-dom";
import { Icon } from "../Icon/Icon";
import classNames from "classnames";
import { VerticalNavigation } from "./VerticalNavigation";
Expand Down Expand Up @@ -30,6 +30,10 @@ export function VerticalNavigationItem({
}: Props) {
const [expanded, setExpanded] = React.useState(false);

const match = useRouteMatch({
path: to,
});

const handleExpand = useCallback(
(e: any) => {
e.preventDefault();
Expand All @@ -40,6 +44,12 @@ export function VerticalNavigationItem({
[onExpand, setExpanded]
);

useEffect(() => {
if (match) {
setExpanded(true);
}
}, [match?.path]);

return (
<>
<NavLink
Expand Down
1 change: 1 addition & 0 deletions libs/util/billing-types/src/lib/billing-feature.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum BillingFeature {
GitLab = "feature-gitlab",
IgnoreValidationCodeGeneration = "feature-ignore-validation-code-generation",
ImportDBSchema = "feature-import-db-schema",
JovuRequests = "feature-jovu-requests",
Notification = "feature-notifications",
Projects = "feature-projects",
RedesignArchitecture = "feature-redesign-architecture",
Expand Down
14 changes: 14 additions & 0 deletions packages/amplication-client/src/Assistant/Assistant.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ $assistant-width: 350px;
$assistant-handle-width: 24px;
$assistant-handle-top: 150px;
$assistant-handle-margin: 40px;
$avatar-size: 30px;

#root {
// --assistant-background: var(--theme-gradient);
Expand Down Expand Up @@ -75,6 +76,12 @@ $assistant-handle-margin: 40px;
}
}

&__limit {
padding: var(--default-spacing);
flex: 1;
text-align: center;
}

&__header {
display: flex;
flex-direction: row;
Expand Down Expand Up @@ -109,6 +116,7 @@ $assistant-handle-margin: 40px;
gap: var(--default-spacing);
overflow-y: auto;
padding: var(--default-spacing);
padding-left: 0;
font-size: var(--tag-font-size);
}

Expand Down Expand Up @@ -199,5 +207,11 @@ $assistant-handle-margin: 40px;
justify-content: flex-start;
font-weight: semi-bold;
color: var(--assistant-role-color);

.user-avatar__initials {
width: $avatar-size;
height: $avatar-size;
font-size: var(--h3-font-size);
}
}
}
79 changes: 73 additions & 6 deletions packages/amplication-client/src/Assistant/Assistant.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import {
EnumContentAlign,
EnumFlexDirection,
EnumGapSize,
EnumItemsAlign,
EnumTextAlign,
EnumTextColor,
EnumTextStyle,
FlexItem,
Icon,
Text,
TextField,
Expand All @@ -17,6 +23,11 @@ import AssistantMessage from "./AssistantMessage";
import classNames from "classnames";
import { useAppContext } from "../context/appContext";
import { Link } from "react-router-dom";
import jovu from "../assets/jovu.svg";
import { BillingFeature } from "@amplication/util-billing-types";
import { useStiggContext } from "@stigg/react-sdk";
import { GET_CONTACT_US_LINK } from "../Workspaces/queries/workspaceQueries";
import { useQuery } from "@apollo/client";
type SendMessageType = models.SendAssistantMessageInput;

const INITIAL_VALUES: SendMessageType = {
Expand Down Expand Up @@ -52,6 +63,16 @@ const WIDTH_STATE_SETTINGS: Record<
const Assistant = () => {
const { currentWorkspace } = useAppContext();

const { stigg } = useStiggContext();

const { hasAccess } = stigg.getMeteredEntitlement({
featureId: BillingFeature.JovuRequests,
});

const { data } = useQuery(GET_CONTACT_US_LINK, {
variables: { id: currentWorkspace.id },
});

const [open, setOpen] = useState(true);
const [widthState, setWidthState] = useState(WIDTH_STATE_DEFAULT);

Expand All @@ -65,7 +86,6 @@ const Assistant = () => {
const {
sendMessage,
messages,
sendMessageError: error,
processingMessage: loading,
streamError,
} = useAssistant();
Expand Down Expand Up @@ -100,7 +120,13 @@ const Assistant = () => {
)}
>
<div className={`${CLASS_NAME}__header`}>
<Icon icon="ai" color={EnumTextColor.White} size="large" />
<img
src={jovu}
alt="jovu"
width={30}
height={30}
style={{ background: "white", borderRadius: "50%" }}
/>
<Text className={`${CLASS_NAME}__title`} textStyle={EnumTextStyle.H4}>
Jovu (Beta)
</Text>
Expand Down Expand Up @@ -133,7 +159,51 @@ const Assistant = () => {
</Tooltip>
</div>

{currentWorkspace?.allowLLMFeatures ? (
{!hasAccess ? (
<FlexItem
direction={EnumFlexDirection.Column}
itemsAlign={EnumItemsAlign.Center}
contentAlign={EnumContentAlign.Center}
gap={EnumGapSize.Large}
className={`${CLASS_NAME}__limit`}
>
<img
src={jovu}
alt="jovu"
width={50}
height={50}
style={{ background: "white", borderRadius: "50%" }}
/>
<Text textStyle={EnumTextStyle.H3} textAlign={EnumTextAlign.Center}>
You have reached the daily limit of Jovu requests for your plan.
</Text>
<Text
textStyle={EnumTextStyle.Tag}
textAlign={EnumTextAlign.Center}
>
Talk with us to upgrade and discover additional hidden
functionalities.
</Text>
<Text
textColor={EnumTextColor.White}
textStyle={EnumTextStyle.Tag}
textAlign={EnumTextAlign.Center}
>
<a
className={`${CLASS_NAME}__addon-section__contact-us`}
href={data?.contactUsLink}
target="blank"
>
<Text
textColor={EnumTextColor.ThemeTurquoise}
textStyle={EnumTextStyle.Tag}
>
Talk with us
</Text>
</a>
</Text>
</FlexItem>
) : currentWorkspace?.allowLLMFeatures ? (
<>
<div className={`${CLASS_NAME}__messages`}>
{messages.map((message) => (
Expand All @@ -145,9 +215,6 @@ const Assistant = () => {
))}

<div ref={messagesEndRef} />
{error && (
<div className={`${CLASS_NAME}__error`}>{error.message}</div>
)}
{streamError && (
<div className={`${CLASS_NAME}__error`}>
{streamError.message}
Expand Down
19 changes: 11 additions & 8 deletions packages/amplication-client/src/Assistant/AssistantMessage.tsx
yuval-hazaz marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import {
Button,
EnumButtonStyle,
EnumTextColor,
Icon,
} from "@amplication/ui/design-system";
import { Button, EnumButtonStyle } from "@amplication/ui/design-system";
import ReactMarkdown from "react-markdown";
import { Link } from "react-router-dom";
import UserBadge from "../Components/UserBadge";
import * as models from "../models";
import { AssistantMessageWithOptions } from "./hooks/useAssistant";
import { Link } from "react-router-dom";

import jovu from "../assets/jovu.svg";

const CLASS_NAME = "assistant";

Expand All @@ -28,7 +25,13 @@ const AssistantMessage = ({ message, onOptionClick }: Props) => {
</>
) : (
<>
<Icon icon="ai" color={EnumTextColor.ThemeTurquoise} size="large" />
<img
src={jovu}
alt="jovu"
width={30}
height={30}
style={{ background: "white", borderRadius: "50%" }}
/>
Jovu
</>
)}
Expand Down
44 changes: 29 additions & 15 deletions packages/amplication-client/src/Assistant/hooks/useAssistant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ const useAssistant = () => {

const [threadId, setThreadId] = useState<string | null>(null);

const [
sendAssistantMessage,
{ error: sendMessageError, loading: sendMessageLoading },
] = useMutation<TAssistantThreadData>(SEND_ASSISTANT_MESSAGE, {
onCompleted: (data) => {
setThreadId(data.sendAssistantMessageWithStream.id);
setMessages([
...messages,
...data.sendAssistantMessageWithStream.messages,
]);
},
});
const [sendAssistantMessage] = useMutation<TAssistantThreadData>(
SEND_ASSISTANT_MESSAGE,
{
onCompleted: (data) => {
setThreadId(data.sendAssistantMessageWithStream.id);
setMessages([
...messages,
...data.sendAssistantMessageWithStream.messages,
]);
},
}
);

const { error: streamError } = useSubscription<TAssistantMessageUpdatedData>(
ASSISTANT_MESSAGE_UPDATED,
Expand Down Expand Up @@ -125,15 +125,29 @@ const useAssistant = () => {
},
},
}).catch((error) => {
console.error(error);
setMessages([
...messages,
{
text: "I'm sorry, I had a problem processing your request.",
role: models.EnumAssistantMessageRole.Assistant,
id: Date.now().toString() + "_",
createdAt: "",
},
{
text: error.message,
role: models.EnumAssistantMessageRole.Assistant,
id: Date.now().toString() + "_",
createdAt: "",
},
]);

setProcessingMessage(false);
});
};

return {
sendMessage,
messages,
sendMessageError,
sendMessageLoading,
streamError,
processingMessage,
};
Expand Down