diff --git a/src/handlers/comment/handlers/ask.ts b/src/handlers/comment/handlers/ask.ts index 71557eb78..a1206cbc4 100644 --- a/src/handlers/comment/handlers/ask.ts +++ b/src/handlers/comment/handlers/ask.ts @@ -143,97 +143,6 @@ export const ask = async (body: string) => { const gptAnswer = typeof gptDecidedContext === "string" ? gptDecidedContext : gptDecidedContext.answer || ""; const contextTokens = encodee(cleanText(gptAnswer)); - // console.log("gptDecidedContext", gptDecidedContext); - // console.log("contextTokens", contextTokens); - - // const commentBeforeQuestion = streamlined[streamlined.length - 2]; - // const secondLast = streamlined[streamlined.length - 3]; - - // const latestComments = [commentBeforeQuestion, secondLast]; - - // const fmLatestComments = formatChat(latestComments); - - // const fmStreamlined = formatChat(streamlined); - - // const formats = [ - // { - // quarter: "1st", - // content: `IssueSpec: + ${issue.body} \n LastTwoComments: ${fmLatestComments} \n Question: ${body}`, - // current: contextTokens, - // }, - // { - // quarter: "2nd", - // content: `IssueSpec: + ${issue.body} \n LinkedIssueContext: ${formatChat( - // linkedIssueStreamlined - // )}\n LastTwoComments: ${fmLatestComments} \n Question: ${body}`, - // current: contextTokens, - // }, - // { - // quarter: "3rd", - // content: `IssueSpec: + ${issue.body} \n LinkedIssueContext: ${formatChat(linkedIssueStreamlined)}\n LinkedPRContext: ${formatChat( - // linkedPRStreamlined - // )} LastTwoComments: ${latestComments} \n Question: ${body}`, - // current: contextTokens, - // }, - // { - // quarter: "4th", - // content: `IssueSpec: + ${issue.body} \n LinkedIssueContext: ${formatChat(linkedIssueStreamlined)}\n LinkedPRContext: ${formatChat( - // linkedPRStreamlined - // )} CurrentIssueComments: ${fmStreamlined} \n Question: ${body}`, - // current: contextTokens, - // }, - // ]; - - // const remainingTokens = (s: string) => { - // const max = 4096; - // const tokens = encodee(s).length; - // let nextActiveFourth = ""; - - // if (tokens < max / 4) { - // nextActiveFourth = "1st"; - // } else if (tokens < max / 2) { - // nextActiveFourth = "2nd"; - // } else if (tokens < (max / 4) * 3) { - // nextActiveFourth = "3rd"; - // } else if (tokens < max) { - // nextActiveFourth = "4th"; - // } else { - // nextActiveFourth = "Max"; - // } - - // const remaining = { - // content: s, - // current: tokens + formats[0].current, - // quarter: nextActiveFourth, - // }; - - // return remaining; - // }; - - // let selectedFormat = ""; - // let closestTokenCount = 0; - - // for (const format of formats) { - // const tokenCount = remainingTokens(cleanText(format.content)).current; - // if (tokenCount > closestTokenCount && tokenCount < 4096) { - // closestTokenCount = tokenCount; - // selectedFormat = format.content; - // } - // } - - // if (selectedFormat === "") { - // return "Format selection failed."; - // } - - // console.log("========================"); - // console.log("=== selectedFormat ===", selectedFormat); - - // const { quarter, current } = remainingTokens(cleanText(selectedFormat)); - - // if (current >= 4096) { - // return "Format selection failed."; - // } - chatHistory = []; const tokenSize = contextTokens.length + encodee(body).length;