MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / processEvent

Function processEvent

sdk/src/impl/chatgpt-backend-fetch.ts:230–410  ·  view source on GitHub ↗
(
    controller: TransformStreamDefaultController<Uint8Array>,
    data: Record<string, unknown>,
  )

Source from the content-addressed store, hash-verified

228 }
229
230 function processEvent(
231 controller: TransformStreamDefaultController<Uint8Array>,
232 data: Record<string, unknown>,
233 ) {
234 const type = data.type as string | undefined
235 if (!type) return
236
237 switch (type) {
238 case 'response.created': {
239 const resp = data.response as Record<string, unknown> | undefined
240 responseId = (resp?.id as string) ?? null
241 responseModel = (resp?.model as string) ?? null
242 if (!emittedRole) {
243 emit(controller, {
244 id: responseId,
245 model: responseModel,
246 choices: [
247 { index: 0, delta: { role: 'assistant' }, finish_reason: null },
248 ],
249 })
250 emittedRole = true
251 }
252 break
253 }
254
255 case 'response.output_text.delta': {
256 emit(controller, {
257 id: responseId,
258 choices: [
259 {
260 index: 0,
261 delta: { content: data.delta as string },
262 finish_reason: null,
263 },
264 ],
265 })
266 break
267 }
268
269 case 'response.reasoning_summary_text.delta': {
270 emit(controller, {
271 id: responseId,
272 choices: [
273 {
274 index: 0,
275 delta: { reasoning_content: data.delta as string },
276 finish_reason: null,
277 },
278 ],
279 })
280 break
281 }
282
283 case 'response.output_item.added': {
284 const item = data.item as Record<string, unknown> | undefined
285 if (item?.type === 'function_call') {
286 const tcIndex = nextToolCallIndex++
287 const outputIdx = (data.output_index as number) ?? 0

Callers 3

transformFunction · 0.85
flushFunction · 0.85
processLineMethod · 0.85

Calls 4

emitFunction · 0.85
setMethod · 0.80
enqueueMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected