MCPcopy Create free account
hub / github.com/bigcode-project/jupytercoder / getCellContentTextRequiredForBigCode

Function getCellContentTextRequiredForBigCode

src/utility.js:266–304  ·  view source on GitHub ↗
(currctJupyterModel)

Source from the content-addressed store, hash-verified

264
265
266function getCellContentTextRequiredForBigCode(currctJupyterModel) {
267 const context = getActiveContext(currctJupyterModel)
268
269 if(context.length == 0){
270 return [null, null]
271 }
272
273
274 let prompt = "<start_jupyter>"
275 let cellCodeText = ""
276 let isLastLine = true
277
278 for (let index = 0; index < context.length; index++) {
279 const lineInformation = context[index]
280
281 if (lineInformation.isCursor) {
282 prompt += bigcodeFormattPrefixMap[lineInformation.type] + cellCodeText + lineInformation.content
283 isLastLine = judgeIsTheLastLine(context, index)
284 break
285 }
286
287 if (index == context.length - 1) {
288 prompt += bigcodeFormattPrefixMap[lineInformation.type] + cellCodeText + lineInformation.content
289 break
290 }
291
292 const nextLineInformation = context[index + 1]
293
294 if (lineInformation.cellIndex != nextLineInformation.cellIndex || lineInformation.type != nextLineInformation.type) {
295 prompt += bigcodeFormattPrefixMap[lineInformation.type] + cellCodeText + lineInformation.content
296 cellCodeText = ""
297 } else {
298 cellCodeText += lineInformation.content + "\n"
299 }
300
301 }
302
303 return [prompt, isLastLine]
304}
305
306
307

Callers 1

getCellContentTextFunction · 0.85

Calls 2

getActiveContextFunction · 0.85
judgeIsTheLastLineFunction · 0.85

Tested by

no test coverage detected