Skip to content
This repository was archived by the owner on Aug 14, 2025. It is now read-only.

Commit 746de67

Browse files
feat(api): update via SDK Studio
1 parent 96ca9d0 commit 746de67

File tree

8 files changed

+132
-115
lines changed

8 files changed

+132
-115
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 106
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-f59f1c7d33001d60b5190f68aa49eacec90f05dbe694620b8916152c3922051d.yml
33
openapi_spec_hash: 804edd2e834493906dc430145402be3b
4-
config_hash: e6c3e48e220b264936ee6df8b996ab12
4+
config_hash: de16e52db65de71ac35adcdb665a74f5

api.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,16 +403,24 @@ Methods:
403403

404404
- <code title="get /v1/inspect/routes">client.routes.<a href="./src/resources/routes.ts">list</a>() -> RouteListResponse</code>
405405

406+
# Moderations
407+
408+
Types:
409+
410+
- <code><a href="./src/resources/moderations.ts">CreateResponse</a></code>
411+
412+
Methods:
413+
414+
- <code title="post /v1/openai/v1/moderations">client.moderations.<a href="./src/resources/moderations.ts">create</a>({ ...params }) -> CreateResponse</code>
415+
406416
# Safety
407417

408418
Types:
409419

410-
- <code><a href="./src/resources/safety.ts">CreateResponse</a></code>
411420
- <code><a href="./src/resources/safety.ts">RunShieldResponse</a></code>
412421

413422
Methods:
414423

415-
- <code title="post /v1/openai/v1/moderations">client.safety.<a href="./src/resources/safety.ts">create</a>({ ...params }) -> CreateResponse</code>
416424
- <code title="post /v1/safety/run-shield">client.safety.<a href="./src/resources/safety.ts">runShield</a>({ ...params }) -> RunShieldResponse</code>
417425

418426
# Shields

src/index.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,10 @@ import {
6868
ModelRegisterParams,
6969
Models,
7070
} from './resources/models';
71+
import { CreateResponse, ModerationCreateParams, Moderations } from './resources/moderations';
7172
import { ListProvidersResponse, ProviderListResponse, Providers } from './resources/providers';
7273
import { ListRoutesResponse, RouteListResponse, Routes } from './resources/routes';
73-
import {
74-
CreateResponse,
75-
RunShieldResponse,
76-
Safety,
77-
SafetyCreateParams,
78-
SafetyRunShieldParams,
79-
} from './resources/safety';
74+
import { RunShieldResponse, Safety, SafetyRunShieldParams } from './resources/safety';
8075
import {
8176
Scoring,
8277
ScoringScoreBatchParams,
@@ -335,6 +330,7 @@ export class LlamaStackClient extends Core.APIClient {
335330
postTraining: API.PostTraining = new API.PostTraining(this);
336331
providers: API.Providers = new API.Providers(this);
337332
routes: API.Routes = new API.Routes(this);
333+
moderations: API.Moderations = new API.Moderations(this);
338334
safety: API.Safety = new API.Safety(this);
339335
shields: API.Shields = new API.Shields(this);
340336
syntheticDataGeneration: API.SyntheticDataGeneration = new API.SyntheticDataGeneration(this);
@@ -413,6 +409,7 @@ LlamaStackClient.Models = Models;
413409
LlamaStackClient.PostTraining = PostTraining;
414410
LlamaStackClient.Providers = Providers;
415411
LlamaStackClient.Routes = Routes;
412+
LlamaStackClient.Moderations = Moderations;
416413
LlamaStackClient.Safety = Safety;
417414
LlamaStackClient.Shields = Shields;
418415
LlamaStackClient.SyntheticDataGeneration = SyntheticDataGeneration;
@@ -604,10 +601,14 @@ export declare namespace LlamaStackClient {
604601
};
605602

606603
export {
607-
Safety as Safety,
604+
Moderations as Moderations,
608605
type CreateResponse as CreateResponse,
606+
type ModerationCreateParams as ModerationCreateParams,
607+
};
608+
609+
export {
610+
Safety as Safety,
609611
type RunShieldResponse as RunShieldResponse,
610-
type SafetyCreateParams as SafetyCreateParams,
611612
type SafetyRunShieldParams as SafetyRunShieldParams,
612613
};
613614

src/resources/index.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export {
8686
type ModelListResponse,
8787
type ModelRegisterParams,
8888
} from './models';
89+
export { Moderations, type CreateResponse, type ModerationCreateParams } from './moderations';
8990
export {
9091
PostTraining,
9192
type AlgorithmConfig,
@@ -106,13 +107,7 @@ export {
106107
type ResponseListParams,
107108
} from './responses/responses';
108109
export { Routes, type ListRoutesResponse, type RouteListResponse } from './routes';
109-
export {
110-
Safety,
111-
type CreateResponse,
112-
type RunShieldResponse,
113-
type SafetyCreateParams,
114-
type SafetyRunShieldParams,
115-
} from './safety';
110+
export { Safety, type RunShieldResponse, type SafetyRunShieldParams } from './safety';
116111
export {
117112
Scoring,
118113
type ScoringScoreResponse,

src/resources/moderations.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../resource';
4+
import * as Core from '../core';
5+
6+
export class Moderations extends APIResource {
7+
/**
8+
* Classifies if text and/or image inputs are potentially harmful.
9+
*/
10+
create(body: ModerationCreateParams, options?: Core.RequestOptions): Core.APIPromise<CreateResponse> {
11+
return this._client.post('/v1/openai/v1/moderations', { body, ...options });
12+
}
13+
}
14+
15+
/**
16+
* A moderation object.
17+
*/
18+
export interface CreateResponse {
19+
/**
20+
* The unique identifier for the moderation request.
21+
*/
22+
id: string;
23+
24+
/**
25+
* The model used to generate the moderation results.
26+
*/
27+
model: string;
28+
29+
/**
30+
* A list of moderation objects
31+
*/
32+
results: Array<CreateResponse.Result>;
33+
}
34+
35+
export namespace CreateResponse {
36+
/**
37+
* A moderation object.
38+
*/
39+
export interface Result {
40+
/**
41+
* Whether any of the below categories are flagged.
42+
*/
43+
flagged: boolean;
44+
45+
metadata: { [key: string]: boolean | number | string | Array<unknown> | unknown | null };
46+
47+
/**
48+
* A list of the categories, and whether they are flagged or not.
49+
*/
50+
categories?: { [key: string]: boolean };
51+
52+
/**
53+
* A list of the categories along with the input type(s) that the score applies to.
54+
*/
55+
category_applied_input_types?: { [key: string]: Array<string> };
56+
57+
/**
58+
* A list of the categories along with their scores as predicted by model. Required
59+
* set of categories that need to be in response - violence - violence/graphic -
60+
* harassment - harassment/threatening - hate - hate/threatening - illicit -
61+
* illicit/violent - sexual - sexual/minors - self-harm - self-harm/intent -
62+
* self-harm/instructions
63+
*/
64+
category_scores?: { [key: string]: number };
65+
66+
user_message?: string;
67+
}
68+
}
69+
70+
export interface ModerationCreateParams {
71+
/**
72+
* Input (or inputs) to classify. Can be a single string, an array of strings, or
73+
* an array of multi-modal input objects similar to other models.
74+
*/
75+
input: string | Array<string>;
76+
77+
/**
78+
* The content moderation model you would like to use.
79+
*/
80+
model: string;
81+
}
82+
83+
export declare namespace Moderations {
84+
export { type CreateResponse as CreateResponse, type ModerationCreateParams as ModerationCreateParams };
85+
}

src/resources/safety.ts

Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ import * as Core from '../core';
55
import * as Shared from './shared';
66

77
export class Safety extends APIResource {
8-
/**
9-
* Classifies if text and/or image inputs are potentially harmful.
10-
*/
11-
create(body: SafetyCreateParams, options?: Core.RequestOptions): Core.APIPromise<CreateResponse> {
12-
return this._client.post('/v1/openai/v1/moderations', { body, ...options });
13-
}
14-
158
/**
169
* Run a shield.
1710
*/
@@ -20,61 +13,6 @@ export class Safety extends APIResource {
2013
}
2114
}
2215

23-
/**
24-
* A moderation object.
25-
*/
26-
export interface CreateResponse {
27-
/**
28-
* The unique identifier for the moderation request.
29-
*/
30-
id: string;
31-
32-
/**
33-
* The model used to generate the moderation results.
34-
*/
35-
model: string;
36-
37-
/**
38-
* A list of moderation objects
39-
*/
40-
results: Array<CreateResponse.Result>;
41-
}
42-
43-
export namespace CreateResponse {
44-
/**
45-
* A moderation object.
46-
*/
47-
export interface Result {
48-
/**
49-
* Whether any of the below categories are flagged.
50-
*/
51-
flagged: boolean;
52-
53-
metadata: { [key: string]: boolean | number | string | Array<unknown> | unknown | null };
54-
55-
/**
56-
* A list of the categories, and whether they are flagged or not.
57-
*/
58-
categories?: { [key: string]: boolean };
59-
60-
/**
61-
* A list of the categories along with the input type(s) that the score applies to.
62-
*/
63-
category_applied_input_types?: { [key: string]: Array<string> };
64-
65-
/**
66-
* A list of the categories along with their scores as predicted by model. Required
67-
* set of categories that need to be in response - violence - violence/graphic -
68-
* harassment - harassment/threatening - hate - hate/threatening - illicit -
69-
* illicit/violent - sexual - sexual/minors - self-harm - self-harm/intent -
70-
* self-harm/instructions
71-
*/
72-
category_scores?: { [key: string]: number };
73-
74-
user_message?: string;
75-
}
76-
}
77-
7816
/**
7917
* Response from running a safety shield.
8018
*/
@@ -85,19 +23,6 @@ export interface RunShieldResponse {
8523
violation?: Shared.SafetyViolation;
8624
}
8725

88-
export interface SafetyCreateParams {
89-
/**
90-
* Input (or inputs) to classify. Can be a single string, an array of strings, or
91-
* an array of multi-modal input objects similar to other models.
92-
*/
93-
input: string | Array<string>;
94-
95-
/**
96-
* The content moderation model you would like to use.
97-
*/
98-
model: string;
99-
}
100-
10126
export interface SafetyRunShieldParams {
10227
/**
10328
* The messages to run the shield on.
@@ -116,10 +41,5 @@ export interface SafetyRunShieldParams {
11641
}
11742

11843
export declare namespace Safety {
119-
export {
120-
type CreateResponse as CreateResponse,
121-
type RunShieldResponse as RunShieldResponse,
122-
type SafetyCreateParams as SafetyCreateParams,
123-
type SafetyRunShieldParams as SafetyRunShieldParams,
124-
};
44+
export { type RunShieldResponse as RunShieldResponse, type SafetyRunShieldParams as SafetyRunShieldParams };
12545
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import LlamaStackClient from 'llama-stack-client';
4+
import { Response } from 'node-fetch';
5+
6+
const client = new LlamaStackClient({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
7+
8+
describe('resource moderations', () => {
9+
test('create: only required params', async () => {
10+
const responsePromise = client.moderations.create({ input: 'string', model: 'model' });
11+
const rawResponse = await responsePromise.asResponse();
12+
expect(rawResponse).toBeInstanceOf(Response);
13+
const response = await responsePromise;
14+
expect(response).not.toBeInstanceOf(Response);
15+
const dataAndResponse = await responsePromise.withResponse();
16+
expect(dataAndResponse.data).toBe(response);
17+
expect(dataAndResponse.response).toBe(rawResponse);
18+
});
19+
20+
test('create: required and optional params', async () => {
21+
const response = await client.moderations.create({ input: 'string', model: 'model' });
22+
});
23+
});

tests/api-resources/safety.test.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,6 @@ import { Response } from 'node-fetch';
66
const client = new LlamaStackClient({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
77

88
describe('resource safety', () => {
9-
test('create: only required params', async () => {
10-
const responsePromise = client.safety.create({ input: 'string', model: 'model' });
11-
const rawResponse = await responsePromise.asResponse();
12-
expect(rawResponse).toBeInstanceOf(Response);
13-
const response = await responsePromise;
14-
expect(response).not.toBeInstanceOf(Response);
15-
const dataAndResponse = await responsePromise.withResponse();
16-
expect(dataAndResponse.data).toBe(response);
17-
expect(dataAndResponse.response).toBe(rawResponse);
18-
});
19-
20-
test('create: required and optional params', async () => {
21-
const response = await client.safety.create({ input: 'string', model: 'model' });
22-
});
23-
249
test('runShield: only required params', async () => {
2510
const responsePromise = client.safety.runShield({
2611
messages: [{ content: 'string', role: 'user' }],

0 commit comments

Comments
 (0)