Skip to content

Commit ae60159

Browse files
committed
review from @coyotte508
1 parent e8e5fa6 commit ae60159

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

packages/tiny-agents/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { PROVIDERS_OR_POLICIES } from "@huggingface/inference";
77
import { Agent } from "@huggingface/mcp-client";
88
import { version as packageVersion } from "../package.json";
99
import { ServerConfigSchema } from "./lib/types";
10-
import { ANSI, debug, error } from "./lib/utils";
10+
import { debug, error } from "./lib/utils";
1111
import { mainCliLoop } from "./lib/mainCliLoop";
1212
import { startServer } from "./lib/webServer";
1313
import { stdout } from "node:process";

packages/tiny-agents/src/lib/webServer.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@ import { stdout } from "node:process";
88
import type { ChatCompletionStreamOutput } from "@huggingface/tasks";
99

1010
const REQUEST_ID_HEADER = "X-Request-Id";
11-
// Generate a simple UUID v4 without dependencies
12-
const generateUUID = () => {
13-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
14-
const r = (Math.random() * 16) | 0;
15-
const v = c === "x" ? r : (r & 0x3) | 0x8;
16-
return v.toString(16);
17-
});
18-
};
11+
1912
const ChatCompletionInputSchema = z.object({
2013
messages: z.array(
2114
z.object({
@@ -48,7 +41,7 @@ class ServerResp extends ServerResponse {
4841

4942
export function startServer(agent: Agent): void {
5043
const server = createServer({ ServerResponse: ServerResp }, async (req, res) => {
51-
res.setHeader(REQUEST_ID_HEADER, generateUUID());
44+
res.setHeader(REQUEST_ID_HEADER, crypto.randomUUID());
5245
res.setHeader("Content-Type", "application/json");
5346
if (req.method === "POST" && req.url === "/v1/chat/completions") {
5447
let body: unknown;

0 commit comments

Comments
 (0)