MCPcopy Create free account
hub / github.com/ephraimduncan/opencode-cursor / handleNonStreamingResponse

Function handleNonStreamingResponse

src/proxy.ts:1417–1444  ·  view source on GitHub ↗
(
  payload: CursorRequestPayload,
  accessToken: string,
  modelId: string,
  convKey: string,
)

Source from the content-addressed store, hash-verified

1415}
1416
1417async function handleNonStreamingResponse(
1418 payload: CursorRequestPayload,
1419 accessToken: string,
1420 modelId: string,
1421 convKey: string,
1422): Promise<Response> {
1423 const completionId = `chatcmpl-${crypto.randomUUID().replace(/-/g, "").slice(0, 28)}`;
1424 const created = Math.floor(Date.now() / 1000);
1425 const { text, usage } = await collectFullResponse(payload, accessToken, convKey);
1426
1427 return new Response(
1428 JSON.stringify({
1429 id: completionId,
1430 object: "chat.completion",
1431 created,
1432 model: modelId,
1433 choices: [
1434 {
1435 index: 0,
1436 message: { role: "assistant", content: text },
1437 finish_reason: "stop",
1438 },
1439 ],
1440 usage,
1441 }),
1442 { headers: { "Content-Type": "application/json" } },
1443 );
1444}
1445
1446interface CollectedResponse {
1447 text: string;

Callers 1

handleChatCompletionFunction · 0.85

Calls 1

collectFullResponseFunction · 0.85

Tested by

no test coverage detected