Upgrade from GPT-3.5-turbo to GPT-4o-mini for better performance and cost efficiency

- Updated all 13 OpenAI API calls to use gpt-4o-mini model
- Updated source labels to reflect new model usage
- Benefits: Better performance, more recent training data, improved instruction following
- Cost: Significantly lower (/usr/bin/bash.15//usr/bin/bash.60 vs /usr/bin/bash.50/.50 per 1M tokens)
- Enhanced multilingual support for German/English conversations
- Improved Socratic teaching capabilities for children
This commit is contained in:
root
2025-06-30 15:52:52 +02:00
parent fd63a4617a
commit a2aeff7ecd

View File

@@ -125,7 +125,7 @@ app.post('/api/reveal-answer', async (req, res) => {
// Function to get OpenAI-powered educational guidance (Primary)
async function getOpenAIGuidance(question, language) {
console.log('🤖 Calling OpenAI with GPT-3.5-turbo...');
console.log('🤖 Calling OpenAI with GPT-4o-mini...');
const isGerman = language === 'de';
@@ -139,7 +139,7 @@ async function getOpenAIGuidance(question, language) {
try {
const completion = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
messages: [
{ role: "system", content: systemPrompt },
{ role: "user", content: userPrompt }
@@ -158,7 +158,7 @@ async function getOpenAIGuidance(question, language) {
type: 'ai-powered',
steps: steps,
encouragement: getRandomEncouragement(language, question),
source: 'OpenAI GPT-3.5'
source: 'OpenAI GPT-4o-mini'
};
} catch (error) {
@@ -472,7 +472,7 @@ async function getActualAnswer(question, language) {
try {
if (process.env.OPENAI_API_KEY) {
const completion = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
messages: [
{ role: "system", content: systemPrompt },
{ role: "user", content: userPrompt }
@@ -487,7 +487,7 @@ async function getActualAnswer(question, language) {
return {
type: 'ai-powered',
text: answer.trim(),
source: 'OpenAI GPT-3.5'
source: 'OpenAI GPT-4o-mini'
};
}
} catch (error) {
@@ -570,7 +570,7 @@ The child is expressing confusion and needs help understanding. Provide a clear,
if (process.env.OPENAI_API_KEY) {
try {
const completion = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
messages: [
{
role: "system",
@@ -588,7 +588,7 @@ The child is expressing confusion and needs help understanding. Provide a clear,
return res.json({
success: true,
response: aiResponse,
source: 'OpenAI GPT-3.5 (Confusion Explanation)'
source: 'OpenAI GPT-4o-mini (Confusion Explanation)'
});
}
} catch (openaiError) {
@@ -646,7 +646,7 @@ The child is asking for a definition, explanation, or clarification about locati
if (process.env.OPENAI_API_KEY) {
try {
const completion = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
messages: [
{
role: "system",
@@ -664,7 +664,7 @@ The child is asking for a definition, explanation, or clarification about locati
return res.json({
success: true,
response: aiResponse,
source: 'OpenAI GPT-3.5 (Definition Response)'
source: 'OpenAI GPT-4o-mini (Definition Response)'
});
}
} catch (openaiError) {
@@ -726,7 +726,7 @@ IMPORTANT:
if (process.env.OPENAI_API_KEY) {
try {
const completion = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
messages: [
{
role: "system",
@@ -744,7 +744,7 @@ IMPORTANT:
return res.json({
success: true,
response: aiResponse,
source: 'OpenAI GPT-3.5'
source: 'OpenAI GPT-4o-mini'
});
}
} catch (openaiError) {
@@ -828,7 +828,7 @@ CHILD'S ANSWER: "${userAnswer}"
Ask one thoughtful follow-up question that invites the child to explore the topic deeper. The question should spark curiosity and encourage hands-on observation. Give NO answers - just one fascinating question.`;
const completion = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
messages: [
{ role: "system", content: systemPrompt },
{ role: "user", content: userPrompt }
@@ -844,7 +844,7 @@ Ask one thoughtful follow-up question that invites the child to explore the topi
return res.json({
success: true,
response: aiResponse,
source: 'OpenAI GPT-3.5 Deeper Exploration'
source: 'OpenAI GPT-4o-mini Deeper Exploration'
});
}
} catch (openaiError) {