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
4 changes: 0 additions & 4 deletions docs/openapi/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,6 @@ paths:
$ref: './llmo-api.yaml#/llmo-global-sheet-data'
/sites/{siteId}/llmo/config:
$ref: './llmo-api.yaml#/llmo-config'
/sites/{siteId}/llmo/questions:
$ref: './llmo-api.yaml#/llmo-questions'
/sites/{siteId}/llmo/questions/{questionKey}:
$ref: './llmo-api.yaml#/llmo-question'
/sites/{siteId}/llmo/customer-intent:
$ref: './llmo-api.yaml#/llmo-customer-intent'
/sites/{siteId}/llmo/customer-intent/{intentKey}:
Expand Down
120 changes: 0 additions & 120 deletions docs/openapi/llmo-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -895,126 +895,6 @@ llmo-offboard:
security:
- api_key: [ ]

llmo-questions:
parameters:
- $ref: './parameters.yaml#/siteId'
get:
tags:
- llmo
summary: Get LLMO questions
description: |
Retrieves all LLMO questions (both human and AI) for a specific site.
Returns an object with Human and AI question arrays.
operationId: getLlmoQuestions
responses:
'200':
description: LLMO questions retrieved successfully
content:
application/json:
schema:
$ref: './schemas.yaml#/LlmoQuestions'
'400':
$ref: './responses.yaml#/400'
'401':
$ref: './responses.yaml#/401'
'500':
$ref: './responses.yaml#/500'
security:
- api_key: [ ]
post:
tags:
- llmo
summary: Add LLMO questions
description: |
Adds new questions to the LLMO configuration for a specific site.
Questions can be added to both Human and AI categories.
operationId: addLlmoQuestion
requestBody:
required: true
content:
application/json:
schema:
$ref: './schemas.yaml#/LlmoQuestionsInput'
responses:
'200':
description: LLMO questions added successfully
content:
application/json:
schema:
$ref: './schemas.yaml#/LlmoQuestions'
'400':
$ref: './responses.yaml#/400'
'401':
$ref: './responses.yaml#/401'
'500':
$ref: './responses.yaml#/500'
security:
- api_key: [ ]

llmo-question:
parameters:
- $ref: './parameters.yaml#/siteId'
- name: questionKey
in: path
required: true
description: The unique key of the question to modify
schema:
type: string
format: uuid
example: '123e4567-e89b-12d3-a456-426614174000'
delete:
tags:
- llmo
summary: Remove LLMO question
description: |
Removes a specific question from the LLMO configuration by its unique key.
The question can be from either Human or AI categories.
operationId: removeLlmoQuestion
responses:
'200':
description: LLMO question removed successfully
content:
application/json:
schema:
$ref: './schemas.yaml#/LlmoQuestions'
'400':
$ref: './responses.yaml#/400'
'401':
$ref: './responses.yaml#/401'
'500':
$ref: './responses.yaml#/500'
security:
- api_key: [ ]
patch:
tags:
- llmo
summary: Update LLMO question
description: |
Updates a specific question in the LLMO configuration by its unique key.
The question can be from either Human or AI categories.
operationId: patchLlmoQuestion
requestBody:
required: true
content:
application/json:
schema:
$ref: './schemas.yaml#/LlmoQuestionUpdate'
responses:
'200':
description: LLMO question updated successfully
content:
application/json:
schema:
$ref: './schemas.yaml#/LlmoQuestions'
'400':
$ref: './responses.yaml#/400'
'401':
$ref: './responses.yaml#/401'
'500':
$ref: './responses.yaml#/500'
security:
- api_key: [ ]

llmo-customer-intent:
parameters:
- $ref: './parameters.yaml#/siteId'
Expand Down
98 changes: 0 additions & 98 deletions src/controllers/llmo/llmo.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
composeBaseURL,
} from '@adobe/spacecat-shared-utils';
import { Config } from '@adobe/spacecat-shared-data-access/src/models/site/config.js';
import crypto from 'crypto';
import { Entitlement as EntitlementModel } from '@adobe/spacecat-shared-data-access';
import AccessControlUtil from '../../support/access-control-util.js';
import { triggerBrandProfileAgent } from '../../support/brand-profile-trigger.js';
Expand Down Expand Up @@ -84,17 +83,6 @@ function LlmoController(ctx) {
}
};

// Helper function to validate question key
const validateQuestionKey = (config, questionKey) => {
const humanQuestions = config.getLlmoHumanQuestions() || [];
const aiQuestions = config.getLlmoAIQuestions() || [];

if (!humanQuestions.some((question) => question.key === questionKey)
&& !aiQuestions.some((question) => question.key === questionKey)) {
throw new Error('Invalid question key, please provide a valid question key');
}
};

// Helper function to validate customer intent key
const validateCustomerIntentKey = (config, intentKey) => {
const customerIntent = config.getLlmoCustomerIntent() || [];
Expand Down Expand Up @@ -509,88 +497,6 @@ function LlmoController(ctx) {
}
}

// Handles requests to the LLMO questions endpoint, returns both human and ai questions
const getLlmoQuestions = async (context) => {
const { llmoConfig } = await getSiteAndValidateLlmo(context);
return ok(llmoConfig.questions || {});
};

// Handles requests to the LLMO questions endpoint, adds a new question
// the body format is { Human: [question1, question2], AI: [question3, question4] }
const addLlmoQuestion = async (context) => {
const { log } = context;
const { site, config } = await getSiteAndValidateLlmo(context);

// add the question to the llmoConfig
const newQuestions = context.data;
if (!newQuestions) {
return badRequest('No questions provided in the request body');
}
let updated = false;

// Prepare human questions with unique keys
if (newQuestions.Human && newQuestions.Human.length > 0) {
const humanQuestionsWithKeys = newQuestions.Human.map((question) => ({
...question,
key: crypto.randomUUID(),
}));
config.addLlmoHumanQuestions(humanQuestionsWithKeys);
updated = true;
}

// Prepare AI questions with unique keys
if (newQuestions.AI && newQuestions.AI.length > 0) {
const aiQuestionsWithKeys = newQuestions.AI.map((question) => ({
...question,
key: crypto.randomUUID(),
}));
config.addLlmoAIQuestions(aiQuestionsWithKeys);
updated = true;
}

if (updated) {
await saveSiteConfig(site, config, log, 'adding new questions');
}

// return the updated llmoConfig questions
return ok(config.getLlmoConfig().questions);
};

// Handles requests to the LLMO questions endpoint, removes a question
const removeLlmoQuestion = async (context) => {
const { log } = context;
const { questionKey } = context.params;
const { site, config } = await getSiteAndValidateLlmo(context);

validateQuestionKey(config, questionKey);

// remove the question using the config method
config.removeLlmoQuestion(questionKey);

await saveSiteConfig(site, config, log, 'removing question');

// return the updated llmoConfig questions
return ok(config.getLlmoConfig().questions);
};

// Handles requests to the LLMO questions endpoint, updates a question
const patchLlmoQuestion = async (context) => {
const { log } = context;
const { questionKey } = context.params;
const { data } = context;
const { site, config } = await getSiteAndValidateLlmo(context);

validateQuestionKey(config, questionKey);

// update the question using the config method
config.updateLlmoQuestion(questionKey, data);

await saveSiteConfig(site, config, log, 'updating question');

// return the updated llmoConfig questions
return ok(config.getLlmoConfig().questions);
};

// Handles requests to the LLMO customer intent endpoint, returns customer intent array
const getLlmoCustomerIntent = async (context) => {
try {
Expand Down Expand Up @@ -910,10 +816,6 @@ function LlmoController(ctx) {
queryLlmoSheetData,
getLlmoGlobalSheetData,
getLlmoConfig,
getLlmoQuestions,
addLlmoQuestion,
removeLlmoQuestion,
patchLlmoQuestion,
getLlmoCustomerIntent,
addLlmoCustomerIntent,
removeLlmoCustomerIntent,
Expand Down
4 changes: 0 additions & 4 deletions src/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,6 @@ export default function getRouteHandlers(
'GET /sites/:siteId/llmo/config': llmoController.getLlmoConfig,
'PATCH /sites/:siteId/llmo/config': llmoController.updateLlmoConfig,
'POST /sites/:siteId/llmo/config': llmoController.updateLlmoConfig,
'GET /sites/:siteId/llmo/questions': llmoController.getLlmoQuestions,
'POST /sites/:siteId/llmo/questions': llmoController.addLlmoQuestion,
'DELETE /sites/:siteId/llmo/questions/:questionKey': llmoController.removeLlmoQuestion,
'PATCH /sites/:siteId/llmo/questions/:questionKey': llmoController.patchLlmoQuestion,
'GET /sites/:siteId/llmo/customer-intent': llmoController.getLlmoCustomerIntent,
'POST /sites/:siteId/llmo/customer-intent': llmoController.addLlmoCustomerIntent,
'DELETE /sites/:siteId/llmo/customer-intent/:intentKey': llmoController.removeLlmoCustomerIntent,
Expand Down
Loading