openai.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. /**
  2. * openai.ts - OpenAI-compatible HTTP embedding provider
  3. *
  4. * Talks to any endpoint that implements `POST /v1/embeddings` with the OpenAI
  5. * shape: request `{model, input: string|string[]}`, response
  6. * `{data: [{embedding: number[], index: number}, ...]}`.
  7. *
  8. * Used by qmd to delegate embeddings to a GPU worker (e.g. ai.mm.mk →
  9. * qmd-embed-worker on `models` LXC, RTX 4090) instead of running
  10. * node-llama-cpp locally.
  11. *
  12. * Features:
  13. * - Batches input in groups of ≤64 (configurable via QMD_EMBED_BATCH_SIZE)
  14. * - Retries 429 / 503 with exponential backoff (1s, 4s, 16s)
  15. * - 4xx (non-429) → no retry, count as failure
  16. * - Circuit breaker: >50% failures in a 60s window → OPEN for 5 min,
  17. * callers can use this to fall back to a local provider
  18. * - Per-call timeout via AbortSignal (default QMD_EMBED_TIMEOUT_MS=30000)
  19. * - Healthcheck via `GET /health` if available, else a probe embed call
  20. */
  21. // ─────────────────────────── Configuration ───────────────────────────────────
  22. /**
  23. * Default batch size — most OpenAI-compatible embedding endpoints accept up to
  24. * 2048 inputs per call but for memory and latency we cap at 64.
  25. */
  26. export const DEFAULT_BATCH_SIZE = 64;
  27. /**
  28. * Default in-flight concurrency cap for `embedBatch`. The qmd-embed-worker
  29. * exposes a 4-way semaphore (`MAX_CONCURRENT_REQUESTS=4`) and idles at
  30. * queue-depth 1.0 under sequential clients (i-fkpnar9i baseline). Defaulting
  31. * to 4 matches the worker's advertised concurrency without overshooting the
  32. * GPU. Override per-deploy via `QMD_EMBED_CONCURRENCY`. Setting to 1 reverts
  33. * to the legacy sequential dispatch.
  34. */
  35. export const DEFAULT_CONCURRENCY = 4;
  36. /**
  37. * Default per-request timeout (30 s). embeddinggemma-300M on RTX 4090 takes
  38. * <500ms per batch of 64 in practice; 30s is a safe upper bound.
  39. */
  40. export const DEFAULT_TIMEOUT_MS = 30_000;
  41. /**
  42. * Retry backoff schedule (ms) for 429/503 responses. 3 attempts total
  43. * (initial + 2 retries) — aligns with issue spec "1s/4s/16s".
  44. */
  45. export const RETRY_BACKOFFS_MS = [1_000, 4_000, 16_000];
  46. /**
  47. * Circuit breaker — flips OPEN when error rate exceeds threshold within
  48. * window. While OPEN, every call fails fast so the caller can fall back.
  49. */
  50. export const CIRCUIT_WINDOW_MS = 60_000;
  51. export const CIRCUIT_OPEN_DURATION_MS = 5 * 60_000;
  52. export const CIRCUIT_FAILURE_RATE_THRESHOLD = 0.5;
  53. export const CIRCUIT_MIN_SAMPLES = 4;
  54. // ─────────────────────────── Helpers ─────────────────────────────────────────
  55. function defaultSleep(ms) {
  56. return new Promise((resolve) => setTimeout(resolve, ms));
  57. }
  58. /**
  59. * Build the merged AbortSignal for a single HTTP attempt: combines an
  60. * external `userSignal` (from caller / withLLMSession) with a per-attempt
  61. * timeout signal. Returns the merged signal AND the timeout id so the
  62. * caller can `clearTimeout` after the attempt completes (avoids leaks).
  63. */
  64. function buildAttemptSignal(userSignal, timeoutMs) {
  65. const ctrl = new AbortController();
  66. const timeoutId = setTimeout(() => {
  67. ctrl.abort(new Error(`Request timed out after ${timeoutMs}ms`));
  68. }, timeoutMs);
  69. // Don't keep process alive just for this timer
  70. if (typeof timeoutId === "object" && timeoutId !== null && "unref" in timeoutId) {
  71. timeoutId.unref();
  72. }
  73. const onUserAbort = () => ctrl.abort(userSignal?.reason);
  74. if (userSignal) {
  75. if (userSignal.aborted) {
  76. ctrl.abort(userSignal.reason);
  77. }
  78. else {
  79. userSignal.addEventListener("abort", onUserAbort, { once: true });
  80. }
  81. }
  82. const cleanup = () => {
  83. clearTimeout(timeoutId);
  84. if (userSignal)
  85. userSignal.removeEventListener("abort", onUserAbort);
  86. };
  87. return { signal: ctrl.signal, cleanup };
  88. }
  89. /**
  90. * Determine whether an HTTP status is retryable. 429 (Too Many Requests)
  91. * and 503 (Service Unavailable) are retried; 4xx (other than 429) are not.
  92. */
  93. export function isRetryableStatus(status) {
  94. return status === 429 || status === 503;
  95. }
  96. /**
  97. * Chunk an array into pieces of ≤ size each. `size` MUST be ≥ 1.
  98. */
  99. export function chunkArray(items, size) {
  100. if (size < 1)
  101. throw new Error(`chunkArray: size must be ≥ 1, got ${size}`);
  102. if (items.length <= size)
  103. return items.length === 0 ? [] : [items];
  104. const out = [];
  105. for (let i = 0; i < items.length; i += size) {
  106. out.push(items.slice(i, i + size));
  107. }
  108. return out;
  109. }
  110. // ─────────────────────────── Circuit Breaker ─────────────────────────────────
  111. /**
  112. * Sliding-window circuit breaker. Tracks the last N samples (min 4) over a
  113. * 60-second window; flips OPEN when failure rate exceeds 50%, then auto-
  114. * resets to HALF-OPEN after 5 minutes — at which point the next probe
  115. * decides whether to close (success) or re-open (failure).
  116. */
  117. export class CircuitBreaker {
  118. samples = [];
  119. state = "closed";
  120. openedAt = null;
  121. windowMs;
  122. openDurationMs;
  123. threshold;
  124. minSamples;
  125. now;
  126. constructor(opts = {}) {
  127. this.windowMs = opts.windowMs ?? CIRCUIT_WINDOW_MS;
  128. this.openDurationMs = opts.openDurationMs ?? CIRCUIT_OPEN_DURATION_MS;
  129. this.threshold = opts.threshold ?? CIRCUIT_FAILURE_RATE_THRESHOLD;
  130. this.minSamples = opts.minSamples ?? CIRCUIT_MIN_SAMPLES;
  131. this.now = opts.now ?? Date.now;
  132. }
  133. getState() {
  134. this.tickAutoReset();
  135. return this.state;
  136. }
  137. /**
  138. * Returns true when calls should be short-circuited (skip HTTP, fall back).
  139. * Side-effects: may transition OPEN → HALF-OPEN if the open window expired.
  140. */
  141. shouldFailFast() {
  142. return this.getState() === "open";
  143. }
  144. /** Record a successful call. */
  145. recordSuccess() {
  146. // Honor the time-based OPEN→HALF-OPEN transition before deciding what
  147. // to do with this sample. Without this, a success that lands AFTER the
  148. // open window expired would still see state==="open" and never close
  149. // the breaker (a probe call could only flip it via getState()).
  150. this.tickAutoReset();
  151. this.pushSample(true);
  152. if (this.state === "half-open") {
  153. this.state = "closed";
  154. this.openedAt = null;
  155. }
  156. }
  157. /** Record a failed call. May trigger OPEN. */
  158. recordFailure() {
  159. // Same reasoning as recordSuccess — apply lazy auto-reset before
  160. // classifying the sample.
  161. this.tickAutoReset();
  162. this.pushSample(false);
  163. if (this.state === "half-open") {
  164. // Probe failed — re-open
  165. this.state = "open";
  166. this.openedAt = this.now();
  167. return;
  168. }
  169. if (this.state === "closed")
  170. this.evaluate();
  171. }
  172. /** Force-reset the breaker (used by tests / admin) */
  173. reset() {
  174. this.samples = [];
  175. this.state = "closed";
  176. this.openedAt = null;
  177. }
  178. pushSample(ok) {
  179. const ts = this.now();
  180. this.samples.push({ ts, ok });
  181. // Drop samples outside the window
  182. const cutoff = ts - this.windowMs;
  183. while (this.samples.length > 0 && this.samples[0].ts < cutoff) {
  184. this.samples.shift();
  185. }
  186. }
  187. evaluate() {
  188. if (this.samples.length < this.minSamples)
  189. return;
  190. const failures = this.samples.filter((s) => !s.ok).length;
  191. const rate = failures / this.samples.length;
  192. if (rate > this.threshold) {
  193. this.state = "open";
  194. this.openedAt = this.now();
  195. }
  196. }
  197. tickAutoReset() {
  198. if (this.state === "open" && this.openedAt !== null) {
  199. if (this.now() - this.openedAt >= this.openDurationMs) {
  200. this.state = "half-open";
  201. }
  202. }
  203. }
  204. }
  205. // ─────────────────────────── Errors ──────────────────────────────────────────
  206. /**
  207. * Raised when the circuit breaker is OPEN and a call is short-circuited.
  208. * Callers (e.g. fallback wrapper) can catch this to switch to local provider.
  209. */
  210. export class CircuitOpenError extends Error {
  211. constructor(message = "OpenAIEmbeddingsProvider circuit is OPEN") {
  212. super(message);
  213. this.name = "CircuitOpenError";
  214. }
  215. }
  216. /**
  217. * Persistent (non-retryable) HTTP error from upstream. Includes status code.
  218. */
  219. export class HttpError extends Error {
  220. status;
  221. bodyPreview;
  222. constructor(status, bodyPreview) {
  223. super(`HTTP ${status}: ${bodyPreview.slice(0, 200)}`);
  224. this.name = "HttpError";
  225. this.status = status;
  226. this.bodyPreview = bodyPreview.slice(0, 1024);
  227. }
  228. }
  229. // ─────────────────────────── Provider ────────────────────────────────────────
  230. export class OpenAIEmbeddingsProvider {
  231. kind = "openai";
  232. endpoint;
  233. apiKey;
  234. modelId;
  235. upstreamModel;
  236. batchSize;
  237. concurrency;
  238. timeoutMs;
  239. fetchImpl;
  240. retryBackoffsMs;
  241. sleep;
  242. now;
  243. dimensions = undefined;
  244. lastError = undefined;
  245. breaker;
  246. constructor(config) {
  247. if (!config.endpoint) {
  248. throw new Error("OpenAIEmbeddingsProvider: endpoint is required");
  249. }
  250. this.endpoint = config.endpoint.replace(/\/+$/, "");
  251. this.apiKey = config.apiKey;
  252. this.modelId = config.modelId ?? "embeddinggemma";
  253. this.upstreamModel = config.upstreamModel ?? this.modelId;
  254. this.batchSize = config.batchSize ?? DEFAULT_BATCH_SIZE;
  255. this.concurrency = config.concurrency ?? DEFAULT_CONCURRENCY;
  256. this.timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;
  257. this.fetchImpl = config.fetchImpl ?? globalThis.fetch;
  258. this.retryBackoffsMs = config.retryBackoffsMs ?? RETRY_BACKOFFS_MS;
  259. this.sleep = config.sleep ?? defaultSleep;
  260. this.now = config.now ?? Date.now;
  261. this.breaker = new CircuitBreaker({ now: this.now });
  262. if (!this.fetchImpl) {
  263. throw new Error("OpenAIEmbeddingsProvider: global fetch is unavailable. " +
  264. "Provide a `fetchImpl` config option (Node ≥18 ships fetch by default).");
  265. }
  266. if (this.batchSize < 1) {
  267. throw new Error(`OpenAIEmbeddingsProvider: batchSize must be ≥ 1, got ${this.batchSize}`);
  268. }
  269. if (this.concurrency < 1) {
  270. throw new Error(`OpenAIEmbeddingsProvider: concurrency must be ≥ 1, got ${this.concurrency}`);
  271. }
  272. }
  273. getModelId() {
  274. return this.modelId;
  275. }
  276. getDimensions() {
  277. return this.dimensions;
  278. }
  279. /**
  280. * Most recent per-chunk failure message (HTTP status + body preview, malformed
  281. * JSON, timeout, abort reason). Returns `undefined` after a successful call
  282. * or before the first call. See `EmbeddingProvider.getLastError`.
  283. */
  284. getLastError() {
  285. return this.lastError;
  286. }
  287. /** Endpoint URL configured at construction time — used by callers when
  288. * building error messages for failed first-chunk probes. */
  289. getEndpoint() {
  290. return this.endpoint;
  291. }
  292. async healthcheck(signal) {
  293. // Try GET /health first (worker exposes it). Fall back to probe embed.
  294. try {
  295. const { signal: attemptSig, cleanup } = buildAttemptSignal(signal, this.timeoutMs);
  296. try {
  297. const resp = await this.fetchImpl(`${this.endpoint}/health`, {
  298. method: "GET",
  299. headers: this.buildHeaders(),
  300. signal: attemptSig,
  301. });
  302. if (resp.ok) {
  303. return {
  304. ok: true,
  305. model: this.modelId,
  306. dimensions: this.dimensions,
  307. detail: `GET /health → ${resp.status}`,
  308. };
  309. }
  310. return {
  311. ok: false,
  312. model: this.modelId,
  313. detail: `GET /health → HTTP ${resp.status}`,
  314. };
  315. }
  316. finally {
  317. cleanup();
  318. }
  319. }
  320. catch (err) {
  321. // Endpoint may not implement /health — try a single embed probe instead.
  322. try {
  323. const probe = await this.embed("healthcheck", { signal });
  324. if (probe) {
  325. return {
  326. ok: true,
  327. model: this.modelId,
  328. dimensions: probe.embedding.length,
  329. detail: "embed probe ok",
  330. };
  331. }
  332. return {
  333. ok: false,
  334. model: this.modelId,
  335. detail: "embed probe returned null",
  336. };
  337. }
  338. catch (probeErr) {
  339. return {
  340. ok: false,
  341. model: this.modelId,
  342. detail: (err instanceof Error ? err.message : String(err)) +
  343. " | probe: " +
  344. (probeErr instanceof Error ? probeErr.message : String(probeErr)),
  345. };
  346. }
  347. }
  348. }
  349. async embed(text, options = {}) {
  350. const batch = await this.embedBatch([text], options);
  351. return batch[0] ?? null;
  352. }
  353. async embedBatch(texts, options = {}) {
  354. if (texts.length === 0)
  355. return [];
  356. if (this.breaker.shouldFailFast()) {
  357. throw new CircuitOpenError();
  358. }
  359. const chunks = chunkArray(texts, this.batchSize);
  360. const results = new Array(texts.length).fill(null);
  361. // Pre-compute the input-array starting position for each chunk so each
  362. // worker can write its slice of `results` independently — input order is
  363. // preserved end-to-end without a final re-sort step.
  364. const chunkStarts = new Array(chunks.length);
  365. {
  366. let cursor = 0;
  367. for (let i = 0; i < chunks.length; i++) {
  368. chunkStarts[i] = cursor;
  369. cursor += chunks[i].length;
  370. }
  371. }
  372. // Shared state across the worker pool. Each transition is final-write,
  373. // so plain JS scalars are safe — no atomics or locks needed since
  374. // workers only contend on these via cooperative-scheduled awaits.
  375. let nextChunkIdx = 0;
  376. let anySucceeded = false;
  377. let aborted = false;
  378. let circuitTrippedDuringRun = null;
  379. // Workers run as parallel async tasks pulling chunks off `nextChunkIdx`
  380. // until the queue is drained or one of the early-exit flags is set.
  381. // Concurrency is capped at min(this.concurrency, chunks.length) so we
  382. // don't spin up idle workers for tiny inputs.
  383. const workerCount = Math.min(this.concurrency, chunks.length);
  384. const dispatchOne = async () => {
  385. while (true) {
  386. if (aborted || circuitTrippedDuringRun)
  387. return;
  388. const idx = nextChunkIdx++;
  389. if (idx >= chunks.length)
  390. return;
  391. const chunk = chunks[idx];
  392. const start = chunkStarts[idx];
  393. // Honor abort/breaker BEFORE issuing the request so we don't waste
  394. // network for a dispatch we know will be discarded.
  395. if (options.signal?.aborted) {
  396. aborted = true;
  397. this.lastError = `aborted by caller${options.signal.reason ? `: ${String(options.signal.reason)}` : ""}`;
  398. return;
  399. }
  400. if (this.breaker.shouldFailFast()) {
  401. // Capture the breaker-open intent so we throw it AFTER all
  402. // currently in-flight workers settle, instead of leaking
  403. // half-completed results. The thrown error is a fresh instance
  404. // (matching legacy behavior).
  405. circuitTrippedDuringRun = new CircuitOpenError();
  406. return;
  407. }
  408. try {
  409. const embeddings = await this.requestWithRetry(chunk, options);
  410. for (let i = 0; i < chunk.length; i++) {
  411. const embedding = embeddings[i];
  412. if (embedding) {
  413. results[start + i] = {
  414. embedding,
  415. model: this.modelId,
  416. };
  417. anySucceeded = true;
  418. // Record dimensions on first success. Concurrent workers may
  419. // race on this assignment, but they all observe the same
  420. // length so the race is benign.
  421. if (this.dimensions === undefined) {
  422. this.dimensions = embedding.length;
  423. }
  424. }
  425. }
  426. this.breaker.recordSuccess();
  427. }
  428. catch (err) {
  429. this.breaker.recordFailure();
  430. if (err instanceof CircuitOpenError) {
  431. circuitTrippedDuringRun = err;
  432. return;
  433. }
  434. // Last-write-wins on lastError matches the legacy semantics — under
  435. // concurrency multiple workers may fail in the same call, but the
  436. // lastError just needs to surface "the most recent cause."
  437. this.lastError = this.formatErrorContext(err);
  438. if (process.env.QMD_EMBED_DEBUG) {
  439. process.stderr.write(`OpenAIEmbeddingsProvider: chunk failed (${err instanceof Error ? err.message : String(err)})\n`);
  440. }
  441. }
  442. }
  443. };
  444. await Promise.all(Array.from({ length: workerCount }, () => dispatchOne()));
  445. // If a worker observed `shouldFailFast()` mid-run, surface the error
  446. // after all in-flight workers have settled.
  447. if (circuitTrippedDuringRun)
  448. throw circuitTrippedDuringRun;
  449. // Clear lastError on a fully-successful sweep (every input got an embedding).
  450. if (anySucceeded && results.every((r) => r !== null)) {
  451. this.lastError = undefined;
  452. }
  453. return results;
  454. }
  455. async dispose() {
  456. // Nothing to release — fetch handles its own connection pooling.
  457. // Reset the breaker so a re-instantiation starts fresh.
  458. this.breaker.reset();
  459. }
  460. // ────────────────────── Internals ──────────────────────
  461. /**
  462. * Format a request-failure context string for `lastError`. Includes endpoint
  463. * + HTTP status + body preview when the error was an `HttpError`, otherwise
  464. * falls back to the message of the underlying error (or the value itself
  465. * when not an Error). Kept short — body preview is already capped at 1024
  466. * chars by `HttpError`, but we trim further here for the dimension-probe
  467. * thrown error which surfaces directly to users.
  468. */
  469. formatErrorContext(err) {
  470. if (err instanceof HttpError) {
  471. const preview = err.bodyPreview.replace(/\s+/g, " ").trim().slice(0, 240);
  472. return `endpoint=${this.endpoint}/v1/embeddings status=${err.status}${preview ? ` body="${preview}"` : ""}`;
  473. }
  474. if (err instanceof Error) {
  475. return `endpoint=${this.endpoint}/v1/embeddings error="${err.message}"`;
  476. }
  477. return `endpoint=${this.endpoint}/v1/embeddings error="${String(err)}"`;
  478. }
  479. buildHeaders() {
  480. const headers = {
  481. "Content-Type": "application/json",
  482. "Accept": "application/json",
  483. };
  484. if (this.apiKey) {
  485. headers["Authorization"] = `Bearer ${this.apiKey}`;
  486. }
  487. return headers;
  488. }
  489. /**
  490. * Single HTTP request with retry on 429/503. Returns embeddings indexed
  491. * the same as `texts`. Throws on non-retryable failure or all attempts
  492. * exhausted.
  493. */
  494. async requestWithRetry(texts, options) {
  495. let lastErr = null;
  496. const maxAttempts = this.retryBackoffsMs.length + 1;
  497. for (let attempt = 0; attempt < maxAttempts; attempt++) {
  498. // Honor user abort BEFORE issuing the call (avoids wasted network)
  499. if (options.signal?.aborted) {
  500. throw new Error("aborted by caller");
  501. }
  502. try {
  503. return await this.requestOnce(texts, options);
  504. }
  505. catch (err) {
  506. lastErr = err;
  507. const retryable = err instanceof HttpError ? isRetryableStatus(err.status) : false;
  508. if (!retryable)
  509. throw err;
  510. if (attempt < this.retryBackoffsMs.length) {
  511. await this.sleep(this.retryBackoffsMs[attempt]);
  512. }
  513. }
  514. }
  515. // Exhausted retries → throw the last error so caller marks the chunk null
  516. throw lastErr ?? new Error("requestWithRetry exhausted");
  517. }
  518. /**
  519. * Issue one HTTP attempt to `POST /v1/embeddings`. Does NOT retry.
  520. */
  521. async requestOnce(texts, options) {
  522. const { signal: attemptSig, cleanup } = buildAttemptSignal(options.signal, this.timeoutMs);
  523. try {
  524. const body = JSON.stringify({
  525. model: options.model ?? this.upstreamModel,
  526. input: texts,
  527. });
  528. const resp = await this.fetchImpl(`${this.endpoint}/v1/embeddings`, {
  529. method: "POST",
  530. headers: this.buildHeaders(),
  531. body,
  532. signal: attemptSig,
  533. });
  534. if (!resp.ok) {
  535. const text = await resp.text().catch(() => "");
  536. throw new HttpError(resp.status, text);
  537. }
  538. let parsed;
  539. try {
  540. parsed = (await resp.json());
  541. }
  542. catch (err) {
  543. throw new Error(`OpenAIEmbeddingsProvider: malformed JSON from ${this.endpoint}/v1/embeddings: ${err instanceof Error ? err.message : String(err)}`);
  544. }
  545. if (!parsed || !Array.isArray(parsed.data)) {
  546. throw new Error(`OpenAIEmbeddingsProvider: response missing "data" array (got ${typeof parsed})`);
  547. }
  548. // Sort by index to match input order (in case server returns out-of-order).
  549. const out = new Array(texts.length);
  550. for (const item of parsed.data) {
  551. if (typeof item.index !== "number" ||
  552. item.index < 0 ||
  553. item.index >= texts.length) {
  554. throw new Error(`OpenAIEmbeddingsProvider: data item index out of range (${item.index}, expected 0..${texts.length - 1})`);
  555. }
  556. if (!Array.isArray(item.embedding)) {
  557. throw new Error(`OpenAIEmbeddingsProvider: data[${item.index}].embedding is not an array`);
  558. }
  559. out[item.index] = item.embedding;
  560. }
  561. // Sanity check — every slot must be filled
  562. for (let i = 0; i < texts.length; i++) {
  563. if (!out[i]) {
  564. throw new Error(`OpenAIEmbeddingsProvider: response missing embedding for index ${i}`);
  565. }
  566. }
  567. return out;
  568. }
  569. finally {
  570. cleanup();
  571. }
  572. }
  573. }