Skip to content

Commit 90b238c

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
chore(docs): fix incorrect client var names (#186)
1 parent 9dc66dd commit 90b238c

File tree

5 files changed

+63
-68
lines changed

5 files changed

+63
-68
lines changed

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const client = new PromptFoundry({
149149
});
150150

151151
async function main() {
152-
const modelParameters: PromptFoundry.ModelParameters = await promptFoundry.prompts.getParameters('1212121');
152+
const modelParameters: PromptFoundry.ModelParameters = await client.prompts.getParameters('1212121');
153153
}
154154

155155
main();
@@ -166,7 +166,7 @@ a subclass of `APIError` will be thrown:
166166
<!-- prettier-ignore -->
167167
```ts
168168
async function main() {
169-
const modelParameters = await promptFoundry.prompts.getParameters('1212121').catch(async (err) => {
169+
const modelParameters = await client.prompts.getParameters('1212121').catch(async (err) => {
170170
if (err instanceof PromptFoundry.APIError) {
171171
console.log(err.status); // 400
172172
console.log(err.name); // BadRequestError
@@ -209,7 +209,7 @@ const client = new PromptFoundry({
209209
});
210210

211211
// Or, configure per-request:
212-
await promptFoundry.prompts.getParameters('1212121', {
212+
await client.prompts.getParameters('1212121', {
213213
maxRetries: 5,
214214
});
215215
```
@@ -226,7 +226,7 @@ const client = new PromptFoundry({
226226
});
227227

228228
// Override per-request:
229-
await promptFoundry.prompts.getParameters('1212121', {
229+
await client.prompts.getParameters('1212121', {
230230
timeout: 5 * 1000,
231231
});
232232
```
@@ -247,13 +247,11 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
247247
```ts
248248
const client = new PromptFoundry();
249249

250-
const response = await promptFoundry.prompts.getParameters('1212121').asResponse();
250+
const response = await client.prompts.getParameters('1212121').asResponse();
251251
console.log(response.headers.get('X-My-Header'));
252252
console.log(response.statusText); // access the underlying Response object
253253

254-
const { data: modelParameters, response: raw } = await promptFoundry.prompts
255-
.getParameters('1212121')
256-
.withResponse();
254+
const { data: modelParameters, response: raw } = await client.prompts.getParameters('1212121').withResponse();
257255
console.log(raw.headers.get('X-My-Header'));
258256
console.log(modelParameters);
259257
```
@@ -359,7 +357,7 @@ const client = new PromptFoundry({
359357
});
360358

361359
// Override per-request:
362-
await promptFoundry.prompts.getParameters('1212121', {
360+
await client.prompts.getParameters('1212121', {
363361
httpAgent: new http.Agent({ keepAlive: false }),
364362
});
365363
```

tests/api-resources/evaluation-assertions.test.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import PromptFoundry from '@prompt-foundry/typescript-sdk';
44
import { Response } from 'node-fetch';
55

6-
const promptFoundry = new PromptFoundry({
6+
const client = new PromptFoundry({
77
apiKey: 'My API Key',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});
1010

1111
describe('resource evaluationAssertions', () => {
1212
test('create: only required params', async () => {
13-
const responsePromise = promptFoundry.evaluationAssertions.create({
13+
const responsePromise = client.evaluationAssertions.create({
1414
evaluationId: 'evaluationId',
1515
targetValue: 'targetValue',
1616
type: 'EXACT_MATCH',
@@ -25,7 +25,7 @@ describe('resource evaluationAssertions', () => {
2525
});
2626

2727
test('create: required and optional params', async () => {
28-
const response = await promptFoundry.evaluationAssertions.create({
28+
const response = await client.evaluationAssertions.create({
2929
evaluationId: 'evaluationId',
3030
targetValue: 'targetValue',
3131
type: 'EXACT_MATCH',
@@ -37,7 +37,7 @@ describe('resource evaluationAssertions', () => {
3737
});
3838

3939
test('update: only required params', async () => {
40-
const responsePromise = promptFoundry.evaluationAssertions.update('1212121', {
40+
const responsePromise = client.evaluationAssertions.update('1212121', {
4141
evaluationId: 'evaluationId',
4242
targetValue: 'targetValue',
4343
type: 'EXACT_MATCH',
@@ -52,7 +52,7 @@ describe('resource evaluationAssertions', () => {
5252
});
5353

5454
test('update: required and optional params', async () => {
55-
const response = await promptFoundry.evaluationAssertions.update('1212121', {
55+
const response = await client.evaluationAssertions.update('1212121', {
5656
evaluationId: 'evaluationId',
5757
targetValue: 'targetValue',
5858
type: 'EXACT_MATCH',
@@ -64,7 +64,7 @@ describe('resource evaluationAssertions', () => {
6464
});
6565

6666
test('list', async () => {
67-
const responsePromise = promptFoundry.evaluationAssertions.list();
67+
const responsePromise = client.evaluationAssertions.list();
6868
const rawResponse = await responsePromise.asResponse();
6969
expect(rawResponse).toBeInstanceOf(Response);
7070
const response = await responsePromise;
@@ -76,23 +76,20 @@ describe('resource evaluationAssertions', () => {
7676

7777
test('list: request options instead of params are passed correctly', async () => {
7878
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
79-
await expect(
80-
promptFoundry.evaluationAssertions.list({ path: '/_stainless_unknown_path' }),
81-
).rejects.toThrow(PromptFoundry.NotFoundError);
79+
await expect(client.evaluationAssertions.list({ path: '/_stainless_unknown_path' })).rejects.toThrow(
80+
PromptFoundry.NotFoundError,
81+
);
8282
});
8383

8484
test('list: request options and params are passed correctly', async () => {
8585
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
8686
await expect(
87-
promptFoundry.evaluationAssertions.list(
88-
{ evaluationId: 'eval-1234' },
89-
{ path: '/_stainless_unknown_path' },
90-
),
87+
client.evaluationAssertions.list({ evaluationId: 'eval-1234' }, { path: '/_stainless_unknown_path' }),
9188
).rejects.toThrow(PromptFoundry.NotFoundError);
9289
});
9390

9491
test('delete', async () => {
95-
const responsePromise = promptFoundry.evaluationAssertions.delete('1212121');
92+
const responsePromise = client.evaluationAssertions.delete('1212121');
9693
const rawResponse = await responsePromise.asResponse();
9794
expect(rawResponse).toBeInstanceOf(Response);
9895
const response = await responsePromise;
@@ -105,12 +102,12 @@ describe('resource evaluationAssertions', () => {
105102
test('delete: request options instead of params are passed correctly', async () => {
106103
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
107104
await expect(
108-
promptFoundry.evaluationAssertions.delete('1212121', { path: '/_stainless_unknown_path' }),
105+
client.evaluationAssertions.delete('1212121', { path: '/_stainless_unknown_path' }),
109106
).rejects.toThrow(PromptFoundry.NotFoundError);
110107
});
111108

112109
test('get', async () => {
113-
const responsePromise = promptFoundry.evaluationAssertions.get('1212121');
110+
const responsePromise = client.evaluationAssertions.get('1212121');
114111
const rawResponse = await responsePromise.asResponse();
115112
expect(rawResponse).toBeInstanceOf(Response);
116113
const response = await responsePromise;
@@ -123,7 +120,7 @@ describe('resource evaluationAssertions', () => {
123120
test('get: request options instead of params are passed correctly', async () => {
124121
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
125122
await expect(
126-
promptFoundry.evaluationAssertions.get('1212121', { path: '/_stainless_unknown_path' }),
123+
client.evaluationAssertions.get('1212121', { path: '/_stainless_unknown_path' }),
127124
).rejects.toThrow(PromptFoundry.NotFoundError);
128125
});
129126
});

tests/api-resources/evaluations.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import PromptFoundry from '@prompt-foundry/typescript-sdk';
44
import { Response } from 'node-fetch';
55

6-
const promptFoundry = new PromptFoundry({
6+
const client = new PromptFoundry({
77
apiKey: 'My API Key',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});
1010

1111
describe('resource evaluations', () => {
1212
test('create: only required params', async () => {
13-
const responsePromise = promptFoundry.evaluations.create({
13+
const responsePromise = client.evaluations.create({
1414
appendedMessages: [
1515
{
1616
content: [
@@ -50,7 +50,7 @@ describe('resource evaluations', () => {
5050
});
5151

5252
test('create: required and optional params', async () => {
53-
const response = await promptFoundry.evaluations.create({
53+
const response = await client.evaluations.create({
5454
appendedMessages: [
5555
{
5656
content: [
@@ -85,7 +85,7 @@ describe('resource evaluations', () => {
8585
});
8686

8787
test('update: only required params', async () => {
88-
const responsePromise = promptFoundry.evaluations.update('1212121', {
88+
const responsePromise = client.evaluations.update('1212121', {
8989
appendedMessages: [
9090
{
9191
content: [
@@ -125,7 +125,7 @@ describe('resource evaluations', () => {
125125
});
126126

127127
test('update: required and optional params', async () => {
128-
const response = await promptFoundry.evaluations.update('1212121', {
128+
const response = await client.evaluations.update('1212121', {
129129
appendedMessages: [
130130
{
131131
content: [
@@ -160,7 +160,7 @@ describe('resource evaluations', () => {
160160
});
161161

162162
test('list', async () => {
163-
const responsePromise = promptFoundry.evaluations.list();
163+
const responsePromise = client.evaluations.list();
164164
const rawResponse = await responsePromise.asResponse();
165165
expect(rawResponse).toBeInstanceOf(Response);
166166
const response = await responsePromise;
@@ -172,13 +172,13 @@ describe('resource evaluations', () => {
172172

173173
test('list: request options instead of params are passed correctly', async () => {
174174
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
175-
await expect(promptFoundry.evaluations.list({ path: '/_stainless_unknown_path' })).rejects.toThrow(
175+
await expect(client.evaluations.list({ path: '/_stainless_unknown_path' })).rejects.toThrow(
176176
PromptFoundry.NotFoundError,
177177
);
178178
});
179179

180180
test('delete', async () => {
181-
const responsePromise = promptFoundry.evaluations.delete('1212121');
181+
const responsePromise = client.evaluations.delete('1212121');
182182
const rawResponse = await responsePromise.asResponse();
183183
expect(rawResponse).toBeInstanceOf(Response);
184184
const response = await responsePromise;
@@ -190,13 +190,13 @@ describe('resource evaluations', () => {
190190

191191
test('delete: request options instead of params are passed correctly', async () => {
192192
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
193-
await expect(
194-
promptFoundry.evaluations.delete('1212121', { path: '/_stainless_unknown_path' }),
195-
).rejects.toThrow(PromptFoundry.NotFoundError);
193+
await expect(client.evaluations.delete('1212121', { path: '/_stainless_unknown_path' })).rejects.toThrow(
194+
PromptFoundry.NotFoundError,
195+
);
196196
});
197197

198198
test('get', async () => {
199-
const responsePromise = promptFoundry.evaluations.get('1212121');
199+
const responsePromise = client.evaluations.get('1212121');
200200
const rawResponse = await responsePromise.asResponse();
201201
expect(rawResponse).toBeInstanceOf(Response);
202202
const response = await responsePromise;
@@ -208,8 +208,8 @@ describe('resource evaluations', () => {
208208

209209
test('get: request options instead of params are passed correctly', async () => {
210210
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
211-
await expect(
212-
promptFoundry.evaluations.get('1212121', { path: '/_stainless_unknown_path' }),
213-
).rejects.toThrow(PromptFoundry.NotFoundError);
211+
await expect(client.evaluations.get('1212121', { path: '/_stainless_unknown_path' })).rejects.toThrow(
212+
PromptFoundry.NotFoundError,
213+
);
214214
});
215215
});

tests/api-resources/prompts.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import PromptFoundry from '@prompt-foundry/typescript-sdk';
44
import { Response } from 'node-fetch';
55

6-
const promptFoundry = new PromptFoundry({
6+
const client = new PromptFoundry({
77
apiKey: 'My API Key',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});
1010

1111
describe('resource prompts', () => {
1212
test('create: only required params', async () => {
13-
const responsePromise = promptFoundry.prompts.create({
13+
const responsePromise = client.prompts.create({
1414
messages: [
1515
{
1616
content: [
@@ -68,7 +68,7 @@ describe('resource prompts', () => {
6868
});
6969

7070
test('create: required and optional params', async () => {
71-
const response = await promptFoundry.prompts.create({
71+
const response = await client.prompts.create({
7272
messages: [
7373
{
7474
content: [
@@ -119,7 +119,7 @@ describe('resource prompts', () => {
119119
});
120120

121121
test('update: only required params', async () => {
122-
const responsePromise = promptFoundry.prompts.update('1212121', {
122+
const responsePromise = client.prompts.update('1212121', {
123123
messages: [
124124
{
125125
content: [
@@ -177,7 +177,7 @@ describe('resource prompts', () => {
177177
});
178178

179179
test('update: required and optional params', async () => {
180-
const response = await promptFoundry.prompts.update('1212121', {
180+
const response = await client.prompts.update('1212121', {
181181
messages: [
182182
{
183183
content: [
@@ -228,7 +228,7 @@ describe('resource prompts', () => {
228228
});
229229

230230
test('list', async () => {
231-
const responsePromise = promptFoundry.prompts.list();
231+
const responsePromise = client.prompts.list();
232232
const rawResponse = await responsePromise.asResponse();
233233
expect(rawResponse).toBeInstanceOf(Response);
234234
const response = await responsePromise;
@@ -240,13 +240,13 @@ describe('resource prompts', () => {
240240

241241
test('list: request options instead of params are passed correctly', async () => {
242242
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
243-
await expect(promptFoundry.prompts.list({ path: '/_stainless_unknown_path' })).rejects.toThrow(
243+
await expect(client.prompts.list({ path: '/_stainless_unknown_path' })).rejects.toThrow(
244244
PromptFoundry.NotFoundError,
245245
);
246246
});
247247

248248
test('delete', async () => {
249-
const responsePromise = promptFoundry.prompts.delete('1212121');
249+
const responsePromise = client.prompts.delete('1212121');
250250
const rawResponse = await responsePromise.asResponse();
251251
expect(rawResponse).toBeInstanceOf(Response);
252252
const response = await responsePromise;
@@ -258,13 +258,13 @@ describe('resource prompts', () => {
258258

259259
test('delete: request options instead of params are passed correctly', async () => {
260260
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
261-
await expect(
262-
promptFoundry.prompts.delete('1212121', { path: '/_stainless_unknown_path' }),
263-
).rejects.toThrow(PromptFoundry.NotFoundError);
261+
await expect(client.prompts.delete('1212121', { path: '/_stainless_unknown_path' })).rejects.toThrow(
262+
PromptFoundry.NotFoundError,
263+
);
264264
});
265265

266266
test('get', async () => {
267-
const responsePromise = promptFoundry.prompts.get('1212121');
267+
const responsePromise = client.prompts.get('1212121');
268268
const rawResponse = await responsePromise.asResponse();
269269
expect(rawResponse).toBeInstanceOf(Response);
270270
const response = await responsePromise;
@@ -276,13 +276,13 @@ describe('resource prompts', () => {
276276

277277
test('get: request options instead of params are passed correctly', async () => {
278278
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
279-
await expect(promptFoundry.prompts.get('1212121', { path: '/_stainless_unknown_path' })).rejects.toThrow(
279+
await expect(client.prompts.get('1212121', { path: '/_stainless_unknown_path' })).rejects.toThrow(
280280
PromptFoundry.NotFoundError,
281281
);
282282
});
283283

284284
test('getParameters', async () => {
285-
const responsePromise = promptFoundry.prompts.getParameters('1212121');
285+
const responsePromise = client.prompts.getParameters('1212121');
286286
const rawResponse = await responsePromise.asResponse();
287287
expect(rawResponse).toBeInstanceOf(Response);
288288
const response = await responsePromise;
@@ -295,14 +295,14 @@ describe('resource prompts', () => {
295295
test('getParameters: request options instead of params are passed correctly', async () => {
296296
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
297297
await expect(
298-
promptFoundry.prompts.getParameters('1212121', { path: '/_stainless_unknown_path' }),
298+
client.prompts.getParameters('1212121', { path: '/_stainless_unknown_path' }),
299299
).rejects.toThrow(PromptFoundry.NotFoundError);
300300
});
301301

302302
test('getParameters: request options and params are passed correctly', async () => {
303303
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
304304
await expect(
305-
promptFoundry.prompts.getParameters(
305+
client.prompts.getParameters(
306306
'1212121',
307307
{
308308
appendMessages: [

0 commit comments

Comments
 (0)