Skip to content

Commit

Permalink
fix: more demo changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Dec 20, 2024
1 parent 500dc58 commit 727fd13
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@inquirer/prompts": "^7.2.0",
"@oclif/core": "^4",
"@oclif/multi-stage-output": "^0.7.12",
"@salesforce/agents": "^0.5.2",
"@salesforce/agents": "^0.5.3",
"@salesforce/core": "^8.8.0",
"@salesforce/kit": "^3.2.1",
"@salesforce/sf-plugins-core": "^12.1.0",
Expand Down
30 changes: 21 additions & 9 deletions src/commands/agent/generate/test-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export type TestSetInputs = {
topicSequenceExpectedValue: string;
};

function castArray<T>(value: T | T[]): T[] {
return Array.isArray(value) ? value : [value];
}

async function promptForTestCase(genAiPlugins: Record<string, string>): Promise<TestSetInputs> {
const utterance = await input({
message: 'Utterance',
Expand Down Expand Up @@ -96,7 +100,7 @@ async function promptForTestCase(genAiPlugins: Record<string, string>): Promise<
const genAiPluginXml = await readFile(genAiPlugins[topicSequenceExpectedValue], 'utf-8');
const parser = new XMLParser();
const parsed = parser.parse(genAiPluginXml) as { GenAiPlugin: { genAiFunctions: Array<{ functionName: string }> } };
const actions = parsed.GenAiPlugin.genAiFunctions.map((f) => f.functionName);
const actions = castArray(parsed.GenAiPlugin.genAiFunctions).map((f) => f.functionName);

let actionSequenceExpectedValue = await checkbox<string>({
message: 'Expected action(s)',
Expand Down Expand Up @@ -160,14 +164,22 @@ export default class AgentGenerateTestset extends SfCommand<void> {
public async run(): Promise<void> {
const testSetName = await input({
message: 'What is the name of this set of test cases',
// TODO: add back validation once we refine the regex
// validate(d: string): boolean | string {
// // check against FORTY_CHAR_API_NAME_REGEX
// if (!FORTY_CHAR_API_NAME_REGEX.test(d)) {
// return 'The non-namespaced portion an API name must begin with a letter, contain only letters, numbers, and underscores, not contain consecutive underscores, and not end with an underscore.';
// }
// return true;
// },

validate(d: string): boolean | string {
// ensure that it's not empty
if (!d.length) {
return 'Name cannot be empty';
}

return true;

// TODO: add back validation once we refine the regex
// check against FORTY_CHAR_API_NAME_REGEX
// if (!FORTY_CHAR_API_NAME_REGEX.test(d)) {
// return 'The non-namespaced portion an API name must begin with a letter, contain only letters, numbers, and underscores, not contain consecutive underscores, and not end with an underscore.';
// }
// return true;
},
});

const genAiPluginDir = join('force-app', 'main', 'default', 'genAiPlugins');
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1483,10 +1483,10 @@
resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"
integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==

"@salesforce/agents@^0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@salesforce/agents/-/agents-0.5.2.tgz#b60e7227a78e3c4431565ba6e3862aa97c65306f"
integrity sha512-Khr24nZlV875PPwrmFjfDBSMi7Hqfrb6+Y+d8I4OHMU7iP+U9lnvRAwczD9o+WB5gq6WSCkhgQY89QmAA55dKw==
"@salesforce/agents@^0.5.3":
version "0.5.3"
resolved "https://registry.yarnpkg.com/@salesforce/agents/-/agents-0.5.3.tgz#e6761df2abebc2317495e1ee18df42e6766c21be"
integrity sha512-en/nJAKm5WRB6GwxE83H0dM3rlOr9nDrGEU7LsQHNkEwEZ/mPAk1MF9r/0KLE7iLuN8638HMmOTHd3jp6YghRw==
dependencies:
"@oclif/table" "^0.3.5"
"@salesforce/core" "^8.8.0"
Expand Down

0 comments on commit 727fd13

Please sign in to comment.