!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

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
2025 x86_64
 

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
Free 25.88 GB of 117.98 GB (21.93%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     streamingSummaryService.js (4.51 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
const config = require('../config/config');
const { AppError } = require('../middleware/errorHandler');
const { Summary, Meeting, Note, Transcript } = require('../models');
const OpenAI = require('openai');

exports.generateStreamingSummary = async (meetingId, onUpdate) => {
  try {
    // Check if summary already exists
    const existingSummary = await Summary.findOne({
      where: { meeting_id: meetingId }
    });

    if (existingSummary) {
      throw new AppError('Summary already exists for this meeting', 400);
    }

    // Get meeting data
    const meeting = await Meeting.findByPk(meetingId);
    if (!meeting) {
      throw new AppError('Meeting not found', 404);
    }

    // Get meeting notes and transcripts
    const notes = await Note.findAll({ where: { meeting_id: meetingId } });
    const transcripts = await Transcript.findAll({
      where: { meeting_id: meetingId }
    });

    // Send initial status update
    onUpdate({
      status: 'starting',
      message: 'Initializing summary generation...'
    });

    // Build prompt
    const prompt = buildSummaryPrompt(meeting, notes, transcripts);

    // Send processing status
    onUpdate({
      status: 'processing',
      message: 'Generating summary with AI...'
    });

    // Initialize OpenAI client
    const openai = new OpenAI({
      apiKey: config.services.openrouter.apiKey,
      baseURL: config.services.openrouter.baseUrl
    });

    // Use OpenAI API without streaming
    const completion = await openai.chat.completions.create({
      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
    });

    const content = completion.choices[0].message.content;

    let summaryData;

    // Parse JSON response
    try {
      summaryData = JSON.parse(content);
    } catch (error) {
      // Fallback parsing
      summaryData = parseSummaryResponse(content);
    }

    // Transform action_items to match model validation
    if (summaryData.action_items && Array.isArray(summaryData.action_items)) {
      summaryData.action_items = summaryData.action_items.map(item => {
        if (typeof item === 'string') {
          return { title: item };
        }
        return item;
      });
    }

    // Set status to completed
    summaryData.status = 'completed';
    summaryData.meeting_id = meetingId;
    summaryData.confidence_score = 0.85;
    summaryData.ai_model = 'openai/gpt-5-nano';

    // Create summary in database
    const summary = await Summary.create(summaryData);

    // Update meeting status to completed
    await meeting.update({ status: 'completed' });

    // Send completion update
    onUpdate({
      status: 'completed',
      data: summary,
      message: 'Summary generation completed successfully'
    });

  } catch (error) {
    console.error('Streaming summary generation failed:', error);
    onUpdate({
      status: 'error',
      error: error.message,
      message: 'Summary generation failed'
    });
    throw new AppError('Summary generation failed: ' + error.message, 500);
  }
};

function buildSummaryPrompt(meeting, notes, transcripts) {
  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)\n\nGenerate this JSON progressively, sending partial results as you complete each section. Do not change the transcript language. output same language as transcript language.`;
}

function parseSummaryResponse(content) {
  try {
    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) {
    // Fallback parsing for malformed JSON
    console.warn('Failed to parse AI response as JSON:', error);
    return {
      overview: content.substring(0, 500),
      decisions: [],
      action_items: [],
      risks: [],
      questions: []
    };
  }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0048 ]--