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

Function classifiersModerateChat

out/cli.cjs:44873–44926  ·  view source on GitHub ↗
(client, request3, options)

Source from the content-addressed store, hash-verified

44871 var components = __importStar(require_components());
44872 var errors = __importStar(require_errors2());
44873 async function classifiersModerateChat(client, request3, options) {
44874 const parsed = (0, schemas_js_1.safeParse)(request3, (value) => components.ChatClassificationRequest$outboundSchema.parse(value), "Input validation failed");
44875 if (!parsed.ok) {
44876 return parsed;
44877 }
44878 const payload = parsed.value;
44879 const body = (0, encodings_js_1.encodeJSON)("body", payload, { explode: true });
44880 const path5 = (0, url_js_1.pathToFunc)("/v1/chat/moderations")();
44881 const headers = new Headers({
44882 "Content-Type": "application/json",
44883 Accept: "application/json"
44884 });
44885 const secConfig = await (0, security_js_1.extractSecurity)(client._options.apiKey);
44886 const securityInput = secConfig == null ? {} : { apiKey: secConfig };
44887 const requestSecurity = (0, security_js_1.resolveGlobalSecurity)(securityInput);
44888 const context = {
44889 operationID: "moderations_chat_v1_chat_moderations_post",
44890 oAuth2Scopes: [],
44891 resolvedSecurity: requestSecurity,
44892 securitySource: client._options.apiKey,
44893 retryConfig: (options === null || options === void 0 ? void 0 : options.retries) || client._options.retryConfig || { strategy: "none" },
44894 retryCodes: (options === null || options === void 0 ? void 0 : options.retryCodes) || ["429", "500", "502", "503", "504"]
44895 };
44896 const requestRes = client._createRequest(context, {
44897 security: requestSecurity,
44898 method: "POST",
44899 path: path5,
44900 headers,
44901 body,
44902 timeoutMs: (options === null || options === void 0 ? void 0 : options.timeoutMs) || client._options.timeoutMs || -1
44903 }, options);
44904 if (!requestRes.ok) {
44905 return requestRes;
44906 }
44907 const req = requestRes.value;
44908 const doResult = await client._do(req, {
44909 context,
44910 errorCodes: ["422", "4XX", "5XX"],
44911 retryConfig: context.retryConfig,
44912 retryCodes: context.retryCodes
44913 });
44914 if (!doResult.ok) {
44915 return doResult;
44916 }
44917 const response = doResult.value;
44918 const responseFields = {
44919 HttpMeta: { Response: response, Request: req }
44920 };
44921 const [result] = await M5.match(M5.json(200, components.ClassificationResponse$inboundSchema), M5.jsonErr(422, errors.HTTPValidationError$inboundSchema), M5.fail(["4XX", "5XX"]))(response, { extraFields: responseFields });
44922 if (!result.ok) {
44923 return result;
44924 }
44925 return result;
44926 }
44927 }
44928});
44929

Callers

nothing calls this directly

Calls 5

_createRequestMethod · 0.80
_doMethod · 0.80
parseMethod · 0.45
matchMethod · 0.45
jsonMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…