Skip to content

Commit 9740921

Browse files
authored
feat: pre-determined creative prompts (#417)
test: prompt feat
1 parent 6a383dd commit 9740921

File tree

24 files changed

+699
-18
lines changed

24 files changed

+699
-18
lines changed

cypress/e2e/builder/main.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
BUILDER_VIEW_CY,
66
NEXT_ROUND_BTN_CY,
77
PLAY_PAUSE_BUTTON_CY,
8-
PROPOSE_NEW_RESPONSE_BTN,
8+
PROPOSE_NEW_RESPONSE_BTN_CY,
99
RESPONSE_COLLECTION_VIEW_CY,
1010
SETTINGS_TAB_CY,
1111
SETTINGS_VIEW_CY,
@@ -47,7 +47,7 @@ describe('Builder View with admin rights, no settings', () => {
4747

4848
cy.get(buildDataCy(RESPONSE_COLLECTION_VIEW_CY)).within(() => {
4949
newIdeas.forEach((idea) => {
50-
cy.get(buildDataCy(PROPOSE_NEW_RESPONSE_BTN)).click();
50+
cy.get(buildDataCy(PROPOSE_NEW_RESPONSE_BTN_CY)).click();
5151
cy.get('#input-response').type('a');
5252
cy.get('#input-response').type('{backspace}');
5353
cy.get('#input-response').should('be.enabled');

cypress/e2e/player/main.cy.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
LIKERT_RATING_CY,
77
NEXT_STEP_BTN_CY,
88
ORCHESTRATION_BAR_CY,
9+
PROMPTS_CY,
10+
PROPOSE_NEW_RESPONSE_BTN_CY,
911
RESPONSE_COLLECTION_VIEW_CY,
1012
RESPONSE_CY,
1113
RESPONSE_EVALUATION_VIEW_CY,
@@ -53,6 +55,21 @@ describe('Player with read rights and collection activity.', () => {
5355
ALL_SETTINGS_OBJECT.instructions.details?.content,
5456
);
5557
});
58+
59+
it('checks the prompts', () => {
60+
cy.get(buildDataCy(PROPOSE_NEW_RESPONSE_BTN_CY)).click();
61+
62+
cy.get(buildDataCy(PROMPTS_CY.DASHBOARD)).should('be.visible');
63+
cy.get(buildDataCy(PROMPTS_CY.PROMPT)).should('not.be.visible');
64+
65+
cy.get(buildDataCy(PROMPTS_CY.REQUEST_BUTTON)).click();
66+
67+
cy.get(buildDataCy(PROMPTS_CY.PROMPT)).should('be.visible');
68+
cy.get(buildDataCy(PROMPTS_CY.PROMPT_STEP)).should(
69+
'have.length',
70+
ALL_SETTINGS_OBJECT.prompts.maxNumberOfQueries,
71+
);
72+
});
5673
});
5774

5875
describe('Player with read rights and evaluation activity.', () => {

cypress/fixtures/appSettings.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ export const ALL_SETTINGS_OBJECT: AllSettingsType = {
9090
assistants: {
9191
assistants: [],
9292
},
93+
prompts: {
94+
selectedSet: 'test',
95+
maxNumberOfQueries: 5,
96+
},
9397
};
9498

9599
export const ALL_SETTINGS = Object.entries(ALL_SETTINGS_OBJECT).map(

src/@types/what-ifs.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { Prompt, PromptAuthor, PromptCategory } from '@/interfaces/prompt';
2+
3+
declare module 'what-ifs.json' {
4+
// eslint-disable-next-line no-labels, no-restricted-syntax
5+
Array<{
6+
name: string;
7+
description: string;
8+
author: Array<PromptAuthor>;
9+
link: string;
10+
categories: Array<PromptCategory>;
11+
set: Array<Prompt>;
12+
}>;
13+
Array<string>;
14+
}

src/config/appActionsTypes.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Data, LocalContext } from '@graasp/apps-query-client';
22
import { AppAction, AppData } from '@graasp/sdk';
33

44
import { ActivityStep } from '@/interfaces/interactionProcess';
5+
import { Prompt } from '@/interfaces/prompt';
56
import {
67
CurrentStateData,
78
RatingsData,
@@ -21,6 +22,7 @@ export enum AppActionTypes {
2122
PreviousStep = 'previous-step',
2223
PlayActivity = 'play-activity',
2324
PauseActivity = 'pause-activity',
25+
RequestPrompt = 'request-prompt',
2426
}
2527

2628
type AppDataRef<T extends Data> = Pick<AppData<T>, 'id' | 'type' | 'data'> &
@@ -73,3 +75,8 @@ export type PlayActivityAction = Pick<AppAction, 'type' | 'data'> & {
7375
export type PauseActivityAction = Pick<AppAction, 'type' | 'data'> & {
7476
type: AppActionTypes.PauseActivity;
7577
};
78+
79+
export type RequestPromptAction = Pick<AppAction, 'type' | 'data'> & {
80+
type: AppActionTypes.RequestPrompt;
81+
data: { prompt: Prompt; promptRequestNumber: number };
82+
};

src/config/appDataTypes.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import { ChatbotResponseData } from '@/interfaces/chatbot';
55
import { EvaluationType } from '@/interfaces/evaluationType';
66
import { ActivityStatus, ActivityType } from '@/interfaces/interactionProcess';
77
import { UsefulnessNoveltyRatings } from '@/interfaces/ratings';
8+
import { PromptsData } from '@/interfaces/prompt';
89

910
export enum AppDataTypes {
1011
Response = 'response',
1112
ResponsesSet = 'responses-set',
1213
CurrentState = 'current-state',
1314
Ratings = 'ratings',
1415
ChatbotResponse = 'chatbot-response',
16+
Prompts = 'prompts',
1517
}
1618

1719
export type ResponseData<T = UsefulnessNoveltyRatings> = {
@@ -23,6 +25,7 @@ export type ResponseData<T = UsefulnessNoveltyRatings> = {
2325
encoding?: 'raw' | 'markdown';
2426
originalResponse?: string;
2527
ratings?: T;
28+
givenPrompt?: string;
2629
};
2730

2831
export type ResponseAppData = AppData & {
@@ -70,3 +73,9 @@ export type ChatbotResponseAppData = AppData & {
7073
data: ChatbotResponseData;
7174
visibility: AppDataVisibility.Member;
7275
};
76+
77+
export type PromptsAppData = AppData & {
78+
type: AppDataTypes.Prompts;
79+
data: PromptsData;
80+
visibility: AppDataVisibility.Member;
81+
};

src/config/appSettingsType.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ export type AssistantsSetting = {
4848
includeDetails?: boolean;
4949
};
5050

51+
export type PromptsSetting = {
52+
selectedSet?: string;
53+
maxNumberOfQueries?: number;
54+
};
55+
5156
export type NotParticipatingSetting = { ids: Member['id'][] };
5257

5358
export type AllSettingsType = {
@@ -59,6 +64,7 @@ export type AllSettingsType = {
5964
systemPrompt: string;
6065
};
6166
assistants: AssistantsSetting;
67+
prompts: PromptsSetting;
6268
};
6369

6470
// default values for the data property of settings by name
@@ -129,4 +135,8 @@ export const defaultSettingsValues: AllSettingsType = {
129135
promptMode: PromptMode.Problem,
130136
includeDetails: false,
131137
},
138+
prompts: {
139+
selectedSet: undefined,
140+
maxNumberOfQueries: undefined,
141+
},
132142
};

src/config/constants.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,14 @@ export const DEFAULT_CHATBOT_RESPONSE_APP_DATA: Pick<
4545
export const DEFAULT_BOT_USERNAME = 'GraaspBot';
4646
export const SHORT_TIME_LIMIT = 10; // seconds
4747
export const DEFAULT_LANG = 'en';
48+
49+
export const CATEGORY_COLORS = [
50+
'#ffadad',
51+
'#ffd6a5',
52+
'#fdffb6',
53+
'#caffbf',
54+
'#9bf6ff',
55+
'#a0c4ff',
56+
'#bdb2ff',
57+
'#ffc6ff',
58+
];

src/config/selectors.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const CODE_EDITOR_ID_CY = 'code-editor-id';
1111
export const SETTING_CHATBOT_PROMPT_CODE_EDITOR_CY =
1212
'setting-chatbot-prompt-code-editor';
1313

14-
export const PROPOSE_NEW_RESPONSE_BTN = 'propose-new-response';
14+
export const PROPOSE_NEW_RESPONSE_BTN_CY = 'propose-new-response';
1515
export const RESPONSE_INPUT_FIELD_CY = 'response-input-field';
1616
export const SUBMIT_RESPONSE_BTN_CY = 'submit-response-button';
1717
export const NEXT_ROUND_BTN_CY = 'next-round';
@@ -37,5 +37,12 @@ export const RESPONSE_CY = 'response';
3737

3838
export const LIKERT_RATING_CY = 'likert-rating';
3939

40+
export const PROMPTS_CY = {
41+
REQUEST_BUTTON: 'prompts-request-button',
42+
PROMPT_STEP: 'prompt-step-indicator',
43+
DASHBOARD: 'prompts-dashboard',
44+
PROMPT: 'prompt',
45+
};
46+
4047
export const buildDataCy = (selector: string): string =>
4148
`[data-cy=${selector}]`;

src/config/what-ifs.json

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"sets": [
3+
{
4+
"id": "test",
5+
"name": "Test set",
6+
"description": "Those prompts are made for testing purpose.",
7+
"author": ["Jérémy La Scala"],
8+
"link": "",
9+
"categories": ["question"],
10+
"set": [
11+
{
12+
"title": "Imagine that you have unlimited resources to bring your idea to life.",
13+
"details": "",
14+
"category": "question"
15+
},
16+
{
17+
"title": "Imagine that your idea must work if everyone works from home.",
18+
"details": "",
19+
"category": "question"
20+
}
21+
]
22+
},
23+
{
24+
"id": "explorerLabs-52cards",
25+
"name": "52 Sustainability Ideation & Brainstorm Cards",
26+
"description": "These cards help you quickly generate sustainability focused radical & disruptive business ideas to take forward & test with your key ecosystem stakeholders.\n\nThey help you think critically & creatively by asking questions from 4P sustainability lenses. People, Planet, Profit & Progress.",
27+
"author": ["Explorer Labs"],
28+
"link": "https://www.explorerlabs.co/tools-canvases/52-sustainability-ideation-brainstorm-cards",
29+
"categories": ["people", "planet", "profit", "progress"],
30+
"set": [
31+
{
32+
"title": "What if: your employees moved country every week?",
33+
"details": "Imagine your employees shifted country every week, enabled by digital-nomadic lifestyles. How could this bring you new business opportunities? Which new ways of working & collaborating could emerge? The average digital nomad is aged 32 yrs, works 40 hours /week & earns ~$100k+ /yr.",
34+
"category": "people"
35+
},
36+
{
37+
"title": "What if: all your customers only bought from net-zero GHG companies?",
38+
"details": "Imagine all your customers refused to buy from non-net-zero companies. What immediate steps would you need to take to become net-zero in the shortest amount of time? Company targets for net-zero at Ørsted, Wipro, AstraZeneca have already been independently validated by Science Based Targets (SBTi).",
39+
"category": "people"
40+
},
41+
{
42+
"title": "What if: truth no longer existed in society?",
43+
"details": "Imagine there was no such thing as objective truth any more. Who would provide an authentic voice? If your customers trusted no-one, where would they get their information? How will they make informed buying decisions? How would they believe your approach to addressing sustainability challenges? Report: The Real Inconvenient Truth (MIT).",
44+
"category": "people"
45+
},
46+
{
47+
"title": "What if: lockdowns occurred every 4 months for 30 days?",
48+
"details": "Imagine new COVID variants create the need to lockdown for 30 days, three times a year. How would this impact your company’s carbon footprint? Which new ways of working would this trigger? How would you keep track & quantify your annual GHG/Co2 emissions? How could you take advantage of this? Think: #antifragile",
49+
"category": "people"
50+
},
51+
{
52+
"title": "What if: climate hacktivists leaked all your company data?",
53+
"details": "Imagine climate hacktivists leaked all your digital databases & files, creating 100% transparency on your real global sustainability impact. How would you respond? Would there be a gap between what you claim you’re doing vs what you’re actually doing? How can you bridge this gap? Example: BBC leaked report on how companies are subverting scientific reports on climate change.",
54+
"category": "people"
55+
},
56+
{
57+
"title": "What if: your customers became your stakeholders?",
58+
"details": "Imagine your customers become your key business stakeholders. They can influence your internal operations. Companies like Airbnb, Salesforce, Alltrue & Southwest Airlines have created programs of giving-back & including their customers as stakeholder in key business decisions & strategic direction. How would this change your business?",
59+
"category": "people"
60+
},
61+
{
62+
"title": "What if: 90% of the population relocated to rural areas?",
63+
"details": "Imagine if most people wanted to get back in touch with nature. Health & wellbeing valued above all else. Counterurbanization or deurbanization is a reality & on the rise due to the pandemic, rising stress, prices resulting in re-prioritization of human needs & quality of life. How should your organisation respond to thrive from this social living shift?",
64+
"category": "people"
65+
},
66+
{
67+
"title": "What if: your main partners were suddenly subject to trade sanctions?",
68+
"details": "Imagine your key business partners were subject to overnight trade sanctions due to their carbon footprint being too high. How would you adjust your business model & operations? What scenarios would you create? How would you pivot, fast? Example: EU’s Environmental Crime laws & legislation.",
69+
"category": "people"
70+
},
71+
{
72+
"title": "What if: working from home was mandatory 50% time?",
73+
"details": "Imagine government legislation forces all employees to work from home 50% of the time, indefinitely to reduce speed of climate change. How would this affect your business model? Could you still operative profitably in the long term? If not, how would you need to change & adjust accordingly? #workfromanywhere",
74+
"category": "people"
75+
},
76+
{
77+
"title": "What if: all your employees went on strike due to lack of sustainability focus?",
78+
"details": "Imagine your employee’s decided to enforce sustainability change by striking or walking-out. What drastic sustainability improvements would you be prepared to make as part of the negotiation process? In 2020, 300+ Amazon employees went on strike to draw attention to poor environmental business practices.",
79+
"category": "people"
80+
},
81+
{
82+
"title": "What if: all companies were capped at 10k employees globally?",
83+
"details": "Imagine companies could no longer hold more than 10k employees as part of a global agreement. How would this impact your ability to deliver customer & sustainability value? Who would you need to partner with? How would you reorganize the business? #sustainabilitysizeperformance",
84+
"category": "people"
85+
},
86+
{
87+
"title": "What if: buying local was the only option?",
88+
"details": "Imagine your customers refused to buy your products & services unless they were produced entirely in their home country. Would you seek different customers entirely? How would you need to modify your value chain? Protectionism is on the rise due to the current economic uncertainties, inflation, interest rates & cost of living crisis...",
89+
"category": "people"
90+
},
91+
{
92+
"title": "What if: customers showed you were greenwashing?",
93+
"details": "Imagine your customers determined your ‘sustainability mission’ merely made tiny alterations to your sustainability footprint & accused you of greenwashing. How would you need to modify your products, services, offers & business model to actually deliver sustainability impact? Examples: The infamous Volkswagen emissions tests cheating scandal & BP’s name change to Beyond Petroleum.",
94+
"category": "people"
95+
}
96+
]
97+
}
98+
]
99+
}

0 commit comments

Comments
 (0)