MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / getResponseStream

Function getResponseStream

out/cli.cjs:79138–79183  ·  view source on GitHub ↗
(inputStream)

Source from the content-addressed store, hash-verified

79136 const { value, done } = yield __await2(reader.read());
79137 if (done) {
79138 break;
79139 }
79140 yield yield __await2(addHelpers(value));
79141 }
79142 });
79143}
79144function getResponseStream(inputStream) {
79145 const reader = inputStream.getReader();
79146 const stream4 = new ReadableStream({
79147 start(controller) {
79148 let currentText = "";
79149 return pump();
79150 function pump() {
79151 return reader.read().then(({ value, done }) => {
79152 if (done) {
79153 if (currentText.trim()) {
79154 controller.error(new GoogleGenerativeAIError("Failed to parse stream"));
79155 return;
79156 }
79157 controller.close();
79158 return;
79159 }
79160 currentText += value;
79161 let match = currentText.match(responseLineRE);
79162 let parsedResponse;
79163 while (match) {
79164 try {
79165 parsedResponse = JSON.parse(match[1]);
79166 } catch (e3) {
79167 controller.error(new GoogleGenerativeAIError(`Error parsing JSON response: "${match[1]}"`));
79168 return;
79169 }
79170 controller.enqueue(parsedResponse);
79171 currentText = currentText.substring(match[0].length);
79172 match = currentText.match(responseLineRE);
79173 }
79174 return pump();
79175 }).catch((e3) => {
79176 let err = e3;
79177 err.stack = e3.stack;
79178 if (err.name === "AbortError") {
79179 err = new GoogleGenerativeAIAbortError("Request aborted when reading from the stream");
79180 } else {
79181 err = new GoogleGenerativeAIError("Error reading from the stream");
79182 }
79183 throw err;
79184 });
79185 }
79186 }

Callers 1

processStreamFunction · 0.85

Calls 1

getReaderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…