Skip to content

Commit

Permalink
Merge branch 'develop' into client-3912-calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbykolev authored Oct 14, 2024
2 parents 68c6da6 + 7f346dd commit f4b571b
Show file tree
Hide file tree
Showing 14 changed files with 382 additions and 187 deletions.
19 changes: 15 additions & 4 deletions src/core/apollo/generated/graphql-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,9 @@ export enum AiPersonaDataAccessMode {
export enum AiPersonaEngine {
CommunityManager = 'COMMUNITY_MANAGER',
Expert = 'EXPERT',
GenericOpenai = 'GENERIC_OPENAI',
Guidance = 'GUIDANCE',
OpenaiAssistant = 'OPENAI_ASSISTANT',
}

export enum AiPersonaInteractionMode {
Expand All @@ -651,7 +653,7 @@ export type AiPersonaService = {
/** The ID of the entity */
id: Scalars['UUID'];
/** The prompt used by this Virtual Persona */
prompt: Scalars['String'];
prompt: Array<Scalars['String']>;
/** The date at which the entity was last updated. */
updatedDate?: Maybe<Scalars['DateTime']>;
};
Expand Down Expand Up @@ -1642,7 +1644,8 @@ export type CreateAiPersonaServiceInput = {
bodyOfKnowledgeType?: InputMaybe<AiPersonaBodyOfKnowledgeType>;
dataAccessMode?: InputMaybe<AiPersonaDataAccessMode>;
engine?: InputMaybe<AiPersonaEngine>;
prompt?: InputMaybe<Scalars['JSON']>;
externalConfig?: InputMaybe<ExternalConfig>;
prompt?: InputMaybe<Array<Scalars['String']>>;
};

export type CreateCalendarEventOnCalendarInput = {
Expand Down Expand Up @@ -2367,6 +2370,13 @@ export type ExploreSpacesInput = {
limit?: InputMaybe<Scalars['Float']>;
};

export type ExternalConfig = {
/** The API key for the external LLM provider. */
apiKey?: InputMaybe<Scalars['String']>;
/** The assistent ID backing the service in OpenAI`s assistant API */
assistantId?: InputMaybe<Scalars['String']>;
};

export type FileStorageConfig = {
__typename?: 'FileStorageConfig';
/** Max file size, in bytes. */
Expand Down Expand Up @@ -5919,8 +5929,9 @@ export type UpdateAiPersonaInput = {

export type UpdateAiPersonaServiceInput = {
ID: Scalars['UUID'];
engine: AiPersonaEngine;
prompt?: InputMaybe<Scalars['JSON']>;
engine?: InputMaybe<AiPersonaEngine>;
externalConfig?: InputMaybe<ExternalConfig>;
prompt?: InputMaybe<Array<Scalars['String']>>;
};

export type UpdateApplicationFormOnRoleSetInput = {
Expand Down
2 changes: 1 addition & 1 deletion src/core/auth/authentication/components/KratosUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export const KratosUI: FC<KratosUIProps> = ({
}

if (node.group === 'oidc' && isSubmitButton(node)) {
return <KratosSocialButton node={node} buttonComponent={buttonComponent} />;
return <KratosSocialButton key={node.attributes.value} node={node} buttonComponent={buttonComponent} />;
}

switch (node.attributes.type) {
Expand Down
30 changes: 24 additions & 6 deletions src/core/i18n/en/translation.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3025,12 +3025,30 @@
},
"submitDisabled": "Add at least one Post to continue"
},
"externalAICommingSoon": {
"title": "🚀 Coming soon!",
"subTitle": "We're currently building the functionality to use external AI services for your Virtual Contributor. You can help us by sharing which AI service you would like to use.",
"input": {
"label": "AI Service",
"placeholder": "E.g. the AI that xx created to xx"
"externalAI": {
"create": {
"title": "Create Virtual Contributor with an External AI",
"subTitle": "Choose a provider and enter your API Key or token to connect your external AI to a Virtual Contributor",
"apiKey": {
"label": "API Key",
"placeholder": "E.g. sk-proj-Uq3zU..."
},
"assistantId": {
"label": "Assistant ID",
"placeholder": "E.g. asst_wTLKgGkKryqR5FlEFleLy5Uq"
},
"provider": {
"title": "Provider",
"placeholder": "Select a provider from this list"
}
},
"commingSoon": {
"title": "🚀 Coming soon!",
"subTitle": "We're currently building the functionality to use external AI services for your Virtual Contributor. You can help us by sharing which AI service you would like to use.",
"input": {
"label": "AI Service",
"placeholder": "E.g. the AI that xx created to xx"
}
},
"contactOptions": {
"title": "May we contact you if we have questions about the way you want to use this AI service?",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const VirtualContributorsDialog: FC<VirtualContributorsDialogProps> = ({ open, o
}
component={Wrapper}
to={vc.profile.url}
key={vc.id}
>
<BlockSectionTitle>{vc.profile.displayName}</BlockSectionTitle>
<BlockSectionTitle>{vc.profile.tagline}</BlockSectionTitle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const useStyles = makeStyles(_ =>
})
);

const ElevatedPaper = withElevationOnHover(Paper);
const ElevatedPaper = withElevationOnHover(Paper) as typeof Paper;

export const ContributorCardSquare: FC<ContributorCardSquareProps> = props => {
const styles = useStyles();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import VCSettingsPageLayout from '../layout/VCSettingsPageLayout';
import SwitchSettingsGroup from '../../../../core/ui/forms/SettingsGroups/SwitchSettingsGroup';
import { useNotification } from '../../../../core/ui/notifications/useNotification';
import RadioSettingsGroup from '../../../../core/ui/forms/SettingsGroups/RadioSettingsGroup';
import { SearchVisibility } from '../../../../core/apollo/generated/graphql-schema';
import { AiPersonaBodyOfKnowledgeType, SearchVisibility } from '../../../../core/apollo/generated/graphql-schema';
import { BlockTitle, Caption } from '../../../../core/ui/typography';
import { Actions } from '../../../../core/ui/actions/Actions';
import { LoadingButton } from '@mui/lab';
Expand Down Expand Up @@ -129,19 +129,21 @@ export const VCAccessibilitySettingsPage = () => {
</PageContentBlock>
</PageContentColumn>
</PageContent>
<PageContent background="background.paper">
<PageContentColumn columns={12}>
<PageContentBlock>
<BlockTitle>{t('pages.virtualContributorProfile.settings.ingestion.title')}</BlockTitle>
<Caption>{t('pages.virtualContributorProfile.settings.ingestion.infoText')}</Caption>
<Actions>
<LoadingButton variant="contained" loading={updateLoading} onClick={refreshIngestion}>
{t('pages.virtualContributorProfile.settings.ingestion.refreshBtn')}
</LoadingButton>
</Actions>
</PageContentBlock>
</PageContentColumn>
</PageContent>
{data?.virtualContributor?.aiPersona?.bodyOfKnowledgeType === AiPersonaBodyOfKnowledgeType.AlkemioSpace && (
<PageContent background="background.paper">
<PageContentColumn columns={12}>
<PageContentBlock>
<BlockTitle>{t('pages.virtualContributorProfile.settings.ingestion.title')}</BlockTitle>
<Caption>{t('pages.virtualContributorProfile.settings.ingestion.infoText')}</Caption>
<Actions>
<LoadingButton variant="contained" loading={updateLoading} onClick={refreshIngestion}>
{t('pages.virtualContributorProfile.settings.ingestion.refreshBtn')}
</LoadingButton>
</Actions>
</PageContentBlock>
</PageContentColumn>
</PageContent>
)}
</VCSettingsPageLayout>
</StorageConfigContextProvider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,40 +70,42 @@ export const VCProfilePageView: FC<PropsWithChildren<VCProfilePageViewProps>> =
<HostCard hostProfile={virtualContributor?.provider.profile} />
</PageContentColumn>
<PageContentColumn columns={8}>
<PageContentBlock>
<SectionTitle>
<BookIcon htmlColor={theme.palette.icons.dark} sx={{ fontSize: '18px' }} />
{t('pages.virtualContributorProfile.sections.knowledge.title')}
</SectionTitle>
<SectionContent>
<Trans i18nKey="pages.virtualContributorProfile.sections.knowledge.description" values={{ name }} />
{bokProfile ? (
<BasicSpaceCard space={bokProfile} />
) : (
<WrapperMarkdown>{bokDescription ?? ''}</WrapperMarkdown>
)}
<Spacer />
</SectionContent>
<SectionTitle>
<RecordVoiceOverIcon htmlColor={theme.palette.icons.dark} sx={{ fontSize: '18px' }} />
{t('pages.virtualContributorProfile.sections.personality.title')}
</SectionTitle>
<SectionContent>
<Trans i18nKey="pages.virtualContributorProfile.sections.personality.description" values={{ name }} />
<Spacer />
</SectionContent>
<SectionTitle>
<CloudDownloadIcon htmlColor={theme.palette.icons.dark} sx={{ fontSize: '18px' }} />
{t('pages.virtualContributorProfile.sections.context.title')}
</SectionTitle>
<SectionContent>
<Trans i18nKey="pages.virtualContributorProfile.sections.context.description" values={{ name }} />
<Trans
i18nKey="pages.virtualContributorProfile.sections.context.bullets"
components={{ ul: <ul />, li: <li /> }}
/>
</SectionContent>
</PageContentBlock>
{bokProfile && (
<PageContentBlock>
<SectionTitle>
<BookIcon htmlColor={theme.palette.icons.dark} sx={{ fontSize: '18px' }} />
{t('pages.virtualContributorProfile.sections.knowledge.title')}
</SectionTitle>
<SectionContent>
<Trans i18nKey="pages.virtualContributorProfile.sections.knowledge.description" values={{ name }} />
{bokProfile ? (
<BasicSpaceCard space={bokProfile} />
) : (
<WrapperMarkdown>{bokDescription ?? ''}</WrapperMarkdown>
)}
<Spacer />
</SectionContent>
<SectionTitle>
<RecordVoiceOverIcon htmlColor={theme.palette.icons.dark} sx={{ fontSize: '18px' }} />
{t('pages.virtualContributorProfile.sections.personality.title')}
</SectionTitle>
<SectionContent>
<Trans i18nKey="pages.virtualContributorProfile.sections.personality.description" values={{ name }} />
<Spacer />
</SectionContent>
<SectionTitle>
<CloudDownloadIcon htmlColor={theme.palette.icons.dark} sx={{ fontSize: '18px' }} />
{t('pages.virtualContributorProfile.sections.context.title')}
</SectionTitle>
<SectionContent>
<Trans i18nKey="pages.virtualContributorProfile.sections.context.description" values={{ name }} />
<Trans
i18nKey="pages.virtualContributorProfile.sections.context.bullets"
components={{ ul: <ul />, li: <li /> }}
/>
</SectionContent>
</PageContentBlock>
)}
<PageContentBlock>
<SectionTitle>
<ShieldIcon htmlColor={theme.palette.icons.dark} sx={{ fontSize: '18px' }} />
Expand Down
9 changes: 9 additions & 0 deletions src/domain/shared/components/withElevationOnHover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ const withElevationOnHover = <El, P extends ComponentProps<El>>(Component: Compo
);
const setInitialElevation = useCallback(() => setElevation(initialElevation), [initialElevation]);

if (componentProps['$$typeof']) {
delete componentProps['$$typeof'];
}
// eslint-disable-next-line react/forbid-foreign-prop-types
if (componentProps['propTypes']) {
// eslint-disable-next-line react/forbid-foreign-prop-types
delete componentProps['propTypes'];
}

return (
<Component
ref={ref}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import React from 'react';
import { Form, Formik } from 'formik';
import * as yup from 'yup';
import { useTranslation } from 'react-i18next';
import { DialogContent } from '@mui/material';
import DialogHeader from '../../../../core/ui/dialog/DialogHeader';
import Gutters from '../../../../core/ui/grid/Gutters';
import { Caption } from '../../../../core/ui/typography';
import { Actions } from '../../../../core/ui/actions/Actions';
import FormikInputField from '../../../../core/ui/forms/FormikInputField/FormikInputField';
import LoadingButton from '@mui/lab/LoadingButton';
import { AiPersonaEngine } from '../../../../core/apollo/generated/graphql-schema';
import ExternalAIComingSoonDialog from './ExternalAIComingSoonDialog';
import FormikAutocomplete from '../../../../core/ui/forms/FormikAutocomplete';

const PROVIDERS = [
{ id: AiPersonaEngine.OpenaiAssistant, name: 'OpenAI Assistant' },
{ id: AiPersonaEngine.GenericOpenai, name: 'OpenAI' },
];

interface CreateExternalAIDialogProps {
onClose: () => void;
onCreateExternal: (externalparams: ExternalVcFormValues) => void;
}

export interface ExternalVcFormValues {
engine: AiPersonaEngine;
apiKey: string;
assistantId?: string;
}

const CreateExternalAIDialog: React.FC<CreateExternalAIDialogProps> = ({ onClose, onCreateExternal }) => {
const { t } = useTranslation();

const initialValues: ExternalVcFormValues = {
engine: AiPersonaEngine.GenericOpenai,
apiKey: '',
assistantId: '',
};

const validationSchema = yup.object().shape({
engine: yup
.string()
.oneOf(PROVIDERS.map(({ id }) => id))
.required(),
apiKey: yup.string().required(),
assistantId: yup.string().when('engine', {
is: AiPersonaEngine.OpenaiAssistant,
then: yup.string().required(),
otherwise: yup.string().notRequired(),
}),
});

const handleSubmit = async (values: ExternalVcFormValues) => {
onCreateExternal(values);
};

return (
<Formik
initialValues={initialValues}
validationSchema={validationSchema}
enableReinitialize
validateOnMount
onSubmit={(values: ExternalVcFormValues) => handleSubmit(values)}
>
{({ isValid, handleChange, values }) => (
<>
<DialogHeader title={t('createVirtualContributorWizard.externalAI.create.title')} onClose={onClose} />
<DialogContent sx={{ paddingTop: 0 }}>
<Caption alignSelf="center">{t('createVirtualContributorWizard.externalAI.create.subTitle')}</Caption>

<Form>
<Gutters disablePadding sx={{ paddingTop: 2, paddingBottom: 2 }}>
<FormikAutocomplete
name="engine"
label={t('createVirtualContributorWizard.externalAI.create.provider.title')}
title="title"
placeholder={t('createVirtualContributorWizard.externalAI.create.provider.placeholder')}
values={PROVIDERS}
/>
<FormikInputField
name="apiKey"
title={t('createVirtualContributorWizard.externalAI.create.apiKey.label')}
placeholder={t('createVirtualContributorWizard.externalAI.create.apiKey.placeholder')}
onChange={handleChange}
/>
{values.engine === AiPersonaEngine.OpenaiAssistant && (
<FormikInputField
name="assistantId"
title={t('createVirtualContributorWizard.externalAI.create.assistantId.label')}
placeholder={t('createVirtualContributorWizard.externalAI.create.assistantId.placeholder')}
onChange={handleChange}
/>
)}
<Actions justifyContent="end">
<LoadingButton variant="contained" disabled={!isValid} type="submit">
{t('buttons.create')}
</LoadingButton>
</Actions>
</Gutters>
</Form>
<ExternalAIComingSoonDialog onClose={onClose} />
</DialogContent>
</>
)}
</Formik>
);
};

export default CreateExternalAIDialog;
Loading

0 comments on commit f4b571b

Please sign in to comment.