diff --git a/src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx b/src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx index e5af0f86..5d3b411b 100644 --- a/src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx +++ b/src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx @@ -41,6 +41,7 @@ import { LLM_CODE_TEMPLATE_EXAMPLES, LLM_CODE_TEMPLATE_OPTIONS } from "./LLM/llm import KernButton from "@/submodules/react-components/components/kern-button/KernButton"; import { MemoIconAlertTriangleFilled, MemoIconArrowLeft, MemoIconCircleCheckFilled } from "@/submodules/react-components/components/kern-icons/icons"; import { LookupListWithOnClick } from "@/src/types/components/projects/projectId/lookup-lists"; +import { InfoButton } from "@/submodules/react-components/components/InfoButton"; const EDITOR_OPTIONS = { theme: 'vs-light', language: 'python', readOnly: false }; @@ -386,10 +387,12 @@ export default function AttributeCalculation() { selectedOption={(option) => setAdditionalConfigTmp(p => ({ ...p, llmIdentifier: option }))} disabled={currentAttribute.state == AttributeState.USABLE} /> - + - setAdditionalConfigTmp(p => ({ ...p, llmConfig: { ...additionalConfigTmp.llmConfig, apiKey: e.target.value } }))} - className="h-8 text-sm border-gray-300 rounded-md placeholder-italic w-full border text-gray-700 pl-4 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-gray-300 focus:ring-offset-2 focus:ring-offset-gray-100 disabled:opacity-50" /> + {additionalConfigTmp?.llmIdentifier != 'Privatemode AI' ? + setAdditionalConfigTmp(p => ({ ...p, llmConfig: { ...additionalConfigTmp.llmConfig, apiKey: e.target.value } }))} + className="h-8 text-sm border-gray-300 rounded-md placeholder-italic w-full border text-gray-700 pl-4 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-gray-300 focus:ring-offset-2 focus:ring-offset-gray-100 disabled:opacity-50" /> + : } }
Attributes
diff --git a/src/components/projects/projectId/attributes/attributeId/LLM/LLMConfig.tsx b/src/components/projects/projectId/attributes/attributeId/LLM/LLMConfig.tsx index cf0eb6df..d2ece072 100644 --- a/src/components/projects/projectId/attributes/attributeId/LLM/LLMConfig.tsx +++ b/src/components/projects/projectId/attributes/attributeId/LLM/LLMConfig.tsx @@ -3,6 +3,7 @@ import OpenAI from "./models/OpenAI" import Azure from "./models/Azure" import { LLMConfigProps } from "./types"; import AzureFoundry from "./models/AzureFoundry"; +import PrivatemodeAi from "./models/PrivatemodeAi"; export function LLMConfig(props: LLMConfigProps) { switch (props.llmIdentifier) { @@ -12,6 +13,8 @@ export function LLMConfig(props: LLMConfigProps) { return case 'Azure Foundry': return + case 'Privatemode AI': + return default: return null } diff --git a/src/components/projects/projectId/attributes/attributeId/LLM/LLMPlaygroundModal.tsx b/src/components/projects/projectId/attributes/attributeId/LLM/LLMPlaygroundModal.tsx index 13314807..42152e3a 100644 --- a/src/components/projects/projectId/attributes/attributeId/LLM/LLMPlaygroundModal.tsx +++ b/src/components/projects/projectId/attributes/attributeId/LLM/LLMPlaygroundModal.tsx @@ -19,6 +19,7 @@ import { jsonCopy } from "@/submodules/javascript-functions/general"; import { TEMPLATE_EXAMPLES, TEMPLATE_OPTIONS } from "./llmTemplates"; import { LLM_PROVIDER_OPTIONS, postProcessLLMPlaygroundRecordData } from "@/src/util/components/projects/projectId/settings/attribute-calculation-helper"; import { MemoIconHandClick, MemoIconPlayCardStar, MemoIconPlayerPlay, MemoIconRefresh, MemoIconTerminal } from "@/submodules/react-components/components/kern-icons/icons"; +import { InfoButton } from "@/submodules/react-components/components/InfoButton"; const ACCEPT_BUTTON = { buttonCaption: "Use current values for attribute", useButton: true }; const DISPLAY_STATES = [AttributeState.AUTOMATICALLY_CREATED, AttributeState.UPLOADED, AttributeState.USABLE] @@ -176,10 +177,12 @@ export default function LLMPlaygroundModal() { options={LLM_PROVIDER_OPTIONS} dropdownWidth="w-64" selectedOption={(option) => setFullLlmConfig(p => ({ ...p, llmIdentifier: option }))} - /> + /> - setFullLlmConfig(p => ({ ...p, llmConfig: { ...fullLlmConfig.llmConfig, apiKey: e.target.value } }))} - className="h-8 text-sm border-gray-300 rounded-md placeholder-italic w-full border text-gray-700 pl-4 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-gray-300 focus:ring-offset-2 focus:ring-offset-gray-100" /> + {fullLlmConfig?.llmIdentifier != 'Privatemode AI' ? + setFullLlmConfig(p => ({ ...p, llmConfig: { ...fullLlmConfig.llmConfig, apiKey: e.target.value } }))} + className="h-8 text-sm border-gray-300 rounded-md placeholder-italic w-full border text-gray-700 pl-4 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-gray-300 focus:ring-offset-2 focus:ring-offset-gray-100" /> + : } } diff --git a/src/components/projects/projectId/attributes/attributeId/LLM/models/PrivatemodeAi.tsx b/src/components/projects/projectId/attributes/attributeId/LLM/models/PrivatemodeAi.tsx new file mode 100644 index 00000000..934ae296 --- /dev/null +++ b/src/components/projects/projectId/attributes/attributeId/LLM/models/PrivatemodeAi.tsx @@ -0,0 +1,79 @@ +import { useEffect } from "react"; +import KernDropdown from "@/submodules/react-components/components/KernDropdown"; +import { InfoButton } from "@/submodules/react-components/components/InfoButton"; +import { InputWithSlider } from "@/submodules/react-components/components/InputWithSlider"; +import { LLmPropsPrivatemodeAI } from "../types"; + + +export const MODEL_MAP_FULL_NAME = { + 'Meta-Llama-3.3-70B': "ibnzterrell/Meta-Llama-3.3-70B-Instruct-AWQ-INT4", + 'gemma-3-27b': "leon-se/gemma-3-27b-it-fp8-dynamic", +} +const REVERSE_MAP_FULL_NAME = Object.fromEntries(Object.entries(MODEL_MAP_FULL_NAME).map(([key, value]) => [value, key])); +export const MODEL_OPTIONS = Object.keys(MODEL_MAP_FULL_NAME); +const MODEL_MAP_FULL_NAME_OPTIONS = Object.keys(REVERSE_MAP_FULL_NAME); +export default function PrivatemodeAi(props: LLmPropsPrivatemodeAI) { + useEffect(() => { + if (props.llmConfig.model && !MODEL_MAP_FULL_NAME_OPTIONS.includes(props.llmConfig.model)) { + props.setLlmConfig({ ...props.llmConfig, model: MODEL_MAP_FULL_NAME[MODEL_OPTIONS[0]] }) + } + }, []); + return ( +
+ {props.onlyEssential ? + null :
+ API Key + +
} +
+ + props.setLlmConfig({ ...props.llmConfig, model: MODEL_MAP_FULL_NAME[option] })} + disabled={props.disabled} + /> +
+ {props.onlyEssential ? null : <> + props.setLlmConfig({ ...props.llmConfig, temperature: value })} + disabled={props.disabled} + /> + + props.setLlmConfig({ ...props.llmConfig, topP: value })} + disabled={props.disabled} + /> + props.setLlmConfig({ ...props.llmConfig, frequencyPenalty: value })} + disabled={props.disabled} + /> + props.setLlmConfig({ ...props.llmConfig, presencePenalty: value })} + disabled={props.disabled} + /> + } + +
+ ) +} \ No newline at end of file diff --git a/src/components/projects/projectId/attributes/attributeId/LLM/types.ts b/src/components/projects/projectId/attributes/attributeId/LLM/types.ts index 40946d37..5aa2505d 100644 --- a/src/components/projects/projectId/attributes/attributeId/LLM/types.ts +++ b/src/components/projects/projectId/attributes/attributeId/LLM/types.ts @@ -30,6 +30,14 @@ export type LLmPropsOpenAI = { disabled?: boolean; } +export type LLmPropsPrivatemodeAI = { + llmConfig: any; + setLlmConfig: (llmConfig: any) => void; + onlyEssential?: boolean; + projectId?: string; + disabled?: boolean; +} + export type LLmPropsAzure = { llmConfig: any; diff --git a/src/components/projects/projectId/settings/embeddings/AddNewEmbeddingModal.tsx b/src/components/projects/projectId/settings/embeddings/AddNewEmbeddingModal.tsx index fe1f3249..8cfc277a 100644 --- a/src/components/projects/projectId/settings/embeddings/AddNewEmbeddingModal.tsx +++ b/src/components/projects/projectId/settings/embeddings/AddNewEmbeddingModal.tsx @@ -56,7 +56,7 @@ export default function AddNewEmbeddingModal() { useEffect(() => { prepareSuggestions(); - checkIfPlatformHasToken(); + // checkIfPlatformHasToken(); }, []); useEffect(() => { @@ -84,7 +84,7 @@ export default function AddNewEmbeddingModal() { const suggestionListFiltered = suggestionList.map((suggestion: any) => { const suggestionCopy = { ...suggestion }; const applicability = JSON.parse(suggestionCopy.applicability); - if ((granularity.value == EmbeddingType.ON_ATTRIBUTE && applicability.attribute) || (granularity.value == EmbeddingType.ON_TOKEN && applicability.token)) { + if ((granularity.value == EmbeddingType.ON_ATTRIBUTE && applicability.attribute) /*|| (granularity.value == EmbeddingType.ON_TOKEN && applicability.token)*/) { suggestionCopy.forceHidden = false; } else { suggestionCopy.forceHidden = true; @@ -99,11 +99,13 @@ export default function AddNewEmbeddingModal() { function checkIfAttributeHasToken() { const attribute = useableEmbedableAttributes.find((a) => a.id == targetAttribute.id); - if (attribute?.dataType == DataTypeEnum.EMBEDDING_LIST) { - setGranularityArray(GRANULARITY_TYPES_ARRAY.filter((g) => g.value != EmbeddingType.ON_TOKEN)); - } else { - checkIfPlatformHasToken(); - } + setGranularityArray(GRANULARITY_TYPES_ARRAY); + + // if (attribute?.dataType == DataTypeEnum.EMBEDDING_LIST) { + // setGranularityArray(GRANULARITY_TYPES_ARRAY.filter((g) => g.value != EmbeddingType.ON_TOKEN)); + // } else { + // checkIfPlatformHasToken(); + // } } function changePlatformOrGranularity() { @@ -131,18 +133,20 @@ export default function AddNewEmbeddingModal() { acceptButtonCopy.disabled = checkIfCreateEmbeddingIsDisabled({ platform, model, apiToken, termsAccepted, embeddings, targetAttribute, granularity, engine, url, version, embeddingPlatforms }); setAcceptButton(acceptButtonCopy); setTermsAccepted(false); - setModel(null); + if (savePlatform == PlatformType.PRIVATEMODE_AI) { + setModel("intfloat/multilingual-e5-large-instruct"); + } else setModel(null); setApiToken(''); } - function checkIfPlatformHasToken() { - if (!platform) return; - if (platform.name == platformNamesDict[PlatformType.OPEN_AI] || platform.name == platformNamesDict[PlatformType.AZURE]) { - setGranularityArray(GRANULARITY_TYPES_ARRAY.filter((g) => g.value != EmbeddingType.ON_TOKEN)); - } else { - setGranularityArray(GRANULARITY_TYPES_ARRAY); - } - } + // function checkIfPlatformHasToken() { + // if (!platform) return; + // if (platform.name == platformNamesDict[PlatformType.OPEN_AI] || platform.name == platformNamesDict[PlatformType.AZURE]) { + // setGranularityArray(GRANULARITY_TYPES_ARRAY.filter((g) => g.value != EmbeddingType.ON_TOKEN)); + // } else { + // setGranularityArray(GRANULARITY_TYPES_ARRAY); + // } + // } const prepareAzureData = useCallback(() => { const getAzureUrl = localStorage.getItem('azureUrls'); @@ -175,7 +179,8 @@ export default function AddNewEmbeddingModal() { platform: platform.platform, termsText: gdprText.current != null ? gdprText.current.innerText : null, termsAccepted: termsAccepted, - embeddingType: granularity.value == EmbeddingType.ON_TOKEN ? EmbeddingType.ON_TOKEN : EmbeddingType.ON_ATTRIBUTE, + // embeddingType: granularity.value == EmbeddingType.ON_TOKEN ? EmbeddingType.ON_TOKEN : EmbeddingType.ON_ATTRIBUTE, + embeddingType: EmbeddingType.ON_ATTRIBUTE, filterAttributes: filteredAttributes } @@ -191,6 +196,8 @@ export default function AddNewEmbeddingModal() { config.type = DEFAULT_AZURE_TYPE; config.version = version; prepareAzureData(); + } else if (platform.name == platformNamesDict[PlatformType.PRIVATEMODE_AI]) { + config.model = model; } createEmbeddingPost(projectId, targetAttribute.id, JSON.stringify(config), (res) => { }); @@ -290,13 +297,20 @@ export default function AddNewEmbeddingModal() { setVersion(option)} name="Version" tooltip="The latest version of the Azure OpenAI service can also be found here." /> } } + {platform && platform.name == platformNamesDict[PlatformType.PRIVATEMODE_AI] && <> + + Model + + + } - {platform && (platform.name == platformNamesDict[PlatformType.OPEN_AI] || platform.name == platformNamesDict[PlatformType.AZURE]) &&
+ {platform && (platform.name == platformNamesDict[PlatformType.OPEN_AI] || platform.name == platformNamesDict[PlatformType.AZURE] || platform.name == platformNamesDict[PlatformType.PRIVATEMODE_AI]) &&
diff --git a/src/types/components/projects/projectId/settings/embeddings.ts b/src/types/components/projects/projectId/settings/embeddings.ts index 4b5f9d98..95c1cfd4 100644 --- a/src/types/components/projects/projectId/settings/embeddings.ts +++ b/src/types/components/projects/projectId/settings/embeddings.ts @@ -31,7 +31,7 @@ export type EmbeddingWithOnClick = Embedding & { export enum EmbeddingType { ON_ATTRIBUTE = "ON_ATTRIBUTE", - ON_TOKEN = "ON_TOKEN" + // ON_TOKEN = "ON_TOKEN" //currently removed since it doesn't seem to be used but kept code wise for easy reenabling }; export type EmbeddingPlatform = { @@ -46,7 +46,8 @@ export type EmbeddingPlatform = { export enum PlatformType { HUGGING_FACE = "huggingface", OPEN_AI = "openai", - AZURE = "azure" + AZURE = "azure", + PRIVATEMODE_AI = "privatemode-ai" } export type RecommendedEncoder = { diff --git a/src/util/components/projects/projectId/settings/attribute-calculation-helper.ts b/src/util/components/projects/projectId/settings/attribute-calculation-helper.ts index 9d9e4596..b4f0aa3b 100644 --- a/src/util/components/projects/projectId/settings/attribute-calculation-helper.ts +++ b/src/util/components/projects/projectId/settings/attribute-calculation-helper.ts @@ -47,7 +47,8 @@ export function postProcessRecordByRecordId(record: Record): Record { export const LLM_PROVIDER_OPTIONS = [ 'Open AI', 'Azure', - 'Azure Foundry' + 'Azure Foundry', + 'Privatemode AI' ]; export function postProcessLLMPlaygroundRecordData(recordList: any[]): any[] { diff --git a/src/util/components/projects/projectId/settings/embeddings-helper.ts b/src/util/components/projects/projectId/settings/embeddings-helper.ts index 401e85a0..25e4ded0 100644 --- a/src/util/components/projects/projectId/settings/embeddings-helper.ts +++ b/src/util/components/projects/projectId/settings/embeddings-helper.ts @@ -12,7 +12,8 @@ export function postProcessingEmbeddings(embeddings: Embedding[], queuedEmbeddin id: task.id, name: task.taskInfo.embeddingName, custom: false, - type: task.taskInfo.embeddingType == EmbeddingType.ON_ATTRIBUTE ? EmbeddingType.ON_ATTRIBUTE : EmbeddingType.ON_TOKEN, + // type: task.taskInfo.embeddingType == EmbeddingType.ON_ATTRIBUTE ? EmbeddingType.ON_ATTRIBUTE : EmbeddingType.ON_TOKEN, + type: EmbeddingType.ON_ATTRIBUTE, state: EmbeddingState.QUEUED, progress: 0, dimension: 0, @@ -24,7 +25,7 @@ export function postProcessingEmbeddings(embeddings: Embedding[], queuedEmbeddin export const GRANULARITY_TYPES_ARRAY = [ { name: 'Attribute', value: EmbeddingType.ON_ATTRIBUTE }, - { name: 'Token', value: EmbeddingType.ON_TOKEN } + // { name: 'Token', value: EmbeddingType.ON_TOKEN } ]; export function postProcessingEmbeddingPlatforms(platforms: EmbeddingPlatform[], organization: Organization) { @@ -46,7 +47,8 @@ export function postProcessingEmbeddingPlatforms(platforms: EmbeddingPlatform[], export const platformNamesDict = { [PlatformType.HUGGING_FACE]: "Hugging Face", [PlatformType.OPEN_AI]: "OpenAI", - [PlatformType.AZURE]: "Azure" + [PlatformType.AZURE]: "Azure", + [PlatformType.PRIVATEMODE_AI]: "Private Mode AI" } export function postProcessingRecommendedEncoders(attributes: Attribute[], tokenizer: string, encoderSuggestions: any): { [embeddingId: string]: RecommendedEncoder } { @@ -71,7 +73,7 @@ function buildExpectedEmbeddingName(data: any): string { let toReturn = data.targetAttribute.name; toReturn += "-" + (data.granularity.value == EmbeddingType.ON_ATTRIBUTE ? 'classification' : 'extraction'); const platform = data.platform; - if (platform == PlatformType.HUGGING_FACE) { + if (platform == PlatformType.HUGGING_FACE || platform == PlatformType.PRIVATEMODE_AI) { toReturn += "-" + platform + "-" + data.model; } else if (platform == PlatformType.OPEN_AI || platform == PlatformType.AZURE) { toReturn += buildEmbeddingNameWithApiToken(data); @@ -110,6 +112,8 @@ export function checkIfCreateEmbeddingIsDisabled(props: EmbeddingCreationEnabled checkFormFields = model == null || apiToken == null || apiToken == "" || !termsAccepted; } else if (platform.name == platformNamesDict[PlatformType.AZURE]) { checkFormFields = apiToken == null || apiToken == "" || url == null || url == "" || version == null || version == "" || !termsAccepted || !engine; + } else if (platform.name == platformNamesDict[PlatformType.PRIVATEMODE_AI]) { + checkFormFields = model == null || model == "" || !termsAccepted; } const data = { targetAttribute: props.targetAttribute,