Skip to content

Commit

Permalink
feat(MLX): add Semantic search preview (#772)
Browse files Browse the repository at this point in the history
* feat(MLX): add ses/preview

* fix: descriptions

* fix: add export document.js

* fix: add Interface for Document  and change SES
  • Loading branch information
paulgerold authored Nov 21, 2023
1 parent 2e60355 commit 4dc7e3c
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/resources/MachineLearning/DocumentInterfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type DocumentRequirementStatus = 'OK' | 'INSUFFICIENT_DOCUMENTS' | 'NB_OF_DOCUMENTS_OVER_LIMIT';
8 changes: 7 additions & 1 deletion src/resources/MachineLearning/MachineLearning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import PQSConfiguration from './PQSConfiguration/PQSConfiguration.js';
import UserActionHistoryConfiguration from './UserActionHistoryConfiguration/UserActionHistoryConfiguration.js';
import IAPRConfiguration from './IAPRConfiguration/IAPRConfiguration.js';
import ModelListing from './ModelListing/ModelListing.js';
import SemanticSearchConfiguration from './SemanticSearchConfiguration/SemanticSearchConfiguration.js';

export default class MachineLearning extends Resource {
static baseUrl = `/rest/organizations/${API.orgPlaceholder}/machinelearning`;
Expand All @@ -21,8 +22,12 @@ export default class MachineLearning extends Resource {
pqsConfig: PQSConfiguration;
iaprConfig: IAPRConfiguration;
modelListing: ModelListing;
semanticSearchConfig: SemanticSearchConfiguration;

constructor(protected api: API, protected serverlessApi: API) {
constructor(
protected api: API,
protected serverlessApi: API,
) {
super(api, serverlessApi);

this.models = new Models(api, serverlessApi);
Expand All @@ -33,6 +38,7 @@ export default class MachineLearning extends Resource {
this.iaprConfig = new IAPRConfiguration(api, serverlessApi);
this.userActionHistoryConfig = new UserActionHistoryConfiguration(api, serverlessApi);
this.modelListing = new ModelListing(api, serverlessApi);
this.semanticSearchConfig = new SemanticSearchConfiguration(api, serverlessApi);
}

register(registration: RegistrationModel) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import API from '../../../APICore.js';
import Resource from '../../Resource.js';
import {
SemanticSearchDocumentGroupPreview,
SemanticSearchDocumentGroupPreviewParams,
} from './SemanticSearchConfigurationInterfaces.js';

export default class SemanticSearchConfiguration extends Resource {
static baseUrl = `/rest/organizations/${API.orgPlaceholder}/machinelearning/configuration/ses`;
static previewUrl = `${SemanticSearchConfiguration.baseUrl}/preview`;

preview(params: SemanticSearchDocumentGroupPreviewParams) {
return this.api.post<SemanticSearchDocumentGroupPreview>(SemanticSearchConfiguration.previewUrl, params);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {DocumentRequirementStatus} from '../DocumentInterfaces.js';
import {FilterConditions} from '../FilterConditions.js';

export interface SemanticSearchDocumentGroupPreviewParams {
/**
* The names of the sources containing the items that the model should use to extract chunks.
*/
sources?: string[];
/**
* The custom filter conditions to target specific documents.
*/
filterConditions?: FilterConditions[];
/**
* The query that determines the documents to extract. Cannot be used with other document extraction parameters, e.g. sources, filter conditions, etc.
*
* @Example @source==("My source") AND @permanentid AND @language="English";
*/
advancedQuery?: string;
}

export interface SemanticSearchDocumentGroupPreview {
/**
* The query that was used to fetch document information.
*
* @Example @source==("Salesforce Notifier")
*/
query: string;
/**
* The total number of documents in the selected sources.
*/
numberOfDocumentsInSources: number;
/**
* The number of documents that are candidates for learning.
*/
numberOfValidDocuments: number;
/**
* The number of documents in the selected sources that match the conditions.
*/
numberOfDocumentsInSourcesMatchingFilters: number;
/**
* The number of documents in the selected sources that match the conditions and have a `permanentid`.
*/
numberOfDocumentsInSourcesMatchingFiltersWithPermanentId: number;
/**
* The maximum number of documents allowed to learn from.
*/
documentLimit: number;
/**
* Status for the number of required documents to build the model.
*/
documentRequirementStatus: DocumentRequirementStatus;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './SemanticSearchConfiguration.js';
export * from './SemanticSearchConfigurationInterfaces.js';
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {DocumentRequirementStatus} from '../DocumentInterfaces.js';
import {FilterConditions} from '../FilterConditions.js';

export interface DocumentType {
Expand Down Expand Up @@ -39,8 +40,6 @@ export interface SmartSnippetsConfigurationModel {
documentTypes?: DocumentType[];
}

export type SmartSnippetsDocumentRequirementStatus = 'OK' | 'INSUFFICIENT_DOCUMENTS' | 'NB_OF_DOCUMENTS_OVER_LIMIT';

export interface SmartSnippetsDocumentGroupPreviewParams {
/**
* The sources to consider.
Expand Down Expand Up @@ -94,7 +93,7 @@ export interface SmartSnippetsDocumentGroupPreview {
/**
* Status for the number of required documents to build the model.
*/
documentRequirementStatus: SmartSnippetsDocumentRequirementStatus;
documentRequirementStatus: DocumentRequirementStatus;
}

export interface SmartSnippetsContentFieldsParams {
Expand Down
2 changes: 2 additions & 0 deletions src/resources/MachineLearning/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
export * from './MachineLearning.js';
export * from './MachineLearningInterfaces.js';
export * from './FilterConditions.js';
export * from './DocumentInterfaces.js';
export * from './Models/index.js';
export * from './ModelInformation/index.js';
export * from './ModelListing/index.js';
export * from './DNEConfiguration/index.js';
export * from './CaseClassificationConfiguration/index.js';
export * from './SmartSnippetsConfiguration/index.js';
export * from './PQSConfiguration/index.js';
export * from './SemanticSearchConfiguration/index.js';
export * from './IAPRConfiguration/index.js';
export * from './UserActionHistoryConfiguration/index.js';

0 comments on commit 4dc7e3c

Please sign in to comment.