ogx-client 0.8.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/.github/workflows/release-doctor.yml +0 -2
  2. package/.release-please-manifest.json +1 -1
  3. package/.stats.yml +4 -4
  4. package/CHANGELOG.md +27 -0
  5. package/CONTRIBUTING.md +0 -14
  6. package/README.md +5 -4
  7. package/api.md +26 -48
  8. package/bin/check-release-environment +0 -4
  9. package/dist/CHANGELOG.md +27 -0
  10. package/dist/README.md +5 -4
  11. package/dist/index.d.mts +2 -18
  12. package/dist/index.d.ts +2 -18
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +0 -15
  15. package/dist/index.js.map +1 -1
  16. package/dist/index.mjs +1 -16
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/package.json +1 -1
  19. package/dist/resources/chat/chat.d.ts +2 -2
  20. package/dist/resources/chat/chat.d.ts.map +1 -1
  21. package/dist/resources/chat/chat.js +2 -2
  22. package/dist/resources/chat/chat.js.map +1 -1
  23. package/dist/resources/chat/chat.mjs +2 -2
  24. package/dist/resources/chat/completions/completions.d.ts +2021 -0
  25. package/dist/resources/chat/completions/completions.d.ts.map +1 -0
  26. package/dist/resources/chat/completions/completions.js +70 -0
  27. package/dist/resources/chat/completions/completions.js.map +1 -0
  28. package/dist/resources/chat/completions/completions.mjs +43 -0
  29. package/dist/resources/chat/completions/completions.mjs.map +1 -0
  30. package/dist/resources/chat/completions/index.d.ts +3 -0
  31. package/dist/resources/chat/completions/index.d.ts.map +1 -0
  32. package/dist/resources/chat/completions/index.js +16 -0
  33. package/dist/resources/chat/completions/index.js.map +1 -0
  34. package/dist/resources/chat/completions/index.mjs +10 -0
  35. package/dist/resources/chat/completions/index.mjs.map +1 -0
  36. package/dist/resources/chat/completions/messages.d.ts +204 -0
  37. package/dist/resources/chat/completions/messages.d.ts.map +1 -0
  38. package/dist/resources/chat/completions/messages.js +35 -0
  39. package/dist/resources/chat/completions/messages.js.map +1 -0
  40. package/dist/resources/chat/completions/messages.mjs +30 -0
  41. package/dist/resources/chat/completions/messages.mjs.map +1 -0
  42. package/dist/resources/chat/completions.d.ts +1 -2020
  43. package/dist/resources/chat/completions.d.ts.map +1 -1
  44. package/dist/resources/chat/completions.js +15 -29
  45. package/dist/resources/chat/completions.js.map +1 -1
  46. package/dist/resources/chat/completions.mjs +1 -27
  47. package/dist/resources/chat/completions.mjs.map +1 -1
  48. package/dist/resources/chat/index.d.ts +1 -1
  49. package/dist/resources/chat/index.d.ts.map +1 -1
  50. package/dist/resources/chat/index.js +2 -2
  51. package/dist/resources/chat/index.js.map +1 -1
  52. package/dist/resources/chat/index.mjs +1 -1
  53. package/dist/resources/completions.d.ts +2 -2
  54. package/dist/resources/completions.d.ts.map +1 -1
  55. package/dist/resources/conversations/conversations.d.ts +12 -11
  56. package/dist/resources/conversations/conversations.d.ts.map +1 -1
  57. package/dist/resources/conversations/conversations.js.map +1 -1
  58. package/dist/resources/conversations/conversations.mjs.map +1 -1
  59. package/dist/resources/conversations/index.d.ts +1 -1
  60. package/dist/resources/conversations/index.d.ts.map +1 -1
  61. package/dist/resources/conversations/items.d.ts +49 -29
  62. package/dist/resources/conversations/items.d.ts.map +1 -1
  63. package/dist/resources/conversations/items.js +5 -5
  64. package/dist/resources/conversations/items.js.map +1 -1
  65. package/dist/resources/conversations/items.mjs +5 -5
  66. package/dist/resources/conversations/items.mjs.map +1 -1
  67. package/dist/resources/files.d.ts +10 -10
  68. package/dist/resources/files.d.ts.map +1 -1
  69. package/dist/resources/files.js.map +1 -1
  70. package/dist/resources/files.mjs.map +1 -1
  71. package/dist/resources/index.d.ts +1 -4
  72. package/dist/resources/index.d.ts.map +1 -1
  73. package/dist/resources/index.js +1 -7
  74. package/dist/resources/index.js.map +1 -1
  75. package/dist/resources/index.mjs +1 -4
  76. package/dist/resources/index.mjs.map +1 -1
  77. package/dist/resources/models/index.d.ts +2 -2
  78. package/dist/resources/models/index.d.ts.map +1 -1
  79. package/dist/resources/models/index.js.map +1 -1
  80. package/dist/resources/models/index.mjs +1 -1
  81. package/dist/resources/models/index.mjs.map +1 -1
  82. package/dist/resources/models/models.d.ts +220 -32
  83. package/dist/resources/models/models.d.ts.map +1 -1
  84. package/dist/resources/models/models.js +32 -10
  85. package/dist/resources/models/models.js.map +1 -1
  86. package/dist/resources/models/models.mjs +32 -10
  87. package/dist/resources/models/models.mjs.map +1 -1
  88. package/dist/resources/models/openai.d.ts +128 -2
  89. package/dist/resources/models/openai.d.ts.map +1 -1
  90. package/dist/resources/models/openai.js +17 -5
  91. package/dist/resources/models/openai.js.map +1 -1
  92. package/dist/resources/models/openai.mjs +17 -5
  93. package/dist/resources/models/openai.mjs.map +1 -1
  94. package/dist/resources/responses/responses.d.ts +0 -16
  95. package/dist/resources/responses/responses.d.ts.map +1 -1
  96. package/dist/resources/responses/responses.js.map +1 -1
  97. package/dist/resources/responses/responses.mjs.map +1 -1
  98. package/dist/resources/shared.d.ts +0 -19
  99. package/dist/resources/shared.d.ts.map +1 -1
  100. package/dist/src/index.ts +12 -43
  101. package/dist/src/resources/chat/chat.ts +2 -2
  102. package/dist/src/resources/chat/completions/completions.ts +2444 -0
  103. package/dist/src/resources/chat/completions/index.ts +24 -0
  104. package/dist/src/resources/chat/completions/messages.ts +273 -0
  105. package/dist/src/resources/chat/completions.ts +1 -2422
  106. package/dist/src/resources/chat/index.ts +1 -1
  107. package/dist/src/resources/completions.ts +2 -2
  108. package/dist/src/resources/conversations/conversations.ts +15 -9
  109. package/dist/src/resources/conversations/index.ts +1 -1
  110. package/dist/src/resources/conversations/items.ts +84 -28
  111. package/dist/src/resources/files.ts +29 -10
  112. package/dist/src/resources/index.ts +9 -10
  113. package/dist/src/resources/models/index.ts +10 -2
  114. package/dist/src/resources/models/models.ts +321 -32
  115. package/dist/src/resources/models/openai.ts +180 -3
  116. package/dist/src/resources/responses/responses.ts +0 -21
  117. package/dist/src/resources/shared.ts +0 -20
  118. package/dist/src/version.ts +1 -1
  119. package/dist/version.d.ts +1 -1
  120. package/dist/version.js +1 -1
  121. package/dist/version.mjs +1 -1
  122. package/package.json +1 -1
  123. package/src/index.ts +12 -43
  124. package/src/resources/chat/chat.ts +2 -2
  125. package/src/resources/chat/completions/completions.ts +2444 -0
  126. package/src/resources/chat/completions/index.ts +24 -0
  127. package/src/resources/chat/completions/messages.ts +273 -0
  128. package/src/resources/chat/completions.ts +1 -2422
  129. package/src/resources/chat/index.ts +1 -1
  130. package/src/resources/completions.ts +2 -2
  131. package/src/resources/conversations/conversations.ts +15 -9
  132. package/src/resources/conversations/index.ts +1 -1
  133. package/src/resources/conversations/items.ts +84 -28
  134. package/src/resources/files.ts +29 -10
  135. package/src/resources/index.ts +9 -10
  136. package/src/resources/models/index.ts +10 -2
  137. package/src/resources/models/models.ts +321 -32
  138. package/src/resources/models/openai.ts +180 -3
  139. package/src/resources/responses/responses.ts +0 -21
  140. package/src/resources/shared.ts +0 -20
  141. package/src/version.ts +1 -1
  142. package/tests/api-resources/chat/{completions.test.ts → completions/completions.test.ts} +0 -1
  143. package/tests/api-resources/chat/completions/messages.test.ts +47 -0
  144. package/tests/api-resources/completions.test.ts +1 -1
  145. package/tests/api-resources/conversations/items.test.ts +12 -0
  146. package/tests/api-resources/models/models.test.ts +34 -0
  147. package/tests/api-resources/models/openai.test.ts +18 -0
  148. package/tests/api-resources/responses/responses.test.ts +0 -2
  149. package/.github/workflows/publish-npm.yml +0 -32
  150. package/dist/resources/moderations.d.ts +0 -83
  151. package/dist/resources/moderations.d.ts.map +0 -1
  152. package/dist/resources/moderations.js +0 -24
  153. package/dist/resources/moderations.js.map +0 -1
  154. package/dist/resources/moderations.mjs +0 -20
  155. package/dist/resources/moderations.mjs.map +0 -1
  156. package/dist/resources/safety.d.ts +0 -297
  157. package/dist/resources/safety.d.ts.map +0 -1
  158. package/dist/resources/safety.js +0 -24
  159. package/dist/resources/safety.js.map +0 -1
  160. package/dist/resources/safety.mjs +0 -20
  161. package/dist/resources/safety.mjs.map +0 -1
  162. package/dist/resources/shields.d.ts +0 -82
  163. package/dist/resources/shields.d.ts.map +0 -1
  164. package/dist/resources/shields.js +0 -46
  165. package/dist/resources/shields.js.map +0 -1
  166. package/dist/resources/shields.mjs +0 -42
  167. package/dist/resources/shields.mjs.map +0 -1
  168. package/dist/src/resources/moderations.ts +0 -97
  169. package/dist/src/resources/safety.ts +0 -367
  170. package/dist/src/resources/shields.ts +0 -119
  171. package/src/resources/moderations.ts +0 -97
  172. package/src/resources/safety.ts +0 -367
  173. package/src/resources/shields.ts +0 -119
  174. package/tests/api-resources/moderations.test.ts +0 -29
  175. package/tests/api-resources/safety.test.ts +0 -41
  176. package/tests/api-resources/shields.test.ts +0 -88
@@ -0,0 +1,47 @@
1
+ // Copyright (c) The OGX Contributors.
2
+ // All rights reserved.
3
+ //
4
+ // This source code is licensed under the terms described in the LICENSE file in
5
+ // the root directory of this source tree.
6
+ //
7
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
8
+
9
+ import OgxClient from 'ogx-client';
10
+ import { Response } from 'node-fetch';
11
+
12
+ const client = new OgxClient({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
13
+
14
+ describe('resource messages', () => {
15
+ test('list', async () => {
16
+ const responsePromise = client.chat.completions.messages.list('completion_id');
17
+ const rawResponse = await responsePromise.asResponse();
18
+ expect(rawResponse).toBeInstanceOf(Response);
19
+ const response = await responsePromise;
20
+ expect(response).not.toBeInstanceOf(Response);
21
+ const dataAndResponse = await responsePromise.withResponse();
22
+ expect(dataAndResponse.data).toBe(response);
23
+ expect(dataAndResponse.response).toBe(rawResponse);
24
+ });
25
+
26
+ test('list: request options instead of params are passed correctly', async () => {
27
+ // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
28
+ await expect(
29
+ client.chat.completions.messages.list('completion_id', { path: '/_stainless_unknown_path' }),
30
+ ).rejects.toThrow(OgxClient.NotFoundError);
31
+ });
32
+
33
+ test('list: request options and params are passed correctly', async () => {
34
+ // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
35
+ await expect(
36
+ client.chat.completions.messages.list(
37
+ 'completion_id',
38
+ {
39
+ after: 'after',
40
+ limit: 0,
41
+ order: 'asc',
42
+ },
43
+ { path: '/_stainless_unknown_path' },
44
+ ),
45
+ ).rejects.toThrow(OgxClient.NotFoundError);
46
+ });
47
+ });
@@ -31,7 +31,7 @@ describe('resource completions', () => {
31
31
  echo: true,
32
32
  frequency_penalty: -2,
33
33
  logit_bias: { foo: 0 },
34
- logprobs: true,
34
+ logprobs: 0,
35
35
  max_tokens: 1,
36
36
  n: 1,
37
37
  presence_penalty: -2,
@@ -114,4 +114,16 @@ describe('resource items', () => {
114
114
  client.conversations.items.get('conversation_id', 'item_id', { path: '/_stainless_unknown_path' }),
115
115
  ).rejects.toThrow(OgxClient.NotFoundError);
116
116
  });
117
+
118
+ test('get: request options and params are passed correctly', async () => {
119
+ // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
120
+ await expect(
121
+ client.conversations.items.get(
122
+ 'conversation_id',
123
+ 'item_id',
124
+ { include: ['web_search_call.action.sources'] },
125
+ { path: '/_stainless_unknown_path' },
126
+ ),
127
+ ).rejects.toThrow(OgxClient.NotFoundError);
128
+ });
117
129
  });
@@ -30,6 +30,22 @@ describe('resource models', () => {
30
30
  );
31
31
  });
32
32
 
33
+ test('retrieve: request options and params are passed correctly', async () => {
34
+ // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
35
+ await expect(
36
+ client.models.retrieve(
37
+ 'model_id',
38
+ {
39
+ 'anthropic-version': 'anthropic-version',
40
+ 'x-goog-api-client': 'x-goog-api-client',
41
+ 'x-goog-api-key': 'x-goog-api-key',
42
+ 'x-goog-user-project': 'x-goog-user-project',
43
+ },
44
+ { path: '/_stainless_unknown_path' },
45
+ ),
46
+ ).rejects.toThrow(OgxClient.NotFoundError);
47
+ });
48
+
33
49
  test('list', async () => {
34
50
  const responsePromise = client.models.list();
35
51
  const rawResponse = await responsePromise.asResponse();
@@ -47,4 +63,22 @@ describe('resource models', () => {
47
63
  OgxClient.NotFoundError,
48
64
  );
49
65
  });
66
+
67
+ test('list: request options and params are passed correctly', async () => {
68
+ // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
69
+ await expect(
70
+ client.models.list(
71
+ {
72
+ after_id: 'after_id',
73
+ before_id: 'before_id',
74
+ limit: 1,
75
+ 'anthropic-version': 'anthropic-version',
76
+ 'x-goog-api-client': 'x-goog-api-client',
77
+ 'x-goog-api-key': 'x-goog-api-key',
78
+ 'x-goog-user-project': 'x-goog-user-project',
79
+ },
80
+ { path: '/_stainless_unknown_path' },
81
+ ),
82
+ ).rejects.toThrow(OgxClient.NotFoundError);
83
+ });
50
84
  });
@@ -29,4 +29,22 @@ describe('resource openai', () => {
29
29
  OgxClient.NotFoundError,
30
30
  );
31
31
  });
32
+
33
+ test('list: request options and params are passed correctly', async () => {
34
+ // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
35
+ await expect(
36
+ client.models.openai.list(
37
+ {
38
+ after_id: 'after_id',
39
+ before_id: 'before_id',
40
+ limit: 1,
41
+ 'anthropic-version': 'anthropic-version',
42
+ 'x-goog-api-client': 'x-goog-api-client',
43
+ 'x-goog-api-key': 'x-goog-api-key',
44
+ 'x-goog-user-project': 'x-goog-user-project',
45
+ },
46
+ { path: '/_stainless_unknown_path' },
47
+ ),
48
+ ).rejects.toThrow(OgxClient.NotFoundError);
49
+ });
32
50
  });
@@ -31,7 +31,6 @@ describe('resource responses', () => {
31
31
  context_management: [{ type: 'compaction', compact_threshold: 0 }],
32
32
  conversation: 'conversation',
33
33
  frequency_penalty: -2,
34
- guardrails: ['string'],
35
34
  include: ['web_search_call.action.sources'],
36
35
  instructions: 'instructions',
37
36
  max_infer_iters: 1,
@@ -48,7 +47,6 @@ describe('resource responses', () => {
48
47
  },
49
48
  prompt_cache_key: 'prompt_cache_key',
50
49
  reasoning: { effort: 'none', summary: 'auto' },
51
- safety_identifier: 'safety_identifier',
52
50
  service_tier: 'auto',
53
51
  store: true,
54
52
  stream: false,
@@ -1,32 +0,0 @@
1
- # This workflow is triggered when a GitHub release is created.
2
- # It can also be run manually to re-publish to NPM in case it failed for some reason.
3
- # You can run this workflow by navigating to https://www.github.com/ogx-ai/ogx-client-typescript/actions/workflows/publish-npm.yml
4
- name: Publish NPM
5
- on:
6
- workflow_dispatch:
7
-
8
- release:
9
- types: [published]
10
-
11
- jobs:
12
- publish:
13
- name: publish
14
- runs-on: ubuntu-latest
15
-
16
- steps:
17
- - uses: actions/checkout@v6
18
-
19
- - name: Set up Node
20
- uses: actions/setup-node@v3
21
- with:
22
- node-version: '20'
23
-
24
- - name: Install dependencies
25
- run: |
26
- yarn install
27
-
28
- - name: Publish to NPM
29
- run: |
30
- bash ./bin/publish-npm
31
- env:
32
- NPM_TOKEN: ${{ secrets.OGX_CLIENT_NPM_TOKEN || secrets.NPM_TOKEN }}
@@ -1,83 +0,0 @@
1
- import { APIResource } from "../resource.js";
2
- import * as Core from "../core.js";
3
- /**
4
- * OpenAI-compatible Moderations API.
5
- */
6
- export declare class Moderations extends APIResource {
7
- /**
8
- * Classifies if text inputs are potentially harmful. OpenAI-compatible endpoint.
9
- */
10
- create(body: ModerationCreateParams, options?: Core.RequestOptions): Core.APIPromise<CreateResponse>;
11
- }
12
- /**
13
- * A moderation object containing the results of content classification.
14
- */
15
- export interface CreateResponse {
16
- /**
17
- * The unique identifier for the moderation request
18
- */
19
- id: string;
20
- /**
21
- * The model used to generate the moderation results
22
- */
23
- model: string;
24
- /**
25
- * A list of moderation result objects
26
- */
27
- results: Array<CreateResponse.Result>;
28
- }
29
- export declare namespace CreateResponse {
30
- /**
31
- * A moderation result object containing flagged status and category information.
32
- */
33
- interface Result {
34
- /**
35
- * Whether any of the below categories are flagged
36
- */
37
- flagged: boolean;
38
- /**
39
- * A dictionary of the categories, and whether they are flagged or not
40
- */
41
- categories?: {
42
- [key: string]: boolean;
43
- } | null;
44
- /**
45
- * A dictionary of the categories along with the input type(s) that the score
46
- * applies to
47
- */
48
- category_applied_input_types?: {
49
- [key: string]: Array<string>;
50
- } | null;
51
- /**
52
- * A dictionary of the categories along with their scores as predicted by model
53
- */
54
- category_scores?: {
55
- [key: string]: number;
56
- } | null;
57
- /**
58
- * Additional metadata about the moderation
59
- */
60
- metadata?: {
61
- [key: string]: unknown;
62
- };
63
- /**
64
- * A message to convey to the user about the moderation result
65
- */
66
- user_message?: string | null;
67
- }
68
- }
69
- export interface ModerationCreateParams {
70
- /**
71
- * Input (or inputs) to classify. Can be a single string or an array of strings.
72
- */
73
- input: string | Array<string>;
74
- /**
75
- * The content moderation model to use. If not specified, the default shield will
76
- * be used.
77
- */
78
- model?: string | null;
79
- }
80
- export declare namespace Moderations {
81
- export { type CreateResponse as CreateResponse, type ModerationCreateParams as ModerationCreateParams };
82
- }
83
- //# sourceMappingURL=moderations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"moderations.d.ts","sourceRoot":"","sources":["../src/resources/moderations.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAEhC;;GAEG;AACH,qBAAa,WAAY,SAAQ,WAAW;IAC1C;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC;CAGrG;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;CACvC;AAED,yBAAiB,cAAc,CAAC;IAC9B;;OAEG;IACH,UAAiB,MAAM;QACrB;;WAEG;QACH,OAAO,EAAE,OAAO,CAAC;QAEjB;;WAEG;QACH,UAAU,CAAC,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;SAAE,GAAG,IAAI,CAAC;QAE/C;;;WAGG;QACH,4BAA4B,CAAC,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAA;SAAE,GAAG,IAAI,CAAC;QAEvE;;WAEG;QACH,eAAe,CAAC,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,GAAG,IAAI,CAAC;QAEnD;;WAEG;QACH,QAAQ,CAAC,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;SAAE,CAAC;QAEtC;;WAEG;QACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC9B;CACF;AAED,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,CAAC,OAAO,WAAW,WAAW,CAAC;IACnC,OAAO,EAAE,KAAK,cAAc,IAAI,cAAc,EAAE,KAAK,sBAAsB,IAAI,sBAAsB,EAAE,CAAC;CACzG"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- // Copyright (c) The OGX Contributors.
3
- // All rights reserved.
4
- //
5
- // This source code is licensed under the terms described in the LICENSE file in
6
- // the root directory of this source tree.
7
- //
8
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.Moderations = void 0;
11
- const resource_1 = require("../resource.js");
12
- /**
13
- * OpenAI-compatible Moderations API.
14
- */
15
- class Moderations extends resource_1.APIResource {
16
- /**
17
- * Classifies if text inputs are potentially harmful. OpenAI-compatible endpoint.
18
- */
19
- create(body, options) {
20
- return this._client.post('/v1/moderations', { body, ...options });
21
- }
22
- }
23
- exports.Moderations = Moderations;
24
- //# sourceMappingURL=moderations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"moderations.js","sourceRoot":"","sources":["../src/resources/moderations.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,uBAAuB;AACvB,EAAE;AACF,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,sFAAsF;;;AAEtF,6CAA0C;AAG1C;;GAEG;AACH,MAAa,WAAY,SAAQ,sBAAW;IAC1C;;OAEG;IACH,MAAM,CAAC,IAA4B,EAAE,OAA6B;QAChE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACpE,CAAC;CACF;AAPD,kCAOC"}
@@ -1,20 +0,0 @@
1
- // Copyright (c) The OGX Contributors.
2
- // All rights reserved.
3
- //
4
- // This source code is licensed under the terms described in the LICENSE file in
5
- // the root directory of this source tree.
6
- //
7
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
8
- import { APIResource } from "../resource.mjs";
9
- /**
10
- * OpenAI-compatible Moderations API.
11
- */
12
- export class Moderations extends APIResource {
13
- /**
14
- * Classifies if text inputs are potentially harmful. OpenAI-compatible endpoint.
15
- */
16
- create(body, options) {
17
- return this._client.post('/v1/moderations', { body, ...options });
18
- }
19
- }
20
- //# sourceMappingURL=moderations.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"moderations.mjs","sourceRoot":"","sources":["../src/resources/moderations.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,uBAAuB;AACvB,EAAE;AACF,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,sFAAsF;OAE/E,EAAE,WAAW,EAAE;AAGtB;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,WAAW;IAC1C;;OAEG;IACH,MAAM,CAAC,IAA4B,EAAE,OAA6B;QAChE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACpE,CAAC;CACF"}
@@ -1,297 +0,0 @@
1
- import { APIResource } from "../resource.js";
2
- import * as Core from "../core.js";
3
- import * as Shared from "./shared.js";
4
- /**
5
- * OpenAI-compatible Moderations API.
6
- */
7
- export declare class Safety extends APIResource {
8
- /**
9
- * Run a safety shield on messages to check for policy violations.
10
- */
11
- runShield(body: SafetyRunShieldParams, options?: Core.RequestOptions): Core.APIPromise<RunShieldResponse>;
12
- }
13
- /**
14
- * Response from running a safety shield.
15
- */
16
- export interface RunShieldResponse {
17
- /**
18
- * Details of a safety violation detected by content moderation.
19
- */
20
- violation?: Shared.SafetyViolation | null;
21
- }
22
- export interface SafetyRunShieldParams {
23
- /**
24
- * The messages to run the shield on
25
- */
26
- messages: Array<SafetyRunShieldParams.OpenAIUserMessageParamInput | SafetyRunShieldParams.OpenAISystemMessageParam | SafetyRunShieldParams.OpenAIAssistantMessageParamInput | SafetyRunShieldParams.OpenAIToolMessageParam | SafetyRunShieldParams.OpenAIDeveloperMessageParam>;
27
- /**
28
- * The identifier of the shield to run
29
- */
30
- shield_id: string;
31
- }
32
- export declare namespace SafetyRunShieldParams {
33
- /**
34
- * A message from the user in an OpenAI-compatible chat completion request.
35
- */
36
- interface OpenAIUserMessageParamInput {
37
- /**
38
- * The content of the message, which can include text and other media.
39
- */
40
- content: string | Array<OpenAIUserMessageParamInput.OpenAIChatCompletionContentPartTextParam | OpenAIUserMessageParamInput.OpenAIChatCompletionContentPartImageParam | OpenAIUserMessageParamInput.OpenAIFile>;
41
- /**
42
- * The name of the user message participant.
43
- */
44
- name?: string | null;
45
- /**
46
- * Must be 'user' to identify this as a user message.
47
- */
48
- role?: 'user';
49
- }
50
- namespace OpenAIUserMessageParamInput {
51
- /**
52
- * Text content part for OpenAI-compatible chat completion messages.
53
- */
54
- interface OpenAIChatCompletionContentPartTextParam {
55
- /**
56
- * The text content of the message.
57
- */
58
- text: string;
59
- /**
60
- * Must be 'text' to identify this as text content.
61
- */
62
- type?: 'text';
63
- }
64
- /**
65
- * Image content part for OpenAI-compatible chat completion messages.
66
- */
67
- interface OpenAIChatCompletionContentPartImageParam {
68
- /**
69
- * Image URL specification and processing details.
70
- */
71
- image_url: OpenAIChatCompletionContentPartImageParam.ImageURL;
72
- /**
73
- * Must be 'image_url' to identify this as image content.
74
- */
75
- type?: 'image_url';
76
- }
77
- namespace OpenAIChatCompletionContentPartImageParam {
78
- /**
79
- * Image URL specification and processing details.
80
- */
81
- interface ImageURL {
82
- /**
83
- * URL of the image to include in the message.
84
- */
85
- url: string;
86
- /**
87
- * Level of detail for image processing. Can be 'low', 'high', or 'auto'.
88
- */
89
- detail?: 'low' | 'high' | 'auto' | null;
90
- }
91
- }
92
- /**
93
- * File content part for OpenAI-compatible chat completion messages.
94
- */
95
- interface OpenAIFile {
96
- /**
97
- * File specification.
98
- */
99
- file: OpenAIFile.File;
100
- /**
101
- * Must be 'file' to identify this as file content.
102
- */
103
- type?: 'file';
104
- }
105
- namespace OpenAIFile {
106
- /**
107
- * File specification.
108
- */
109
- interface File {
110
- /**
111
- * Base64-encoded file data.
112
- */
113
- file_data?: string | null;
114
- /**
115
- * ID of an uploaded file.
116
- */
117
- file_id?: string | null;
118
- /**
119
- * Name of the file.
120
- */
121
- filename?: string | null;
122
- }
123
- }
124
- }
125
- /**
126
- * A system message providing instructions or context to the model.
127
- */
128
- interface OpenAISystemMessageParam {
129
- /**
130
- * The content of the 'system prompt'. If multiple system messages are provided,
131
- * they are concatenated.
132
- */
133
- content: string | Array<OpenAISystemMessageParam.ListOpenAIChatCompletionContentPartTextParam>;
134
- /**
135
- * The name of the system message participant.
136
- */
137
- name?: string | null;
138
- /**
139
- * Must be 'system' to identify this as a system message.
140
- */
141
- role?: 'system';
142
- }
143
- namespace OpenAISystemMessageParam {
144
- /**
145
- * Text content part for OpenAI-compatible chat completion messages.
146
- */
147
- interface ListOpenAIChatCompletionContentPartTextParam {
148
- /**
149
- * The text content of the message.
150
- */
151
- text: string;
152
- /**
153
- * Must be 'text' to identify this as text content.
154
- */
155
- type?: 'text';
156
- }
157
- }
158
- /**
159
- * A message containing the model's (assistant) response in an OpenAI-compatible
160
- * chat completion request.
161
- */
162
- interface OpenAIAssistantMessageParamInput {
163
- /**
164
- * The content of the model's response.
165
- */
166
- content?: string | Array<OpenAIAssistantMessageParamInput.ListOpenAIChatCompletionContentPartTextParam> | null;
167
- /**
168
- * The name of the assistant message participant.
169
- */
170
- name?: string | null;
171
- /**
172
- * Must be 'assistant' to identify this as the model's response.
173
- */
174
- role?: 'assistant';
175
- /**
176
- * List of tool calls. Each tool call is an OpenAIChatCompletionToolCall object.
177
- */
178
- tool_calls?: Array<OpenAIAssistantMessageParamInput.ToolCall> | null;
179
- [k: string]: unknown;
180
- }
181
- namespace OpenAIAssistantMessageParamInput {
182
- /**
183
- * Text content part for OpenAI-compatible chat completion messages.
184
- */
185
- interface ListOpenAIChatCompletionContentPartTextParam {
186
- /**
187
- * The text content of the message.
188
- */
189
- text: string;
190
- /**
191
- * Must be 'text' to identify this as text content.
192
- */
193
- type?: 'text';
194
- }
195
- /**
196
- * Tool call specification for OpenAI-compatible chat completion responses.
197
- */
198
- interface ToolCall {
199
- /**
200
- * Unique identifier for the tool call.
201
- */
202
- id: string;
203
- /**
204
- * Function call details.
205
- */
206
- function: ToolCall.Function;
207
- /**
208
- * Must be 'function' to identify this as a function call.
209
- */
210
- type: 'function';
211
- }
212
- namespace ToolCall {
213
- /**
214
- * Function call details.
215
- */
216
- interface Function {
217
- /**
218
- * Arguments to pass to the function as a JSON string.
219
- */
220
- arguments: string;
221
- /**
222
- * Name of the function to call.
223
- */
224
- name: string;
225
- }
226
- }
227
- }
228
- /**
229
- * A message representing the result of a tool invocation in an OpenAI-compatible
230
- * chat completion request.
231
- */
232
- interface OpenAIToolMessageParam {
233
- /**
234
- * The response content from the tool.
235
- */
236
- content: string | Array<OpenAIToolMessageParam.ListOpenAIChatCompletionContentPartTextParam>;
237
- /**
238
- * Unique identifier for the tool call this response is for.
239
- */
240
- tool_call_id: string;
241
- /**
242
- * Must be 'tool' to identify this as a tool response.
243
- */
244
- role?: 'tool';
245
- }
246
- namespace OpenAIToolMessageParam {
247
- /**
248
- * Text content part for OpenAI-compatible chat completion messages.
249
- */
250
- interface ListOpenAIChatCompletionContentPartTextParam {
251
- /**
252
- * The text content of the message.
253
- */
254
- text: string;
255
- /**
256
- * Must be 'text' to identify this as text content.
257
- */
258
- type?: 'text';
259
- }
260
- }
261
- /**
262
- * A message from the developer in an OpenAI-compatible chat completion request.
263
- */
264
- interface OpenAIDeveloperMessageParam {
265
- /**
266
- * The content of the developer message.
267
- */
268
- content: string | Array<OpenAIDeveloperMessageParam.ListOpenAIChatCompletionContentPartTextParam>;
269
- /**
270
- * The name of the developer message participant.
271
- */
272
- name?: string | null;
273
- /**
274
- * Must be 'developer' to identify this as a developer message.
275
- */
276
- role?: 'developer';
277
- }
278
- namespace OpenAIDeveloperMessageParam {
279
- /**
280
- * Text content part for OpenAI-compatible chat completion messages.
281
- */
282
- interface ListOpenAIChatCompletionContentPartTextParam {
283
- /**
284
- * The text content of the message.
285
- */
286
- text: string;
287
- /**
288
- * Must be 'text' to identify this as text content.
289
- */
290
- type?: 'text';
291
- }
292
- }
293
- }
294
- export declare namespace Safety {
295
- export { type RunShieldResponse as RunShieldResponse, type SafetyRunShieldParams as SafetyRunShieldParams };
296
- }
297
- //# sourceMappingURL=safety.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"safety.d.ts","sourceRoot":"","sources":["../src/resources/safety.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC;;GAE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AAC;KACpB;IAED,UAAiB,2BAA2B,CAAC;QAC3C;;WAEG;QACH,UAAiB,4CAA4C;YAC3D;;eAEG;YACH,IAAI,EAAE,MAAM,CAAC;YAEb;;eAEG;YACH,IAAI,CAAC,EAAE,MAAM,CAAC;SACf;KACF;CACF;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,OAAO,EAAE,KAAK,iBAAiB,IAAI,iBAAiB,EAAE,KAAK,qBAAqB,IAAI,qBAAqB,EAAE,CAAC;CAC7G"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- // Copyright (c) The OGX Contributors.
3
- // All rights reserved.
4
- //
5
- // This source code is licensed under the terms described in the LICENSE file in
6
- // the root directory of this source tree.
7
- //
8
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.Safety = void 0;
11
- const resource_1 = require("../resource.js");
12
- /**
13
- * OpenAI-compatible Moderations API.
14
- */
15
- class Safety extends resource_1.APIResource {
16
- /**
17
- * Run a safety shield on messages to check for policy violations.
18
- */
19
- runShield(body, options) {
20
- return this._client.post('/v1/safety/run-shield', { body, ...options });
21
- }
22
- }
23
- exports.Safety = Safety;
24
- //# sourceMappingURL=safety.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"safety.js","sourceRoot":"","sources":["../src/resources/safety.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,uBAAuB;AACvB,EAAE;AACF,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,sFAAsF;;;AAEtF,6CAA0C;AAI1C;;GAEG;AACH,MAAa,MAAO,SAAQ,sBAAW;IACrC;;OAEG;IACH,SAAS,CAAC,IAA2B,EAAE,OAA6B;QAClE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF;AAPD,wBAOC"}