MCPcopy Index your code
hub / github.com/BlockRunAI/ClawRouter / chatCompletion

Function chatCompletion

test/test-e2e.ts:111–130  ·  view source on GitHub ↗
(model: string, content: string)

Source from the content-addressed store, hash-verified

109}
110
111function chatCompletion(model: string, content: string): Record<string, unknown> {
112 return {
113 id: `chatcmpl-e2e-${Date.now()}`,
114 object: "chat.completion",
115 created: Math.floor(Date.now() / 1000),
116 model,
117 choices: [
118 {
119 index: 0,
120 message: { role: "assistant", content },
121 finish_reason: "stop",
122 },
123 ],
124 usage: {
125 prompt_tokens: 12,
126 completion_tokens: Math.max(1, Math.ceil(content.length / 4)),
127 total_tokens: Math.max(13, Math.ceil(content.length / 4) + 12),
128 },
129 };
130}
131
132function writeSseCompletion(res: ServerResponse, model: string, content: string): void {
133 const id = `chatcmpl-e2e-stream-${Date.now()}`;

Callers 1

startMockUpstreamFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected