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

Function getCellContentTextRequiredForOpenAI

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

Source from the content-addressed store, hash-verified

229
230
231const getCellContentTextRequiredForOpenAI = (currctJupyterModel) => {
232 const context = getActiveContext(currctJupyterModel)
233
234 if(context.length == 0){
235 return [null, null]
236 }
237
238
239 let prompt = ""
240 let isLastLine = true
241
242 for (let index = 0; index < context.length; index++) {
243 const lineInformation = context[index]
244
245 if (lineInformation.isCursor) {
246 prompt += lineInformation.content
247 isLastLine = isLastLine = judgeIsTheLastLine(context, index)
248 break
249 }
250
251 if (index == context.length - 1) {
252 prompt += lineInformation.content
253 break
254 }
255
256 if (lineInformation.type == "code") {
257 prompt += lineInformation.content + "\n"
258 }
259 }
260
261 return [prompt, isLastLine]
262}
263
264
265

Callers 1

getCellContentTextFunction · 0.85

Calls 2

getActiveContextFunction · 0.85
judgeIsTheLastLineFunction · 0.85

Tested by

no test coverage detected