Skip to content

Commit

Permalink
Show placeholder values (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
SketchingDev authored Feb 20, 2024
1 parent 3f6e44a commit 84c4751
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 38 deletions.
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 7 additions & 7 deletions docs/api/classes/Conversation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)

___

Expand Down Expand Up @@ -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)

___

Expand All @@ -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)

___

Expand Down Expand Up @@ -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)

___

Expand Down Expand Up @@ -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)

___

Expand All @@ -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)
31 changes: 17 additions & 14 deletions packages/genesys-web-messaging-tester-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

```
Expand Down
2 changes: 1 addition & 1 deletion packages/genesys-web-messaging-tester-cli/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { replacePlaceholders } from './replacePlaceholders';

export interface PromptGeneratorResult {
placeholderValues: Record<string, string>;
placeholdersFound: boolean;
prompt: string;
}

Expand All @@ -14,6 +15,7 @@ export function promptGenerator(
if (!scenario.placeholders) {
return {
placeholderValues: {},
placeholdersFound: false,
prompt: scenario.prompt,
};
}
Expand All @@ -28,6 +30,7 @@ export function promptGenerator(

return {
placeholderValues: chosenValues,
placeholdersFound: Object.keys(chosenValues).length > 0,
prompt: updatePrompt(scenario.prompt, chosenValues),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 84c4751

Please sign in to comment.