diff --git a/README.md b/README.md index 6d5f02b..3772a17 100644 --- a/README.md +++ b/README.md @@ -32,19 +32,18 @@ scenarios: "Accept Survey": - say: hi - waitForReplyContaining: Can we ask you some questions about your experience today? - - say: Yes + - say: 'Yes' - waitForReplyMatching: Thank you! Now for the next question[\.]+ "Decline Survey": - say: hi - waitForReplyContaining: Can we ask you some questions about your experience today? - - say: No + - say: 'No' - waitForReplyContaining: Maybe next time. Goodbye "Provide Incorrect Answer to Survey Question": - say: hi - waitForReplyContaining: Can we ask you some questions about your experience today? - - say: Not sure - - waitForReplyContaining: Sorry I didn't understand you. Please answer with either 'yes' or 'no' - - waitForReplyContaining: Can we ask you some questions about your experience today? + - say: Example + - waitForReplyContaining: Sorry. Please input "Yes" or "No". Do you want to proceed? ``` ## How it works @@ -81,19 +80,18 @@ scenarios: "Accept Survey": - say: hi - waitForReplyContaining: Can we ask you some questions about your experience today? - - say: Yes + - say: 'Yes' - waitForReplyMatching: Thank you! Now for the next question[\.]+ "Decline Survey": - say: hi - waitForReplyContaining: Can we ask you some questions about your experience today? - - say: No + - say: 'No' - waitForReplyContaining: Maybe next time. Goodbye "Provide Incorrect Answer to Survey Question": - say: hi - waitForReplyContaining: Can we ask you some questions about your experience today? - - say: Not sure - - waitForReplyContaining: Sorry I didn't understand you. Please answer with either 'yes' or 'no' - - waitForReplyContaining: Can we ask you some questions about your experience today? + - say: Example + - waitForReplyContaining: Sorry. Please input "Yes" or "No". Do you want to proceed? ``` Then run the test by pointing to the dialogue script file in the terminal: @@ -133,8 +131,12 @@ config: scenarios: "Accept survey": setup: + placeholders: + NAME: + - John + - Jane prompt: | - I want you to play the role of a customer talking to a company's online chatbot. You must not + I want you to play the role of a customer called {NAME}, talking to a company's online chatbot. You must not break from this role, and all of your responses must be based on how a customer would realistically talk to a company's chatbot. To help you play the role of a customer consider the following points when writing a response: @@ -182,7 +184,10 @@ config: config: location: example-location project: example-gcp-project - modelVersion: 002 + modelVersion: "002" + examples: + - input: "What would you like to do today?" + output: "I would like to leave feedback, please" scenarios: "Accept survey": setup: diff --git a/docs/api/classes/Conversation.md b/docs/api/classes/Conversation.md index acdf68f..1ce16fa 100644 --- a/docs/api/classes/Conversation.md +++ b/docs/api/classes/Conversation.md @@ -80,7 +80,7 @@ Returns whether the conversation has been disconnected #### Defined in -[packages/genesys-web-messaging-tester/src/Conversation.ts:198](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/Conversation.ts#L198) +[packages/genesys-web-messaging-tester/src/Conversation.ts:203](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/Conversation.ts#L203) ## Methods @@ -103,7 +103,7 @@ Sends text to the conversation #### Defined in -[packages/genesys-web-messaging-tester/src/Conversation.ts:229](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/Conversation.ts#L229) +[packages/genesys-web-messaging-tester/src/Conversation.ts:234](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/Conversation.ts#L234) ___ @@ -142,7 +142,7 @@ background. This method allows you to wait for this process to finish. #### Defined in -[packages/genesys-web-messaging-tester/src/Conversation.ts:208](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/Conversation.ts#L208) +[packages/genesys-web-messaging-tester/src/Conversation.ts:213](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/Conversation.ts#L213) ___ @@ -160,7 +160,7 @@ If you want to wait for a specific message use [waitForResponseWithTextContainin #### Defined in -[packages/genesys-web-messaging-tester/src/Conversation.ts:255](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/Conversation.ts#L255) +[packages/genesys-web-messaging-tester/src/Conversation.ts:260](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/Conversation.ts#L260) ___ @@ -192,7 +192,7 @@ use [waitForResponseText](Conversation.md#waitforresponsetext). #### Defined in -[packages/genesys-web-messaging-tester/src/Conversation.ts:313](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/Conversation.ts#L313) +[packages/genesys-web-messaging-tester/src/Conversation.ts:318](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/Conversation.ts#L318) ___ @@ -221,7 +221,7 @@ use [waitForResponseText](Conversation.md#waitforresponsetext). #### Defined in -[packages/genesys-web-messaging-tester/src/Conversation.ts:344](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/Conversation.ts#L344) +[packages/genesys-web-messaging-tester/src/Conversation.ts:349](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/Conversation.ts#L349) ___ @@ -243,4 +243,4 @@ Wait for all responses until there is a predefined amount of 'silence'. #### Defined in -[packages/genesys-web-messaging-tester/src/Conversation.ts:271](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/Conversation.ts#L271) +[packages/genesys-web-messaging-tester/src/Conversation.ts:276](https://github.com/ovotech/genesys-web-messaging-tester/blob/main/packages/genesys-web-messaging-tester/src/Conversation.ts#L276) diff --git a/packages/genesys-web-messaging-tester-cli/README.md b/packages/genesys-web-messaging-tester-cli/README.md index 3866e2f..3772a17 100644 --- a/packages/genesys-web-messaging-tester-cli/README.md +++ b/packages/genesys-web-messaging-tester-cli/README.md @@ -32,19 +32,18 @@ scenarios: "Accept Survey": - say: hi - waitForReplyContaining: Can we ask you some questions about your experience today? - - say: Yes + - say: 'Yes' - waitForReplyMatching: Thank you! Now for the next question[\.]+ "Decline Survey": - say: hi - waitForReplyContaining: Can we ask you some questions about your experience today? - - say: No + - say: 'No' - waitForReplyContaining: Maybe next time. Goodbye "Provide Incorrect Answer to Survey Question": - say: hi - waitForReplyContaining: Can we ask you some questions about your experience today? - - say: Not sure - - waitForReplyContaining: Sorry I didn't understand you. Please answer with either 'yes' or 'no' - - waitForReplyContaining: Can we ask you some questions about your experience today? + - say: Example + - waitForReplyContaining: Sorry. Please input "Yes" or "No". Do you want to proceed? ``` ## How it works @@ -81,19 +80,18 @@ scenarios: "Accept Survey": - say: hi - waitForReplyContaining: Can we ask you some questions about your experience today? - - say: Yes + - say: 'Yes' - waitForReplyMatching: Thank you! Now for the next question[\.]+ "Decline Survey": - say: hi - waitForReplyContaining: Can we ask you some questions about your experience today? - - say: No + - say: 'No' - waitForReplyContaining: Maybe next time. Goodbye "Provide Incorrect Answer to Survey Question": - say: hi - waitForReplyContaining: Can we ask you some questions about your experience today? - - say: Not sure - - waitForReplyContaining: Sorry I didn't understand you. Please answer with either 'yes' or 'no' - - waitForReplyContaining: Can we ask you some questions about your experience today? + - say: Example + - waitForReplyContaining: Sorry. Please input "Yes" or "No". Do you want to proceed? ``` Then run the test by pointing to the dialogue script file in the terminal: @@ -133,8 +131,12 @@ config: scenarios: "Accept survey": setup: + placeholders: + NAME: + - John + - Jane prompt: | - I want you to play the role of a customer talking to a company's online chatbot. You must not + I want you to play the role of a customer called {NAME}, talking to a company's online chatbot. You must not break from this role, and all of your responses must be based on how a customer would realistically talk to a company's chatbot. To help you play the role of a customer consider the following points when writing a response: @@ -182,7 +184,10 @@ config: config: location: example-location project: example-gcp-project - modelVersion: 002 + modelVersion: "002" + examples: + - input: "What would you like to do today?" + output: "I would like to leave feedback, please" scenarios: "Accept survey": setup: @@ -212,8 +217,6 @@ Then run the AI test by pointing to the scenario file in the terminal: web-messaging-tester ai tests/example.yml ``` -For a slightly more detailed guide see: [Let's test a Genesys chatbot with AI](https://www.linkedin.com/pulse/lets-test-genesys-chatbot-ai-lucas-woodward-dvrpc). - ## Example commands ``` diff --git a/packages/genesys-web-messaging-tester-cli/package.json b/packages/genesys-web-messaging-tester-cli/package.json index 09ae4bd..637aa07 100644 --- a/packages/genesys-web-messaging-tester-cli/package.json +++ b/packages/genesys-web-messaging-tester-cli/package.json @@ -1,6 +1,6 @@ { "name": "@ovotech/genesys-web-messaging-tester-cli", - "version": "3.0.1", + "version": "3.0.2", "main": "lib/index.js", "types": "lib/index.d.ts", "license": "Apache-2.0", diff --git a/packages/genesys-web-messaging-tester-cli/src/commands/aiTest/createAiTestCommand.ts b/packages/genesys-web-messaging-tester-cli/src/commands/aiTest/createAiTestCommand.ts index 8f20648..3b95fc7 100644 --- a/packages/genesys-web-messaging-tester-cli/src/commands/aiTest/createAiTestCommand.ts +++ b/packages/genesys-web-messaging-tester-cli/src/commands/aiTest/createAiTestCommand.ts @@ -157,8 +157,10 @@ export function createAiTestCommand({ const messages: Utterance[] = []; const generatedPrompt = promptGenerator(scenario.setup); - outputConfig.writeOut(ui.displayPrompt(generatedPrompt)); - outputConfig.writeOut(ui.conversationStartHeader()); + if (generatedPrompt.placeholdersFound) { + outputConfig.writeOut(ui.displayPlaceholders(generatedPrompt)); + outputConfig.writeOut(ui.conversationStartHeader()); + } let endConversation: ShouldEndConversationResult = { hasEnded: false, diff --git a/packages/genesys-web-messaging-tester-cli/src/commands/aiTest/prompt/generation/promptGenerator.ts b/packages/genesys-web-messaging-tester-cli/src/commands/aiTest/prompt/generation/promptGenerator.ts index 6d2d0af..0faa4ee 100644 --- a/packages/genesys-web-messaging-tester-cli/src/commands/aiTest/prompt/generation/promptGenerator.ts +++ b/packages/genesys-web-messaging-tester-cli/src/commands/aiTest/prompt/generation/promptGenerator.ts @@ -3,6 +3,7 @@ import { replacePlaceholders } from './replacePlaceholders'; export interface PromptGeneratorResult { placeholderValues: Record; + placeholdersFound: boolean; prompt: string; } @@ -14,6 +15,7 @@ export function promptGenerator( if (!scenario.placeholders) { return { placeholderValues: {}, + placeholdersFound: false, prompt: scenario.prompt, }; } @@ -28,6 +30,7 @@ export function promptGenerator( return { placeholderValues: chosenValues, + placeholdersFound: Object.keys(chosenValues).length > 0, prompt: updatePrompt(scenario.prompt, chosenValues), }; } diff --git a/packages/genesys-web-messaging-tester-cli/src/commands/aiTest/ui.ts b/packages/genesys-web-messaging-tester-cli/src/commands/aiTest/ui.ts index 9aac176..19d2ffd 100644 --- a/packages/genesys-web-messaging-tester-cli/src/commands/aiTest/ui.ts +++ b/packages/genesys-web-messaging-tester-cli/src/commands/aiTest/ui.ts @@ -51,8 +51,12 @@ export class Ui { ); } - public displayPrompt({ prompt }: PromptGeneratorResult): string { - return Ui.trailingNewline(chalk.grey(prompt)); + public displayPlaceholders({ placeholderValues }: PromptGeneratorResult): string { + const values = Object.entries(placeholderValues); + return Ui.trailingNewline( + chalk.grey(values.map(([key, value]) => `${key}: ${value}`).join('\n')), + 2, + ); } public conversationStartHeader(): string {