Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 1 addition & 44 deletions packages/spacecat-shared-data-access/src/models/site/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,6 @@ export const Config = (data = {}) => {
self.getLlmoConfig = () => state?.llmo;
self.getLlmoDataFolder = () => state?.llmo?.dataFolder;
self.getLlmoBrand = () => state?.llmo?.brand;
self.getLlmoHumanQuestions = () => state?.llmo?.questions?.Human;
self.getLlmoAIQuestions = () => state?.llmo?.questions?.AI;
self.getLlmoUrlPatterns = () => state?.llmo?.urlPatterns;
self.getLlmoCustomerIntent = () => {
const llmoConfig = self.getLlmoConfig();
Expand All @@ -457,13 +455,12 @@ export const Config = (data = {}) => {
};
};

self.updateLlmoConfig = (dataFolder, brand, questions = {}, urlPatterns = undefined) => {
self.updateLlmoConfig = (dataFolder, brand, urlPatterns = undefined) => {
const currentLlmoConfig = state.llmo || {};
state.llmo = {
...currentLlmoConfig,
dataFolder,
brand,
questions,
urlPatterns,
};
};
Expand All @@ -478,20 +475,6 @@ export const Config = (data = {}) => {
state.llmo.brand = brand;
};

self.addLlmoHumanQuestions = (questions) => {
state.llmo = state.llmo || {};
state.llmo.questions = state.llmo.questions || {};
state.llmo.questions.Human = state.llmo.questions.Human || [];
state.llmo.questions.Human.push(...questions);
};

self.addLlmoAIQuestions = (questions) => {
state.llmo = state.llmo || {};
state.llmo.questions = state.llmo.questions || {};
state.llmo.questions.AI = state.llmo.questions.AI || [];
state.llmo.questions.AI.push(...questions);
};

self.addLlmoCustomerIntent = (customerIntentItems) => {
state.llmo = state.llmo || {};
state.llmo.customerIntent = state.llmo.customerIntent || [];
Expand Down Expand Up @@ -533,32 +516,6 @@ export const Config = (data = {}) => {
}
};

self.removeLlmoQuestion = (key) => {
state.llmo = state.llmo || {};
state.llmo.questions = state.llmo.questions || {};
state.llmo.questions.Human = state.llmo.questions.Human || [];
state.llmo.questions.Human = state.llmo.questions.Human.filter(
(question) => question.key !== key,
);
state.llmo.questions.AI = state.llmo.questions.AI || [];
state.llmo.questions.AI = state.llmo.questions.AI.filter(
(question) => question.key !== key,
);
};

self.updateLlmoQuestion = (key, questionUpdate) => {
state.llmo = state.llmo || {};
state.llmo.questions = state.llmo.questions || {};
state.llmo.questions.Human = state.llmo.questions.Human || [];
state.llmo.questions.Human = state.llmo.questions.Human.map(
(question) => (question.key === key ? { ...question, ...questionUpdate, key } : question),
);
state.llmo.questions.AI = state.llmo.questions.AI || [];
state.llmo.questions.AI = state.llmo.questions.AI.map(
(question) => (question.key === key ? { ...question, ...questionUpdate, key } : question),
);
};

self.addLlmoUrlPatterns = (urlPatterns) => {
Joi.assert(urlPatterns, LLMO_URL_PATTERNS_SCHEMA, 'Invalid URL patterns');

Expand Down
27 changes: 1 addition & 26 deletions packages/spacecat-shared-data-access/src/models/site/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,6 @@ export interface ImportConfig {
export type WellKnownLmmoTag = 'market' | 'product' | 'topic';
export type LmmoTag = `${WellKnownLmmoTag}:${string}` | string;

export interface LlmoQuestion {
key: string;
question: string;
source?: string;
volume?: string;
importTime?: string;
keyword?: string;
url?: string;
tags?: LmmoTag[];
}

export interface LlmoUrlPattern {
urlPattern: string;
tags?: LmmoTag[];
Expand Down Expand Up @@ -137,10 +126,6 @@ export interface SiteConfig {
llmo?: {
dataFolder: string;
brand: string;
questions?: {
Human?: Array<LlmoQuestion>;
AI?: Array<LlmoQuestion>;
};
urlPatterns?: Array<LlmoUrlPattern>;
customerIntent?: Array<LlmoCustomerIntent>;
};
Expand All @@ -167,25 +152,15 @@ export interface SiteConfig {
getLlmoConfig(): {
dataFolder: string;
brand: string;
questions?: { Human?: Array<LlmoQuestion>; AI?: Array<LlmoQuestion> };
urlPatterns?: Array<LlmoUrlPattern>;
customerIntent?: Array<LlmoCustomerIntent>;
} | undefined;
updateLlmoConfig(dataFolder: string, brand: string, questions?: {
Human?: Array<LlmoQuestion>;
AI?: Array<LlmoQuestion>;
}, urlPatterns?: Array<LlmoUrlPattern>): void;
updateLlmoConfig(dataFolder: string, brand: string, urlPatterns?: Array<LlmoUrlPattern>): void;
updateLlmoDataFolder(dataFolder: string): void;
updateLlmoBrand(brand: string): void;
getLlmoDataFolder(): string | undefined;
getLlmoBrand(): string | undefined;
getLlmoHumanQuestions(): LlmoQuestion[] | undefined;
getLlmoAIQuestions(): LlmoQuestion[] | undefined;
getLlmoUrlPatterns(): Array<LlmoUrlPattern> | undefined;
addLlmoHumanQuestions(questions: LlmoQuestion[]): void;
addLlmoAIQuestions(questions: LlmoQuestion[]): void;
removeLlmoQuestion(key: string): void;
updateLlmoQuestion(key: string, questionUpdate: Partial<LlmoQuestion>): void;
addLlmoUrlPatterns(urlPatterns: Array<LlmoUrlPattern>): void;
removeLlmoUrlPattern(urlPattern: string): void;
getLlmoCustomerIntent(): Array<LlmoCustomerIntent>;
Expand Down
Loading
Loading