Skip to content

Commit 71d8f75

Browse files
authored
Merge pull request #132 from synapsy-ai/vNext
Version 1.9.1
2 parents db7cf03 + 23ab6dc commit 71d8f75

File tree

9 files changed

+170
-5
lines changed

9 files changed

+170
-5
lines changed

app/[lng]/create/page.tsx

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
getComplexEssayPrompts,
2323
getModels,
2424
getPrompt,
25+
getPromptComplexAnalysis,
2526
getStandardGeneration,
2627
getSystem,
2728
sendToGpt,
@@ -210,13 +211,121 @@ export default function CreatePage({
210211
createComplexEssay();
211212
} else if (type == "ph_complex") {
212213
createComplexPhiloEssay();
214+
} else if (type === "ph_analysis_complex") {
215+
createComplexPhiloAnalysis();
213216
} else if (type.startsWith("ph_analysis_")) {
214217
createAnalysis();
215218
} else {
216219
create();
217220
}
218221
}
219222

223+
async function createComplexPhiloAnalysis() {
224+
setInProgress(true);
225+
setErrorVis(false);
226+
setIsGen(false);
227+
228+
// 1. Generate the outline
229+
const outline = await getStandardGeneration(
230+
getSystem("ph_analysis_outline", lng, tone),
231+
getPrompt("ph_analysis_outline", lng, textToAnalyse) + "\n" + prompt,
232+
s.key,
233+
model,
234+
{
235+
temp: temp,
236+
presP: presP,
237+
topP: topp,
238+
freqP: freqP,
239+
},
240+
);
241+
242+
if (outline instanceof OpenAI.APIError) {
243+
setErrorMsg(outline);
244+
setErrorVis(true);
245+
setInProgress(false);
246+
return;
247+
}
248+
249+
setIsGen(true);
250+
setInProgress(false);
251+
setRes("");
252+
253+
// 2. Generate the intro
254+
const intro =
255+
(await sendToGptCustom(
256+
getSystem("ph_analysis_outline", lng, tone),
257+
getPromptComplexAnalysis(
258+
textToAnalyse,
259+
outline,
260+
"ph_analysis_intro",
261+
lng,
262+
),
263+
s.key,
264+
model,
265+
{
266+
temp: temp,
267+
presP: presP,
268+
topP: topp,
269+
freqP: freqP,
270+
},
271+
"",
272+
{ setContent: setRes },
273+
)) ?? "";
274+
275+
if (intro instanceof OpenAI.APIError) {
276+
setErrorMsg(intro);
277+
setErrorVis(true);
278+
setInProgress(false);
279+
return;
280+
}
281+
282+
// 3. Generate dev part
283+
const p1 = await sendToGptCustom(
284+
getSystem("ph_analysis_outline", lng, tone),
285+
getPromptComplexAnalysis(textToAnalyse, outline, "ph_analysis_dev", lng),
286+
s.key,
287+
model,
288+
{
289+
temp: temp,
290+
presP: presP,
291+
topP: topp,
292+
freqP: freqP,
293+
},
294+
intro + "\n" || "",
295+
{ setContent: setRes },
296+
);
297+
298+
// 4. Generate conclusion
299+
const ccl = await sendToGptCustom(
300+
getSystem("ph_analysis_outline", lng, tone),
301+
getPromptComplexAnalysis(
302+
textToAnalyse,
303+
outline,
304+
"ph_analysis_conclusion",
305+
lng,
306+
),
307+
s.key,
308+
model,
309+
{
310+
temp: temp,
311+
presP: presP,
312+
topP: topp,
313+
freqP: freqP,
314+
},
315+
intro + "\n" + p1 + "\n" || "",
316+
{ setContent: setRes },
317+
);
318+
setRes(intro + p1 + ccl);
319+
addToHistory({
320+
prompt: textToAnalyse,
321+
content: intro + "\n" + p1 + "\n" + ccl ?? "",
322+
template: type,
323+
date: new Date(),
324+
});
325+
setIsGen(false);
326+
setInProgress(false);
327+
}
328+
220329
async function createComplexEssay() {
221330
setInProgress(true);
222331
setErrorVis(false);

app/i18n/locales/en/common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,7 @@
9393
"text-analysis-introduction": "Analysis introduction",
9494
"text-analysis-conclusion": "Analysis conclusion",
9595
"text-analysis-basic": "Text analysis (Basic)",
96+
"text-analysis-complex": "Text analysis (Complex)",
97+
"text-analysis-outline": "Analysis outline",
9698
"text-analysis-dev": "Analysis development"
9799
}

app/i18n/locales/fr/common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,7 @@
9393
"text-analysis-introduction": "Introduction d'analyse",
9494
"text-analysis-conclusion": "Conclusion d'analyse",
9595
"text-analysis-basic": "Analyse de texte (Basique)",
96+
"text-analysis-complex": "Analyse de texte (Complexe)",
97+
"text-analysis-outline": "Plan d'analyse",
9698
"text-analysis-dev": "Development de l'analyse"
9799
}

components/generation-item.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ export function GenerationItem(props: {
8080
return t("text-analysis-basic");
8181
case "ph_analysis_dev":
8282
return t("text-analysis-dev");
83+
case "ph_analysis_outline":
84+
return t("text-analysis-outline");
85+
case "ph_analysis_complex":
86+
return t("text-analysis-complex");
8387
case "table":
8488
return t("table");
8589
default:

lib/ai-completions.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ export function getSystem(
148148
? ""
149149
: " Use the following tone: " + tone;
150150
}
151+
if (template === "ph_analysis_outline") {
152+
return "You are an expert who writes philosophy text analysis similar to those required for a high school diploma in the United States." +
153+
tone ===
154+
"tones-none"
155+
? ""
156+
: " Use the following tone: " + tone;
157+
}
151158
if (template === "table")
152159
return "You are an expert who creates HTML Tables. You help organize data in HTML tables. You ONLY give the code for the HTML Table (body ONLY,no head, no scripts) on a single line." +
153160
tone ===
@@ -197,6 +204,13 @@ export function getSystem(
197204
? ""
198205
: " Utilise le ton suivant : " + tone;
199206
}
207+
if (template === "ph_analysis_outline") {
208+
return "Tu es un expert qui fait des explications de texte type bac de philosophie." +
209+
tone ===
210+
"tones-none"
211+
? ""
212+
: " Utilise le ton suivant : " + tone;
213+
}
200214
if (template === "table")
201215
return "Tu es un expert qui crée des tableaux HTML. Tu aides à organiser les données dans les tableaux HTML. Tu donnes UNIQUEMENT le code du tableau en HTML (body SEULEMENT, pas de head, pas de scripts) en une seule ligne." +
202216
tone ===
@@ -266,7 +280,9 @@ export function getPrompt(
266280
case "ph_analysis_basic":
267281
return `Write the text analysis with Introduction, Development and Conclusion. Use the provided structures. Introduction structure: introduction, presentation of the text's theme, problematic (on the one hand, on the other, therefore), presentation of the author's thesis, announcement of the text's plan, using the author's arguments for each part. Development structure: The explanation is linear, i.e. the assignment must follow the order of the text. Each part corresponds to a part of the extract, and within the part, the various particular explanations (of terms, of sentences in themselves) follow one another as in the text. - For each part, start by giving the main idea. - For each sentence, give its function (premise, explanation, example...) and content, expressed in your own words. An explanation may follow if the sentence is very complex. - Explain the philosophical terms in the sentence, giving definitions, and explain underlying references (you may wish to mention other authors). End with a concrete example illustrating the author's idea. Conclusion structure: recall the most the most important elements of the development, clearly explaining how the development showed how the author demonstrated his thesis. Text: [[${prompt}]]`;
268282
case "ph_analysis_dev":
269-
return `Write the text explanation using sentences, no list. The explanation is linear, i.e. the assignment must follow the order of the text. Each part corresponds to a part of the extract, and within the part, the various specific explanations (of terms, of sentences in themselves) follow one another as in the text. Start from the broadest to the most precise: - For each part, start by giving the main idea. - For each sentence, give its function (premise, explanation, example...) and content expressed in your own words. An explanation may follow if the sentence is very complex. - Explain the philosophical terms in the sentence by giving definitions, and make explicit any implied meaning or underlying references (you may wish to mention other authors). - End with a concrete example illustrating the author's idea. Texte : [[${prompt}]]`;
283+
return `Write the text explanation using sentences, no list. The explanation is linear, i.e. the assignment must follow the order of the text. Each part corresponds to a part of the extract, and within the part, the various specific explanations (of terms, of sentences in themselves) follow one another as in the text. Start from the broadest to the most precise: - For each part, start by giving the main idea. - For each sentence, give its function (premise, explanation, example...) and content expressed in your own words. An explanation may follow if the sentence is very complex. - Explain the philosophical terms in the sentence by giving definitions, and make explicit any implied meaning or underlying references (you may wish to mention other authors). - End with a concrete example illustrating the author's idea. Text: [[${prompt}]]`;
284+
case "ph_analysis_outline":
285+
return `Write the outline of the text explanation. The explanation is linear, i.e. the assignment must follow the order of the text. Each part corresponds to a part of the extract, and within the part, the various specific explanations (of terms, of sentences in themselves) follow one another as in the text. Start from the broadest to the most precise: - For each part, start by giving the main idea. - For each sentence, give its function (premise, explanation, example...) and content expressed in your own words. An explanation may follow if the sentence is very complex. - Explain the philosophical terms in the sentence by giving definitions, and make explicit any implied meaning or underlying references (you may wish to mention other authors). - End with a concrete example illustrating the author's idea. Text: [[${prompt}]]`;
270286

271287
case "table":
272288
return `Give ONLY the corresponding HTML Table about (no other text): ${prompt}`;
@@ -309,6 +325,8 @@ export function getPrompt(
309325
return `Rédige l'explication de texte avec Introduction, développement et conclusion. Utilise les structures proposées. Structure de l'introduction : introduction, présentation du thème du texte, problématique (d'une part, d'autre part, donc), présentation de la thèse de l'auteur, annonce du plan du texte, utilisation des arguments de l'auteur pour chaque partie. Structure du développement : L'explication est linéaire, c'est-à-dire que le devoir doit suivre l'ordre du texte. Chaque partie correspond à une partie de l'extrait, et à l'intérieur de la partie, les différentes explications particulières (de termes, de phrases en elles-mêmes) se succèdent comme dans le texte. - Pour chaque partie, commencez par donner l'idée principale. - Pour chaque phrase, donnez sa fonction (prémisse, explication, exemple...) et son contenu, exprimés avec vos propres mots. Une explication peut suivre si la phrase est très complexe. - Expliquez les termes philosophiques de la phrase, en donnant des définitions, et expliquez les références sous-jacentes (vous pouvez éventuellement mentionner d'autres auteurs). Terminez par un exemple concret illustrant l'idée de l'auteur. Structure de la conclusion : rappeler les éléments les plus importants du développement, en expliquant clairement comment le développement a montré comment l'auteur a démontré sa thèse. Texte : [[${prompt}]]`;
310326
case "ph_analysis_dev":
311327
return `Rédige le developpement l'explication de texte avec des phrases, pas de listes. L'explication est linéaire, c'est-à-dire que le devoir doit suivre l'ordre du texte. Chaque partie correspond à une partie de l'extrait, et à l'intérieur de la partie, les différentes explications particulières (des termes, des phrases en elles-mêmes) se succèdent comme dans le texte. Partez du plus large pour aller vers le plus précis : - Pour chaque partie, commencez par en donner l'idée principale. - Pour chaque phrase, donnez-en la fonction (postulat, explication, exemple...) et le contenu exprimé avec vos mots. Peut suivre une explication si la phrase est très complexe. - Expliquez les termes philosophiques de la phrase en donnant des définitions, et explicitez les sous-entendus, les références sous-jacentes (vous pouvez alors mentionner d'autres auteurs). - Terminez par un exemple concret illustrant l'idée de l'auteur. Texte : [[${prompt}]]`;
328+
case "ph_analysis_outline":
329+
return `Rédige le plan du developpement de l'explication de texte. L'explication est linéaire, c'est-à-dire que le devoir doit suivre l'ordre du texte. Chaque partie correspond à une partie de l'extrait, et à l'intérieur de la partie, les différentes explications particulières (des termes, des phrases en elles-mêmes) se succèdent comme dans le texte. Partez du plus large pour aller vers le plus précis : - Pour chaque partie, commencez par en donner l'idée principale. - Pour chaque phrase, donnez-en la fonction (postulat, explication, exemple...) et le contenu exprimé avec vos mots. Peut suivre une explication si la phrase est très complexe. - Expliquez les termes philosophiques de la phrase en donnant des définitions, et explicitez les sous-entendus, les références sous-jacentes (vous pouvez alors mentionner d'autres auteurs). - Terminez par un exemple concret illustrant l'idée de l'auteur. Texte : [[${prompt}]]`;
312330

313331
case "table":
314332
return `Donne SEULEMENT le tableau HTML correspondant au sujet suivant (pas d'autre texte) : ${prompt}`;
@@ -364,3 +382,31 @@ export interface OpenAiOptions {
364382
presP: number;
365383
temp: number;
366384
}
385+
386+
export function getPromptComplexAnalysis(
387+
text: string,
388+
outline: string,
389+
template: string,
390+
lng: "fr" | "en",
391+
): string {
392+
if (lng === "en") {
393+
switch (template) {
394+
case "ph_analysis_intro":
395+
return `Write ONLY the introduction of the text analysis using the following structure: introduction, presentation of the text's theme, problematic (on the one hand, on the other, therefore [question]), quick presentation of the author's thesis, announcement of the text's plan, using the provided outline. OUTLINE=[[${outline}]]\nTEXT=[[${text}]]`;
396+
case "ph_analysis_dev":
397+
return `Write the text explanation development (note that the intro and conclusion were previously written using the provided OUTLINE) using sentences, no list, don't show the different parts letters and numbers. The explanation is linear, i.e. the assignment must follow the order of the text. Each part corresponds to a part of the extract, and within the part, the various specific explanations (of terms, of sentences in themselves) follow one another as in the text. Start from the broadest to the most precise: - For each part, start by giving the main idea. - For each sentence, give its function (premise, explanation, example...) and content expressed in your own words. An explanation may follow if the sentence is very complex. - Explain the philosophical terms in the sentence by giving definitions, and make explicit any implied meaning or underlying references (you may wish to mention other authors). - End with a concrete example illustrating the author's idea. TEXT=[[${text}]]\nOUTLINE=[[${outline}]]`;
398+
case "ph_analysis_conclusion":
399+
return `Write ONLY the conclusion of the text analysis (which was based on the provided OUTLINE), recall the most the most important elements of the development, clearly explaining how the development showed how the author demonstrated his thesis. OUTLINE=[[${outline}]]\nTEXT=[[${text}]]`;
400+
}
401+
} else {
402+
switch (template) {
403+
case "ph_analysis_intro":
404+
return `Rédiger UNIQUEMENT l'introduction de l'analyse de texte selon la structure suivante (pas de développement) : amorce, présentation du thème du texte, problématique (paragraphe avec : d'une part, d'autre part, donc [question]), présentation très rapide en une phrase de la thèse de l'auteur, annonce du plan du texte, en utilisant le plan fourni. PLAN=[[${outline}]]\nTEXTE=[[${text}]]`;
405+
case "ph_analysis_dev":
406+
return `Rédiger UNIQUEMENT le développement de l'explication de texte (notez que l'introduction et la conclusion ont été rédigées au préalable à l'aide du schéma fourni) en utilisant des phrases, pas de liste, ne montrez pas les différentes parties sous forme de lettres et de chiffres. L'explication est linéaire, c'est-à-dire que le travail doit suivre l'ordre du texte. Chaque partie correspond à une partie de l'extrait, et à l'intérieur de la partie, les différentes explications spécifiques (des termes, des phrases en elles-mêmes) se succèdent comme dans le texte. Partez du plus large au plus précis : - Pour chaque partie, commencez par donner l'idée principale. - Pour chaque phrase, donnez sa fonction (prémisse, explication, exemple...) et son contenu exprimé avec vos propres mots. Une explication peut suivre si la phrase est très complexe. - Expliquez les termes philosophiques de la phrase en donnant des définitions, et explicitez les sous-entendus ou les références sous-jacentes (vous pouvez citer d'autres auteurs). - Terminez par un exemple concret illustrant l'idée de l'auteur. TEXTE=[[${text}]]\nPLAN=[[${outline}]]`;
407+
case "ph_analysis_conclusion":
408+
return `Rédiger UNIQUEMENT la conclusion de l'analyse du texte (qui était basée sur le PLAN fourni), en rappelant les éléments les plus importants du développement, en expliquant clairement comment le développement a montré comment l'auteur a démontré sa thèse. PLAN=[[${outline}]]\nTEXTE=[[${text}]]`;
409+
}
410+
}
411+
return "";
412+
}

lib/formats.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ const formats = [
3333
{
3434
category: "text-philosophy",
3535
options: [
36+
{ text: "text-analysis-outline", val: "ph_analysis_outline" },
3637
{ text: "text-analysis-introduction", val: "ph_analysis_intro" },
3738
{ text: "text-analysis-dev", val: "ph_analysis_dev" },
3839
{ text: "text-analysis-conclusion", val: "ph_analysis_conclusion" },
3940
{ text: "text-analysis-basic", val: "ph_analysis_basic" },
41+
{ text: "text-analysis-complex", val: "ph_analysis_complex" },
4042
],
4143
},
4244
];

lib/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const version = "1.9.0";
1+
export const version = "1.9.1";

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "write",
3-
"version": "1.9.0",
3+
"version": "1.9.1",
44
"private": true,
55
"scripts": {
66
"dev": "next dev",

0 commit comments

Comments
 (0)