更新配置和聊天路由,添加会话中止与分叉功能
This commit is contained in:
Vendored
+11
@@ -1,5 +1,6 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { config } from "../config.js";
|
||||
import { logger } from "../logger.js";
|
||||
const allowedMethods = new Set(["GET", "POST", "PUT", "PATCH", "DELETE"]);
|
||||
const resultStore = new Map();
|
||||
export class DynamicHttpExecutor {
|
||||
@@ -28,11 +29,21 @@ export class DynamicHttpExecutor {
|
||||
if (context.projectId) {
|
||||
headers.set("x-project-id", context.projectId);
|
||||
}
|
||||
const startedAt = Date.now();
|
||||
const response = await fetch(url, {
|
||||
method,
|
||||
headers,
|
||||
signal: AbortSignal.timeout(config.TJWATER_API_TIMEOUT_MS),
|
||||
});
|
||||
const durationMs = Date.now() - startedAt;
|
||||
logger.info({
|
||||
method,
|
||||
path,
|
||||
statusCode: response.status,
|
||||
durationMs,
|
||||
traceId: context.traceId,
|
||||
projectId: context.projectId,
|
||||
}, "dynamic_http_call completed");
|
||||
const contentType = response.headers.get("content-type") ?? "";
|
||||
const rawText = await response.text();
|
||||
const data = contentType.includes("application/json") && rawText
|
||||
|
||||
Reference in New Issue
Block a user