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

Function cleanUpOpenaiOutput

src/api.js:25–42  ·  view source on GitHub ↗
(suggestion, isLastLine)

Source from the content-addressed store, hash-verified

23
24
25const cleanUpOpenaiOutput = (suggestion, isLastLine) => {
26 if (!isLastLine){
27 return suggestion.split("\n").length == 1 ? suggestion : suggestion.split("\n")[0]
28 }
29
30 suggestion = suggestion.replace(/\u200B/g, '')
31 let outPutIndex = suggestion.indexOf("\n\n§ Output")
32
33
34 if (outPutIndex == -1) {
35 let outPutIndex = suggestion.indexOf("\n\n# Output")
36
37 return outPutIndex == -1 ? suggestion : suggestion.substring(0, outPutIndex)
38 } else {
39 return suggestion.substring(0, outPutIndex)
40 }
41
42}
43
44// Function to send request to OpenAI API
45api.sendToOpenAI = async (prompt, apiKey, modelType, isLastLine) => {

Callers 1

api.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected