aboutsummaryrefslogtreecommitdiff
path: root/src/client/apis/gpt/customization.ts
diff options
context:
space:
mode:
authorSophie Zhang <sophie_zhang@brown.edu>2024-02-29 01:25:37 -0500
committerSophie Zhang <sophie_zhang@brown.edu>2024-02-29 01:25:37 -0500
commiteb5746da51bf44aeacb41d6337f666e178fae88e (patch)
tree8ab69fc2849065d4cd01e20b0821164d8f444abf /src/client/apis/gpt/customization.ts
parentb960beb2f31327becdf6709a61b90523abdee65a (diff)
added curr slide info to slide customization
Diffstat (limited to 'src/client/apis/gpt/customization.ts')
-rw-r--r--src/client/apis/gpt/customization.ts24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/client/apis/gpt/customization.ts b/src/client/apis/gpt/customization.ts
index db5ef6eb5..946208eeb 100644
--- a/src/client/apis/gpt/customization.ts
+++ b/src/client/apis/gpt/customization.ts
@@ -35,7 +35,7 @@ interface PromptInfo {
const prompts: { [key: string]: PromptInfo } = {
trails: {
description:
- 'We are adding customization to a slide in a presentation. Given a natural language input, translate it into a json with the required fields: [title, presentation_transition, presentation_effect, config_zoom, presentation_effectDirection].',
+ 'We are customizing the properties and transition of a slide in a presentation. You are given the current properties of the slide in a json with the fields [title, presentation_transition, presentation_effect, config_zoom, presentation_effectDirection], as well as the prompt for how the user wants to change it. Return a json with the required fields: [title, presentation_transition, presentation_effect, config_zoom, presentation_effectDirection] by applying the changes in the prompt to the current state of the slide.',
features: [],
},
};
@@ -44,19 +44,24 @@ export const addCustomizationProperty = (type: CustomizationType, name: string,
values ? prompts[type].features.push({ name, description, values }) : prompts[type].features.push({ name, description });
};
+export const gptSlideProperties = ['title', 'presentation_transition', 'presentation_effect', 'presentation_effectDirection', 'config_zoom'];
+
const setupPresSlideCustomization = () => {
addCustomizationProperty(CustomizationType.PRES_TRAIL_SLIDE, 'title', 'is the title/name of the slide.');
addCustomizationProperty(CustomizationType.PRES_TRAIL_SLIDE, 'presentation_transition', 'is a number in milliseconds for how long it should take to transition/move to a slide.');
addCustomizationProperty(CustomizationType.PRES_TRAIL_SLIDE, 'presentation_effect', 'is an effect applied to the slide when we transition to it.', ['None', 'Fade in', 'Flip', 'Rotate', 'Bounce', 'Roll']);
+ addCustomizationProperty(CustomizationType.PRES_TRAIL_SLIDE, 'presentation_effectDirection', 'is what direction the effect is applied.', ['Enter from left', 'Enter from right', 'Enter from bottom', 'Enter from Top', 'Enter from center']);
+ addCustomizationProperty(CustomizationType.PRES_TRAIL_SLIDE, 'config_zoom', 'is a number from 0 to 1.0 indicating the percentage we should zoom into the slide.');
};
setupPresSlideCustomization();
-export const gptTrailSlideCustomization = async (inputText: string) => {
+export const gptTrailSlideCustomization = async (inputText: string, properties: any) => {
+ console.log('properties', properties);
let prompt = prompts.trails.description;
prompts.trails.features.forEach(feature => {
- prompt += feature.name + feature.description;
+ prompt += feature.name + ' ' + feature.description;
if (feature.values) {
prompt += `Its only possible values are [${feature.values.join(', ')}].`;
}
@@ -65,16 +70,21 @@ export const gptTrailSlideCustomization = async (inputText: string) => {
// prompt +=
// 'title is the title/name of the slide. presentation_transition is a number in milliseconds for how long it should take to transition/move to a slide. presentation_effect is an effect applied to the slide when we transition to it. Its only possible values are: [None, Fade in, Flip, Rotate, Bounce, Roll]. presentation_effectDirection is what direction the effect is applied. Its only possible values are: [Enter from left, Enter from right, Enter from bottom, Enter from Top, Enter from center]. config_zoom is a number from 0 to 1.0 indicating the percentage we should zoom into the slide.';
- prompt += 'If the input does not contain info a specific key, please set their value to null. Please only return the json with these keys and their values.';
+ prompt += 'Set unchanged values to null. Please only return the json with these keys and their values.';
+
+ console.log('messages', [
+ { role: 'system', content: prompt },
+ { role: 'user', content: `Prompt: ${inputText}, Current properties: ${JSON.stringify(properties)}` },
+ ]);
try {
const response = await openai.chat.completions.create({
- model: 'gpt-3.5-turbo',
+ model: 'gpt-4',
messages: [
{ role: 'system', content: prompt },
- { role: 'user', content: inputText },
+ { role: 'user', content: `Prompt: ${inputText}, Current properties: ${JSON.stringify(properties)}` },
],
- temperature: 0.1,
+ temperature: 0,
max_tokens: 1000,
});
return response.choices[0].message?.content;