Skip to content

Commit

Permalink
refactor: adapt changes from new completions config
Browse files Browse the repository at this point in the history
  • Loading branch information
nzambello committed Sep 9, 2024
1 parent 566bff5 commit ce5343a
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
},
"dependencies": {
"@headlessui/react": "1.7.4",
"@memori.ai/memori-api-client": "^5.0.1",
"@memori.ai/memori-api-client": "^5.1.0",
"@react-three/drei": "8.20.2",
"@react-three/fiber": "7.0.25",
"classnames": "2.3.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect, useState } from 'react';
import Tooltip from '../ui/Tooltip';
import Warning from '../icons/Warning';
import { Tenant } from '@memori.ai/memori-api-client/dist/types';
import { useTranslation } from 'react-i18next';

type Status =
Expand All @@ -13,7 +12,7 @@ type Status =

export interface Props {
forceStatus?: Status;
provider?: Tenant['defaultCompletionProvider'];
provider?: string;
}

const initProviderStatus = (
Expand Down
7 changes: 6 additions & 1 deletion src/components/StartPanel/StartPanel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,12 @@ it('renders StartPanel with completion provider down unchanged', () => {
<StartPanel
memori={{
...memori,
completionProvider: 'OpenAI',
completionConfigForQuestionAnswering: {
completionConfigID: '1',
configName: 'openai-gpt-4',
provider: 'OpenAI',
model: 'gpt-4',
},
}}
tenant={tenant}
language="it"
Expand Down
2 changes: 1 addition & 1 deletion src/components/StartPanel/StartPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ const StartPanel: React.FC<Props> = ({
</Button>

<CompletionProviderStatus
provider={memori.completionProvider}
provider={memori.completionConfigForQuestionAnswering?.provider}
forceStatus={_TEST_forceProviderStatus}
/>

Expand Down
17 changes: 17 additions & 0 deletions src/helpers/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const errors = {
MEMORI_NO_PASSWORD_WHEN_PUBLIC: -214,
MEMORI_DEEP_THOUGHT_REQUIRES_COMPLETIONS: -215,
MEMORI_BOARD_OF_EXPERTS_REQUIRES_COMPLETIONS: -216,
MEMORI_INVALID_COMPLETION_CONFIG: -217,

MEMORI_TRANSFER_MISSING_DESTINATION_USER: -231,
MEMORI_TRANSFER_INVALID_DESTINATION_USER_ID: -232,
Expand Down Expand Up @@ -195,6 +196,22 @@ const errors = {

OUTCOME_NO_DCM_CONFIGURED: -2071,
OUTCOME_USER_BADGES_DISABLED: -2072,

COMPLETION_CONFIG_MISSING_NAME: -2401,
COMPLETION_CONFIG_MISSING_PROVIDER: -2402,
COMPLETION_CONFIG_MISSING_ENDPOINT: -2403,
COMPLETION_CONFIG_MISSING_API_KEY: -2404,
COMPLETION_CONFIG_MISSING_MODEL: -2405,
COMPLETION_CONFIG_NO_PURPOSE_SPECIFIED: -2406,
COMPLETION_CONFIG_INVALID_PURPOSE: -2411,
COMPLETION_CONFIG_INVALID_ENDPOINT: -2412,
COMPLETION_CONFIG_INCONSISTENT_ENDPOINT: -2413,
COMPLETION_CONFIG_INVALID_PROVIDER: -2414,
COMPLETION_CONFIG_NOT_FOUND: -2421,
COMPLETION_CONFIG_NOT_ACCESSIBLE: -2422,
COMPLETION_CONFIG_NAME_RESERVED: -2441,
COMPLETION_CONFIG_NAME_ALREADY_EXISTS: -2442,
COMPLETION_CONFIG_VISIBILITY_CHANGE_NOT_ALLOWED: -2443,
};

export const BACKEND_ERRORS = new Map<number, string>(
Expand Down
49 changes: 33 additions & 16 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,22 +280,23 @@
"SESSION_IS_NOT_ADMINISTRATIVE": "Non-administrative session",
"SESSION_EXPIRED": "Session expired",

"MEMORI_MISSING_CONFIGURATION": "Memori: missing configuration",
"MEMORI_CONFIGURATION_NOT_FOUND": "Memories: configuration not found",
"MEMORI_INVALID_PRIVACY_TYPE": "Memories: invalid privacy type",
"MEMORI_MISSING_PASSWORD": "Memori: missing password",
"MEMORI_INVALID_TOTAL_NUMBER_OF_RECOVERY_TOKENS": "Memories: total number of invalid recovery tokens",
"MEMORI_INVALID_MINIMUM_NUMBER_OF_RECOVERY_TOKENS": "Memories: minimum number of invalid recovery tokens",
"MEMORI_INVALID_VOICE_TYPE": "Memories: invalid voice type",
"MEMORI_MISSING_NAME": "Memories: missing name",
"MEMORI_MISSING_PASSWORD_OR_RECOVERY_TOKENS": "Memories: missing password or recovery token",
"MEMORI_INVALID_ID": "Memories: invalid ID",
"MEMORI_NAME_ALREADY_USED": "Memory name already in use",
"MEMORI_INVALID_PIN": "Memories: Invalid PIN",
"MEMORI_GIVER_TAG_PIN_CHANGE_REQUIRES_SEPARATE_OPERATION": "Memories: TAG and PIN change require separate operations",
"MEMORI_NO_PASSWORD_WHEN_PUBLIC": "Memories: no password required when public",
"MEMORI_MISSING_CONFIGURATION": "Twin: missing configuration",
"MEMORI_CONFIGURATION_NOT_FOUND": "Twin: configuration not found",
"MEMORI_INVALID_PRIVACY_TYPE": "Twin: invalid privacy type",
"MEMORI_MISSING_PASSWORD": "Twin: missing password",
"MEMORI_INVALID_TOTAL_NUMBER_OF_RECOVERY_TOKENS": "Twin: total number of invalid recovery tokens",
"MEMORI_INVALID_MINIMUM_NUMBER_OF_RECOVERY_TOKENS": "Twin: minimum number of invalid recovery tokens",
"MEMORI_INVALID_VOICE_TYPE": "Twin: invalid voice type",
"MEMORI_MISSING_NAME": "Twin: missing name",
"MEMORI_MISSING_PASSWORD_OR_RECOVERY_TOKENS": "Twin: missing password or recovery token",
"MEMORI_INVALID_ID": "Twin: invalid ID",
"MEMORI_NAME_ALREADY_USED": "Twin name already in use",
"MEMORI_INVALID_PIN": "Twin: Invalid PIN",
"MEMORI_GIVER_TAG_PIN_CHANGE_REQUIRES_SEPARATE_OPERATION": "Twin: TAG and PIN change require separate operations",
"MEMORI_NO_PASSWORD_WHEN_PUBLIC": "Twin: no password required when public",
"MEMORI_DEEP_THOUGHT_REQUIRES_COMPLETIONS": "Deep Thought requires completions to be enabled",
"MEMORI_BOARD_OF_EXPERTS_REQUIRES_COMPLETIONS": "The expert group requires completions to be enabled",
"MEMORI_INVALID_COMPLETION_CONFIG": "Twin: invalid completions configuration",

"MEMORI_TRANSFER_MISSING_DESTINATION_USER": "Transfer: missing destination user",
"MEMORI_TRANSFER_INVALID_DESTINATION_USER_ID": "Transfer: invalid destination user ID",
Expand Down Expand Up @@ -426,7 +427,23 @@

"BADGE_NOT_FOUND": "Badge not found",

"OUTCOME_NO_DCM_CONFIGURED": "Result: no DCM configured",
"OUTCOME_USER_BADGES_DISABLED": "Result: user badges disabled"
"OUTCOME_NO_DCM_CONFIGURED": "Outcome: no DCM configured",
"OUTCOME_USER_BADGES_DISABLED": "Outcome: user badges disabled",

"COMPLETION_CONFIG_MISSING_NAME": "Completions configuration: missing name",
"COMPLETION_CONFIG_MISSING_PROVIDER": "Completions configuration: missing provider",
"COMPLETION_CONFIG_MISSING_ENDPOINT": "Completions configuration: missing endpoint",
"COMPLETION_CONFIG_MISSING_API_KEY": "Completions configuration: missing API key",
"COMPLETION_CONFIG_MISSING_MODEL": "Completions configuration: missing model",
"COMPLETION_CONFIG_NO_PURPOSE_SPECIFIED": "Completions configuration: at least one completions type must be specified",
"COMPLETION_CONFIG_INVALID_PURPOSE": "Completions configuration: invalid completions type",
"COMPLETION_CONFIG_INVALID_ENDPOINT": "Completions configuration: invalid endpoint",
"COMPLETION_CONFIG_INCONSISTENT_ENDPOINT": "Completions configuration: inconsistent endpoint",
"COMPLETION_CONFIG_INVALID_PROVIDER": "Completions configuration: invalid provider",
"COMPLETION_CONFIG_NOT_FOUND": "Completions configuration: not found",
"COMPLETION_CONFIG_NOT_ACCESSIBLE": "Completions configuration: not accessible",
"COMPLETION_CONFIG_NAME_RESERVED": "Completions configuration: name reserved",
"COMPLETION_CONFIG_NAME_ALREADY_EXISTS": "Completions configuration: name already exists",
"COMPLETION_CONFIG_VISIBILITY_CHANGE_NOT_ALLOWED": "Completions configuration: visibility change not allowed"
}
}
21 changes: 19 additions & 2 deletions src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"MEMORI_NO_PASSWORD_WHEN_PUBLIC": "Memori: password non richiesta su Memori pubblico",
"MEMORI_DEEP_THOUGHT_REQUIRES_COMPLETIONS": "Pensiero Profondo richiede l'abilitazione delle completions",
"MEMORI_BOARD_OF_EXPERTS_REQUIRES_COMPLETIONS": "Il gruppo di esperti richiede l'abilitazione delle completions",
"MEMORI_INVALID_COMPLETION_CONFIG": "Memori: configurazione completions non valida",

"MEMORI_TRANSFER_MISSING_DESTINATION_USER": "Trasferimento: utente di destinazione mancante",
"MEMORI_TRANSFER_INVALID_DESTINATION_USER_ID": "Trasferimento: ID utente di destinazione non valido",
Expand Down Expand Up @@ -425,7 +426,23 @@

"BADGE_NOT_FOUND": "Badge non trovato",

"OUTCOME_NO_DCM_CONFIGURED": "Esito: nessun DCM configurato",
"OUTCOME_USER_BADGES_DISABLED": "Esito: badge utente disabilitati"
"OUTCOME_NO_DCM_CONFIGURED": "Outcome: nessun DCM configurato",
"OUTCOME_USER_BADGES_DISABLED": "Outcome: badge utente disabilitati",

"COMPLETION_CONFIG_MISSING_NAME": "Configurazione completions: nome mancante",
"COMPLETION_CONFIG_MISSING_PROVIDER": "Configurazione completions: provider mancante",
"COMPLETION_CONFIG_MISSING_ENDPOINT": "Configurazione completions: endpoint mancante",
"COMPLETION_CONFIG_MISSING_API_KEY": "Configurazione completions: API key mancante",
"COMPLETION_CONFIG_MISSING_MODEL": "Configurazione completions: modello mancante",
"COMPLETION_CONFIG_NO_PURPOSE_SPECIFIED": "Configurazione completions: almeno un tipo di completions deve essere specificato",
"COMPLETION_CONFIG_INVALID_PURPOSE": "Configurazione completions: tipo di completions non valido",
"COMPLETION_CONFIG_INVALID_ENDPOINT": "Configurazione completions: endpoint non valido",
"COMPLETION_CONFIG_INCONSISTENT_ENDPOINT": "Configurazione completions: endpoint incoerente",
"COMPLETION_CONFIG_INVALID_PROVIDER": "Configurazione completions: provider non valido",
"COMPLETION_CONFIG_NOT_FOUND": "Configurazione completions: non trovata",
"COMPLETION_CONFIG_NOT_ACCESSIBLE": "Configurazione completions: non accessibile",
"COMPLETION_CONFIG_NAME_RESERVED": "Configurazione completions: nome riservato",
"COMPLETION_CONFIG_NAME_ALREADY_EXISTS": "Configurazione completions: nome già esistente",
"COMPLETION_CONFIG_VISIBILITY_CHANGE_NOT_ALLOWED": "Configurazione completions: cambiamento visibilità non consentito"
}
}
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4084,14 +4084,14 @@ __metadata:
languageName: node
linkType: hard

"@memori.ai/memori-api-client@npm:^5.0.1":
version: 5.0.1
resolution: "@memori.ai/memori-api-client@npm:5.0.1"
"@memori.ai/memori-api-client@npm:^5.1.0":
version: 5.1.0
resolution: "@memori.ai/memori-api-client@npm:5.1.0"
dependencies:
cross-fetch: ^3.1.5
peerDependencies:
typescript: ">=4.8"
checksum: cef43b546930e6db3bc8374476f0574fea1df00a47d3b05c680bb26e167f7e7e4a02d7efb0bb160f2ac03a43b0a3ea9d605031c774491026095bb8be09413871
checksum: cc1e24d369efaa0f4d4347357222e95ec4a3fec170ce5b9208606774770b95f97e404298554749cbed27bed9a5727667a68a44adce512f2ff8a678e7e30747b1
languageName: node
linkType: hard

Expand All @@ -4106,7 +4106,7 @@ __metadata:
"@commitlint/cli": 17.3.0
"@commitlint/config-conventional": 17.3.0
"@headlessui/react": 1.7.4
"@memori.ai/memori-api-client": ^5.0.1
"@memori.ai/memori-api-client": ^5.1.0
"@react-three/drei": 8.20.2
"@react-three/fiber": 7.0.25
"@release-it/conventional-changelog": 5.1.1
Expand Down

0 comments on commit ce5343a

Please sign in to comment.