diff --git a/backend/src/entities/ai/use-cases/request-info-from-table-with-ai-v3.use.case.ts b/backend/src/entities/ai/use-cases/request-info-from-table-with-ai-v3.use.case.ts index 53e940973..68beab205 100644 --- a/backend/src/entities/ai/use-cases/request-info-from-table-with-ai-v3.use.case.ts +++ b/backend/src/entities/ai/use-cases/request-info-from-table-with-ai-v3.use.case.ts @@ -50,7 +50,7 @@ export class RequestInfoFromTableWithAIUseCaseV3 let heartbeatInterval: NodeJS.Timeout | null = null; try { - response.write(`Analyzing your request about the "${tableName}" table...`); + // response.write(`Analyzing your request about the "${tableName}" table...`); // heartbeatInterval = this.setupHeartbeat(response); const system_prompt = this.createSystemPrompt(tableName, databaseType, foundConnection); @@ -252,7 +252,7 @@ Remember that all responses should be clear and user-friendly, explaining techni if (completedToolCall) { try { const toolName = completedToolCall.function.name; - response.write(`${this.getUserMessageForTool(toolName)}`); + // response.write(`${this.getUserMessageForTool(toolName)}`); if (toolName === 'getTableStructure') { await this.handleTableStructureTool( @@ -297,7 +297,7 @@ Remember that all responses should be clear and user-friendly, explaining techni ) { const tableStructureInfo = await this.getTableStructureInfo(dao, tableName, userEmail, foundConnection); - response.write(`Fetching table structure information for ${tableName}...`); + // response.write(`Fetching table structure information for ${tableName}...`); const updatedSystemPrompt = this.createTableStructurePrompt(tableName, foundConnection, isMongoDb); @@ -383,7 +383,7 @@ Remember: You MUST use the executeRawSql tool to run your query and show me the let innerAiResponseBuffer = ''; const innerResponseIdRef = { id: null }; - response.write(`Analyzing your data structure and preparing an appropriate query...`); + // response.write(`Analyzing your data structure and preparing an appropriate query...`); for await (const innerChunk of continuedStream) { const typedInnerChunk = innerChunk as any; @@ -404,8 +404,8 @@ Remember: You MUST use the executeRawSql tool to run your query and show me the if (typedInnerChunk.type === 'response.output_item.done' && typedInnerChunk.item?.type === 'function_call') { const completedInnerToolCall = innerToolCalls.find((tc) => tc.id === typedInnerChunk.item.id); if (completedInnerToolCall) { - const toolName = completedInnerToolCall.function.name; - response.write(`${this.getUserMessageForTool(toolName, true)}`); + // const toolName = completedInnerToolCall.function.name; + // response.write(`${this.getUserMessageForTool(toolName, true)}`); await this.processQueryToolCall( completedInnerToolCall, @@ -662,7 +662,7 @@ Remember: You MUST use the executeRawSql tool to run your query and show me the const sanitizedArgs = this.sanitizeJsonString(toolCall.function.arguments); const toolArgs = JSON.parse(sanitizedArgs); - response.write(`${this.getUserMessageForTool(toolName)}`); + // response.write(`${this.getUserMessageForTool(toolName)}`); if (toolName === 'executeRawSql') { const query = toolArgs.query; @@ -683,7 +683,7 @@ Remember: You MUST use the executeRawSql tool to run your query and show me the try { const queryResult = await dao.executeRawQuery(finalQuery, tableName, userEmail); - response.write(`Query executed successfully.`); + // response.write(`Query executed successfully.`); if ( await this.streamHumanReadableAnswer( query, @@ -695,9 +695,9 @@ Remember: You MUST use the executeRawSql tool to run your query and show me the response, ) ) { - console.info('Successfully streamed human-readable answer'); + // console.info('Successfully streamed human-readable answer'); } else { - console.info('Streaming failed, using non-streaming fallback'); + // console.info('Streaming failed, using non-streaming fallback'); const formattedResults = this.formatQueryResults(queryResult); const interpretation = await this.generateHumanReadableAnswer( query, @@ -732,9 +732,9 @@ Remember: You MUST use the executeRawSql tool to run your query and show me the } try { - console.info('Executing MongoDB pipeline:', pipeline); + // console.info('Executing MongoDB pipeline:', pipeline); const pipelineResult = await dao.executeRawQuery(pipeline, tableName, userEmail); - response.write(`Pipeline executed successfully.`); + // response.write(`Pipeline executed successfully.`); if ( await this.streamHumanReadableAnswer( pipeline, @@ -746,9 +746,9 @@ Remember: You MUST use the executeRawSql tool to run your query and show me the response, ) ) { - console.info('Successfully streamed MongoDB pipeline interpretation'); + // console.info('Successfully streamed MongoDB pipeline interpretation'); } else { - console.info('Streaming failed for MongoDB, using non-streaming fallback'); + // console.info('Streaming failed for MongoDB, using non-streaming fallback'); const formattedResults = this.formatQueryResults(pipelineResult); const interpretation = await this.generateHumanReadableAnswer( pipeline, @@ -770,7 +770,7 @@ Remember: You MUST use the executeRawSql tool to run your query and show me the response.write(`Sorry, I couldn't complete the data analysis you requested: ${error.message}`); } } else if (toolName === 'getTableStructure') { - response.write(`Table structure information has been fetched.`); + // response.write(`Table structure information has been fetched.`); } else { console.info(`Unknown tool call: ${toolName}`); response.write(`Received unknown tool call: ${toolName}`); @@ -820,7 +820,7 @@ Remember: You MUST use the executeRawSql tool to run your query and show me the if (!query || query.length < 10) return false; - response.write(`I notice a potential database query in your question. Let me run that for you...`); + // response.write(`I notice a potential database query in your question. Let me run that for you...`); if (!this.isValidSQLQuery(query)) { response.write( @@ -834,7 +834,7 @@ Remember: You MUST use the executeRawSql tool to run your query and show me the try { const queryResult = await dao.executeRawQuery(finalQuery, tableName, userEmail); - response.write(`Successfully retrieved the data you requested.`); + // response.write(`Successfully retrieved the data you requested.`); const openApiKey = getRequiredEnvVariable('OPENAI_API_KEY'); const openai = new OpenAI({ apiKey: openApiKey }); @@ -879,7 +879,7 @@ Remember: You MUST use the executeRawSql tool to run your query and show me the userId: string, ): Promise { try { - console.log('Generating human-readable answer for query results using responses API'); + // console.log('Generating human-readable answer for query results using responses API'); const simplifiedResults = this.simplifyQueryResults(queryResult); @@ -1027,7 +1027,7 @@ Please provide a clear, concise, and conversational answer that directly address ): Promise { try { console.log('Streaming human-readable answer for query results using responses API'); - this.writeToResponse(response, 'Creating an explanation of what your data shows...'); + // this.writeToResponse(response, 'Creating an explanation of what your data shows...'); const simplifiedResults = this.simplifyQueryResults(queryResult); const instructions = this.getExplanationInstructions();