Skip to content

Commit 189dc9f

Browse files
committed
Enables privatemode ai as embedding provider
1 parent 014d8d1 commit 189dc9f

File tree

3 files changed

+44
-24
lines changed

3 files changed

+44
-24
lines changed

src/components/projects/projectId/settings/embeddings/AddNewEmbeddingModal.tsx

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default function AddNewEmbeddingModal() {
5656

5757
useEffect(() => {
5858
prepareSuggestions();
59-
checkIfPlatformHasToken();
59+
// checkIfPlatformHasToken();
6060
}, []);
6161

6262
useEffect(() => {
@@ -84,7 +84,7 @@ export default function AddNewEmbeddingModal() {
8484
const suggestionListFiltered = suggestionList.map((suggestion: any) => {
8585
const suggestionCopy = { ...suggestion };
8686
const applicability = JSON.parse(suggestionCopy.applicability);
87-
if ((granularity.value == EmbeddingType.ON_ATTRIBUTE && applicability.attribute) || (granularity.value == EmbeddingType.ON_TOKEN && applicability.token)) {
87+
if ((granularity.value == EmbeddingType.ON_ATTRIBUTE && applicability.attribute) /*|| (granularity.value == EmbeddingType.ON_TOKEN && applicability.token)*/) {
8888
suggestionCopy.forceHidden = false;
8989
} else {
9090
suggestionCopy.forceHidden = true;
@@ -99,11 +99,13 @@ export default function AddNewEmbeddingModal() {
9999

100100
function checkIfAttributeHasToken() {
101101
const attribute = useableEmbedableAttributes.find((a) => a.id == targetAttribute.id);
102-
if (attribute?.dataType == DataTypeEnum.EMBEDDING_LIST) {
103-
setGranularityArray(GRANULARITY_TYPES_ARRAY.filter((g) => g.value != EmbeddingType.ON_TOKEN));
104-
} else {
105-
checkIfPlatformHasToken();
106-
}
102+
setGranularityArray(GRANULARITY_TYPES_ARRAY);
103+
104+
// if (attribute?.dataType == DataTypeEnum.EMBEDDING_LIST) {
105+
// setGranularityArray(GRANULARITY_TYPES_ARRAY.filter((g) => g.value != EmbeddingType.ON_TOKEN));
106+
// } else {
107+
// checkIfPlatformHasToken();
108+
// }
107109
}
108110

109111
function changePlatformOrGranularity() {
@@ -131,18 +133,21 @@ export default function AddNewEmbeddingModal() {
131133
acceptButtonCopy.disabled = checkIfCreateEmbeddingIsDisabled({ platform, model, apiToken, termsAccepted, embeddings, targetAttribute, granularity, engine, url, version, embeddingPlatforms });
132134
setAcceptButton(acceptButtonCopy);
133135
setTermsAccepted(false);
134-
setModel(null);
136+
if (savePlatform == PlatformType.PRIVATEMODE_AI) {
137+
console.log("Private Mode AI platform selected, setting model to default.");
138+
setModel("intfloat/multilingual-e5-large-instruct");
139+
} else setModel(null);
135140
setApiToken('');
136141
}
137142

138-
function checkIfPlatformHasToken() {
139-
if (!platform) return;
140-
if (platform.name == platformNamesDict[PlatformType.OPEN_AI] || platform.name == platformNamesDict[PlatformType.AZURE]) {
141-
setGranularityArray(GRANULARITY_TYPES_ARRAY.filter((g) => g.value != EmbeddingType.ON_TOKEN));
142-
} else {
143-
setGranularityArray(GRANULARITY_TYPES_ARRAY);
144-
}
145-
}
143+
// function checkIfPlatformHasToken() {
144+
// if (!platform) return;
145+
// if (platform.name == platformNamesDict[PlatformType.OPEN_AI] || platform.name == platformNamesDict[PlatformType.AZURE]) {
146+
// setGranularityArray(GRANULARITY_TYPES_ARRAY.filter((g) => g.value != EmbeddingType.ON_TOKEN));
147+
// } else {
148+
// setGranularityArray(GRANULARITY_TYPES_ARRAY);
149+
// }
150+
// }
146151

147152
const prepareAzureData = useCallback(() => {
148153
const getAzureUrl = localStorage.getItem('azureUrls');
@@ -175,7 +180,8 @@ export default function AddNewEmbeddingModal() {
175180
platform: platform.platform,
176181
termsText: gdprText.current != null ? gdprText.current.innerText : null,
177182
termsAccepted: termsAccepted,
178-
embeddingType: granularity.value == EmbeddingType.ON_TOKEN ? EmbeddingType.ON_TOKEN : EmbeddingType.ON_ATTRIBUTE,
183+
// embeddingType: granularity.value == EmbeddingType.ON_TOKEN ? EmbeddingType.ON_TOKEN : EmbeddingType.ON_ATTRIBUTE,
184+
embeddingType: EmbeddingType.ON_ATTRIBUTE,
179185
filterAttributes: filteredAttributes
180186
}
181187

@@ -191,6 +197,8 @@ export default function AddNewEmbeddingModal() {
191197
config.type = DEFAULT_AZURE_TYPE;
192198
config.version = version;
193199
prepareAzureData();
200+
} else if (platform.name == platformNamesDict[PlatformType.PRIVATEMODE_AI]) {
201+
config.model = model;
194202
}
195203
createEmbeddingPost(projectId, targetAttribute.id, JSON.stringify(config), (res) => { });
196204

@@ -290,13 +298,20 @@ export default function AddNewEmbeddingModal() {
290298
<SuggestionsAzure options={azureVersions} selectedOption={(option: string) => setVersion(option)} name="Version" tooltip="The latest version of the Azure OpenAI service can also be found here." />
291299
</>}
292300
</>}
301+
{platform && platform.name == platformNamesDict[PlatformType.PRIVATEMODE_AI] && <>
302+
<Tooltip content={TOOLTIPS_DICT.PROJECT_SETTINGS.EMBEDDINGS.MODEL} placement="right" color="invert">
303+
<span className="card-title mb-0 label-text flex"><span className="cursor-help underline filtersUnderline">Model</span></span>
304+
</Tooltip>
305+
<input defaultValue="intfloat/multilingual-e5-large-instruct" disabled className="h-9 w-full text-sm border-gray-300 rounded-md placeholder-italic border text-gray-900 pl-4 focus:outline-none focus:ring-2 focus:ring-gray-300 focus:ring-offset-2 focus:ring-offset-gray-100 disabled:opacity-50" />
306+
</>}
293307
</div>
294-
{platform && (platform.name == platformNamesDict[PlatformType.OPEN_AI] || platform.name == platformNamesDict[PlatformType.AZURE]) && <div className="text-center mt-3">
308+
{platform && (platform.name == platformNamesDict[PlatformType.OPEN_AI] || platform.name == platformNamesDict[PlatformType.AZURE] || platform.name == platformNamesDict[PlatformType.PRIVATEMODE_AI]) && <div className="text-center mt-3">
295309
<div className="border border-gray-300 text-xs text-gray-500 p-2.5 rounded-lg text-justify">
296310
<label ref={gdprText} className="text-gray-700">
297311
{selectedPlatform.splitTerms[0]}
298312
{platform.name == platformNamesDict[PlatformType.OPEN_AI] && <a href={selectedPlatform.link} target="_blank" className="underline">openai terms of service.</a>}
299313
{platform.name == platformNamesDict[PlatformType.AZURE] && <a href={selectedPlatform.link} target="_blank" className="underline">azure terms of service.</a>}
314+
{platform.name == platformNamesDict[PlatformType.PRIVATEMODE_AI] && <a href={selectedPlatform.link} target="_blank" className="underline">private mode ai terms of service.</a>}
300315
<div>{selectedPlatform.splitTerms[1]}</div>
301316
</label>
302317
</div>

src/types/components/projects/projectId/settings/embeddings.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type EmbeddingWithOnClick = Embedding & {
3131

3232
export enum EmbeddingType {
3333
ON_ATTRIBUTE = "ON_ATTRIBUTE",
34-
ON_TOKEN = "ON_TOKEN"
34+
// ON_TOKEN = "ON_TOKEN" //currently removed since it doesn't seem to be used but kept code wise for easy reenabling
3535
};
3636

3737
export type EmbeddingPlatform = {
@@ -46,7 +46,8 @@ export type EmbeddingPlatform = {
4646
export enum PlatformType {
4747
HUGGING_FACE = "huggingface",
4848
OPEN_AI = "openai",
49-
AZURE = "azure"
49+
AZURE = "azure",
50+
PRIVATEMODE_AI = "privatemode-ai"
5051
}
5152

5253
export type RecommendedEncoder = {

src/util/components/projects/projectId/settings/embeddings-helper.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export function postProcessingEmbeddings(embeddings: Embedding[], queuedEmbeddin
1212
id: task.id,
1313
name: task.taskInfo.embeddingName,
1414
custom: false,
15-
type: task.taskInfo.embeddingType == EmbeddingType.ON_ATTRIBUTE ? EmbeddingType.ON_ATTRIBUTE : EmbeddingType.ON_TOKEN,
15+
// type: task.taskInfo.embeddingType == EmbeddingType.ON_ATTRIBUTE ? EmbeddingType.ON_ATTRIBUTE : EmbeddingType.ON_TOKEN,
16+
type: EmbeddingType.ON_ATTRIBUTE,
1617
state: EmbeddingState.QUEUED,
1718
progress: 0,
1819
dimension: 0,
@@ -24,7 +25,7 @@ export function postProcessingEmbeddings(embeddings: Embedding[], queuedEmbeddin
2425

2526
export const GRANULARITY_TYPES_ARRAY = [
2627
{ name: 'Attribute', value: EmbeddingType.ON_ATTRIBUTE },
27-
{ name: 'Token', value: EmbeddingType.ON_TOKEN }
28+
// { name: 'Token', value: EmbeddingType.ON_TOKEN }
2829
];
2930

3031
export function postProcessingEmbeddingPlatforms(platforms: EmbeddingPlatform[], organization: Organization) {
@@ -46,7 +47,8 @@ export function postProcessingEmbeddingPlatforms(platforms: EmbeddingPlatform[],
4647
export const platformNamesDict = {
4748
[PlatformType.HUGGING_FACE]: "Hugging Face",
4849
[PlatformType.OPEN_AI]: "OpenAI",
49-
[PlatformType.AZURE]: "Azure"
50+
[PlatformType.AZURE]: "Azure",
51+
[PlatformType.PRIVATEMODE_AI]: "Private Mode AI"
5052
}
5153

5254
export function postProcessingRecommendedEncoders(attributes: Attribute[], tokenizer: string, encoderSuggestions: any): { [embeddingId: string]: RecommendedEncoder } {
@@ -71,7 +73,7 @@ function buildExpectedEmbeddingName(data: any): string {
7173
let toReturn = data.targetAttribute.name;
7274
toReturn += "-" + (data.granularity.value == EmbeddingType.ON_ATTRIBUTE ? 'classification' : 'extraction');
7375
const platform = data.platform;
74-
if (platform == PlatformType.HUGGING_FACE) {
76+
if (platform == PlatformType.HUGGING_FACE || platform == PlatformType.PRIVATEMODE_AI) {
7577
toReturn += "-" + platform + "-" + data.model;
7678
} else if (platform == PlatformType.OPEN_AI || platform == PlatformType.AZURE) {
7779
toReturn += buildEmbeddingNameWithApiToken(data);
@@ -110,6 +112,8 @@ export function checkIfCreateEmbeddingIsDisabled(props: EmbeddingCreationEnabled
110112
checkFormFields = model == null || apiToken == null || apiToken == "" || !termsAccepted;
111113
} else if (platform.name == platformNamesDict[PlatformType.AZURE]) {
112114
checkFormFields = apiToken == null || apiToken == "" || url == null || url == "" || version == null || version == "" || !termsAccepted || !engine;
115+
} else if (platform.name == platformNamesDict[PlatformType.PRIVATEMODE_AI]) {
116+
checkFormFields = model == null || model == "" || !termsAccepted;
113117
}
114118
const data = {
115119
targetAttribute: props.targetAttribute,

0 commit comments

Comments
 (0)