Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-163-generic #173-Ubuntu SMP Tue Oct 14 17:51:00 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /home/picotech/domains/note.picotech.app/public_html/src/services/ drwxr-xr-x | |
| Viewing file: Select action/file-type: const config = require('../config/config');
const { AppError } = require('../middleware/errorHandler');
exports.generateAISummary = async ({ meeting, notes, transcripts }) => {
try {
const prompt = buildSummaryPrompt(meeting, notes, transcripts);
const response = await fetch(`${config.services.openrouter.baseUrl}/chat/completions`, {
method: "POST",
headers: {
"Authorization": `Bearer ${config.services.openrouter.apiKey}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "openai/gpt-5-nano",
messages: [{
role: "system",
content: "You are a meeting summarizer. Create concise, structured summaries in JSON format."
}, {
role: "user",
content: prompt
}],
temperature: 0.7
})
});
if (!response.ok) {
throw new Error(`OpenRouter API error: ${response.status} ${response.statusText}`);
}
const data = await response.json();
return parseSummaryResponse(data.choices[0].message.content);
} catch (error) {
throw new AppError('Summary generation failed: ' + error.message, 500);
}
};
function buildSummaryPrompt(meeting, notes, transcripts) {
// Construct prompt from meeting data
return `Meeting Title: ${meeting.title}\n\nTranscript:\n${
transcripts.map(t => t.content).join('\n')
}\n\nNotes:\n${
notes.map(n => JSON.stringify(n.content_blocks)).join('\n')
}\n\nPlease provide a structured summary in JSON format with the following keys:\n- overview (string)\n- decisions (array of strings)\n- action_items (array of strings)\n- risks (array of strings)\n- questions (array of strings)`;
}
function parseSummaryResponse(content) {
try {
// Try to parse as JSON first
const parsed = JSON.parse(content);
return {
overview: parsed.overview || '',
decisions: Array.isArray(parsed.decisions) ? parsed.decisions : [],
action_items: Array.isArray(parsed.action_items) ? parsed.action_items : [],
risks: Array.isArray(parsed.risks) ? parsed.risks : [],
questions: Array.isArray(parsed.questions) ? parsed.questions : []
};
} catch (error) {
// If JSON parsing fails, return default structure
console.warn('Failed to parse AI response as JSON:', error);
return {
overview: content.substring(0, 500), // Fallback to first 500 chars
decisions: [],
action_items: [],
risks: [],
questions: []
};
}
} |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0035 ]-- |