MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / nonAzurePolicy

Function nonAzurePolicy

out/cli.cjs:78497–78534  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78495 var _b2;
78496 var { error } = _a5, successResult = __rest(_a5, ["error"]);
78497 return error ? {
78498 error: Object.assign(Object.assign({}, error), { details: (_b2 = error["details"]) !== null && _b2 !== void 0 ? _b2 : [] })
78499 } : camelCaseKeys(successResult);
78500}
78501
78502// node_modules/@azure/openai/dist-esm/src/api/policies/nonAzure.js
78503function nonAzurePolicy() {
78504 const policy = {
78505 name: "openAiEndpoint",
78506 sendRequest: (request3, next) => {
78507 const obj = new URL(request3.url);
78508 const parts = obj.pathname.split("/");
78509 switch (parts[parts.length - 1]) {
78510 case "completions":
78511 if (parts[parts.length - 2] === "chat") {
78512 obj.pathname = `${parts[1]}/chat/completions`;
78513 } else {
78514 obj.pathname = `${parts[1]}/completions`;
78515 }
78516 break;
78517 case "embeddings":
78518 obj.pathname = `${parts[1]}/embeddings`;
78519 break;
78520 case "generations":
78521 if (parts[parts.length - 2] === "images") {
78522 obj.pathname = `${parts[1]}/images/generations`;
78523 } else {
78524 throw new Error("Unexpected path");
78525 }
78526 break;
78527 case "transcriptions":
78528 obj.pathname = `${parts[1]}/audio/transcriptions`;
78529 break;
78530 case "translations":
78531 obj.pathname = `${parts[1]}/audio/translations`;
78532 break;
78533 }
78534 obj.searchParams.delete("api-version");
78535 request3.url = obj.toString();
78536 return next(request3);
78537 }

Callers 1

constructorMethod · 0.85

Calls 3

nextFunction · 0.85
deleteMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…