File tree Expand file tree Collapse file tree 2 files changed +3
-10
lines changed
Expand file tree Collapse file tree 2 files changed +3
-10
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { PROVIDERS_OR_POLICIES } from "@huggingface/inference";
77import { Agent } from "@huggingface/mcp-client" ;
88import { version as packageVersion } from "../package.json" ;
99import { ServerConfigSchema } from "./lib/types" ;
10- import { ANSI , debug , error } from "./lib/utils" ;
10+ import { debug , error } from "./lib/utils" ;
1111import { mainCliLoop } from "./lib/mainCliLoop" ;
1212import { startServer } from "./lib/webServer" ;
1313import { stdout } from "node:process" ;
Original file line number Diff line number Diff line change @@ -8,14 +8,7 @@ import { stdout } from "node:process";
88import type { ChatCompletionStreamOutput } from "@huggingface/tasks" ;
99
1010const 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 ( / [ x y ] / 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+
1912const ChatCompletionInputSchema = z . object ( {
2013 messages : z . array (
2114 z . object ( {
@@ -48,7 +41,7 @@ class ServerResp extends ServerResponse {
4841
4942export 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 ;
You can’t perform that action at this time.
0 commit comments