Skip to content

Commit cd15af0

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): OpenAPI spec update via Stainless API (#18)
1 parent f908edb commit cd15af0

File tree

13 files changed

+262
-139
lines changed

13 files changed

+262
-139
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 50
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/julep-ai-inc-dash%2Fjulep-6a1e46c04a25dba0557ccbab92a9b9ccfbdb804849b91a8a780949c771321b12.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/julep-ai-inc-dash%2Fjulep-f81af3213db01ef83d8f104374a7f47b8d46c3817e26d587a555ae05f2cae02c.yml

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Methods:
6969
- <code title="get /sessions">client.sessions.<a href="./src/resources/sessions.ts">list</a>({ ...params }) -> SessionsOffsetPagination</code>
7070
- <code title="delete /sessions/{session_id}">client.sessions.<a href="./src/resources/sessions.ts">delete</a>(sessionId) -> ResourceDeleted</code>
7171
- <code title="post /sessions/{session_id}/chat">client.sessions.<a href="./src/resources/sessions.ts">chat</a>(sessionId, { ...params }) -> SessionChatResponse</code>
72-
- <code title="post /sessions/{session_id}">client.sessions.<a href="./src/resources/sessions.ts">createOrUpdate</a>(sessionId, { ...params }) -> ResourceCreated</code>
72+
- <code title="post /sessions/{session_id}">client.sessions.<a href="./src/resources/sessions.ts">createOrUpdate</a>(sessionId, { ...params }) -> ResourceUpdated</code>
7373
- <code title="get /sessions/{session_id}">client.sessions.<a href="./src/resources/sessions.ts">get</a>(sessionId) -> Session</code>
7474
- <code title="get /sessions/{session_id}/history">client.sessions.<a href="./src/resources/sessions.ts">history</a>(sessionId) -> History</code>
7575
- <code title="patch /sessions/{session_id}">client.sessions.<a href="./src/resources/sessions.ts">patch</a>(sessionId, { ...params }) -> ResourceUpdated</code>

src/resources/sessions.ts

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,18 @@ export class Sessions extends APIResource {
5757
*/
5858
chat(
5959
sessionId: string,
60-
body: SessionChatParams,
60+
params: SessionChatParams,
6161
options?: Core.RequestOptions,
6262
): Core.APIPromise<SessionChatResponse> {
63-
return this._client.post(`/sessions/${sessionId}/chat`, { body, ...options });
63+
const { 'X-Custom-Api-Key': xCustomAPIKey, ...body } = params;
64+
return this._client.post(`/sessions/${sessionId}/chat`, {
65+
body,
66+
...options,
67+
headers: {
68+
...(xCustomAPIKey != null ? { 'X-Custom-Api-Key': xCustomAPIKey } : undefined),
69+
...options?.headers,
70+
},
71+
});
6472
}
6573

6674
/**
@@ -70,7 +78,7 @@ export class Sessions extends APIResource {
7078
sessionId: string,
7179
body: SessionCreateOrUpdateParams,
7280
options?: Core.RequestOptions,
73-
): Core.APIPromise<Shared.ResourceCreated> {
81+
): Core.APIPromise<Shared.ResourceUpdated> {
7482
return this._client.post(`/sessions/${sessionId}`, { body, ...options });
7583
}
7684

@@ -1005,48 +1013,113 @@ export interface SessionListParams extends OffsetPaginationParams {
10051013
}
10061014

10071015
export interface SessionChatParams {
1016+
/**
1017+
* Body param:
1018+
*/
10081019
messages: Array<Message>;
10091020

1021+
/**
1022+
* Body param:
1023+
*/
10101024
agent?: string | null;
10111025

1026+
/**
1027+
* Body param:
1028+
*/
10121029
frequency_penalty?: number | null;
10131030

1031+
/**
1032+
* Body param:
1033+
*/
10141034
length_penalty?: number | null;
10151035

1036+
/**
1037+
* Body param:
1038+
*/
10161039
logit_bias?: Record<string, number> | null;
10171040

1041+
/**
1042+
* Body param:
1043+
*/
10181044
max_tokens?: number | null;
10191045

1046+
/**
1047+
* Body param:
1048+
*/
10201049
min_p?: number | null;
10211050

1051+
/**
1052+
* Body param:
1053+
*/
10221054
model?: string | null;
10231055

1056+
/**
1057+
* Body param:
1058+
*/
10241059
presence_penalty?: number | null;
10251060

1061+
/**
1062+
* Body param:
1063+
*/
10261064
recall?: boolean;
10271065

1066+
/**
1067+
* Body param:
1068+
*/
10281069
repetition_penalty?: number | null;
10291070

1071+
/**
1072+
* Body param:
1073+
*/
10301074
response_format?:
10311075
| SessionChatParams.SimpleCompletionResponseFormat
10321076
| SessionChatParams.SchemaCompletionResponseFormat
10331077
| null;
10341078

1079+
/**
1080+
* Body param:
1081+
*/
10351082
save?: boolean;
10361083

1084+
/**
1085+
* Body param:
1086+
*/
10371087
seed?: number | null;
10381088

1089+
/**
1090+
* Body param:
1091+
*/
10391092
stop?: Array<string>;
10401093

1094+
/**
1095+
* Body param:
1096+
*/
10411097
stream?: boolean;
10421098

1099+
/**
1100+
* Body param:
1101+
*/
10431102
temperature?: number | null;
10441103

1104+
/**
1105+
* Body param:
1106+
*/
10451107
tool_choice?: 'auto' | 'none' | SessionChatParams.NamedToolChoice | null;
10461108

1109+
/**
1110+
* Body param:
1111+
*/
10471112
tools?: Array<SessionChatParams.Tool>;
10481113

1114+
/**
1115+
* Body param:
1116+
*/
10491117
top_p?: number | null;
1118+
1119+
/**
1120+
* Header param:
1121+
*/
1122+
'X-Custom-Api-Key'?: string;
10501123
}
10511124

10521125
export namespace SessionChatParams {

tests/api-resources/agents/agents.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('resource agents', () => {
2121
});
2222

2323
test('update', async () => {
24-
const responsePromise = client.agents.update('agent_id', {});
24+
const responsePromise = client.agents.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {});
2525
const rawResponse = await responsePromise.asResponse();
2626
expect(rawResponse).toBeInstanceOf(Response);
2727
const response = await responsePromise;
@@ -60,7 +60,7 @@ describe('resource agents', () => {
6060
});
6161

6262
test('delete', async () => {
63-
const responsePromise = client.agents.delete('agent_id');
63+
const responsePromise = client.agents.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
6464
const rawResponse = await responsePromise.asResponse();
6565
expect(rawResponse).toBeInstanceOf(Response);
6666
const response = await responsePromise;
@@ -72,9 +72,9 @@ describe('resource agents', () => {
7272

7373
test('delete: request options instead of params are passed correctly', async () => {
7474
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
75-
await expect(client.agents.delete('agent_id', { path: '/_stainless_unknown_path' })).rejects.toThrow(
76-
Julep.NotFoundError,
77-
);
75+
await expect(
76+
client.agents.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }),
77+
).rejects.toThrow(Julep.NotFoundError);
7878
});
7979

8080
test('createOrUpdate', async () => {
@@ -89,7 +89,7 @@ describe('resource agents', () => {
8989
});
9090

9191
test('get', async () => {
92-
const responsePromise = client.agents.get('agent_id');
92+
const responsePromise = client.agents.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
9393
const rawResponse = await responsePromise.asResponse();
9494
expect(rawResponse).toBeInstanceOf(Response);
9595
const response = await responsePromise;
@@ -101,13 +101,13 @@ describe('resource agents', () => {
101101

102102
test('get: request options instead of params are passed correctly', async () => {
103103
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
104-
await expect(client.agents.get('agent_id', { path: '/_stainless_unknown_path' })).rejects.toThrow(
105-
Julep.NotFoundError,
106-
);
104+
await expect(
105+
client.agents.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }),
106+
).rejects.toThrow(Julep.NotFoundError);
107107
});
108108

109109
test('patch', async () => {
110-
const responsePromise = client.agents.patch('agent_id', {});
110+
const responsePromise = client.agents.patch('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {});
111111
const rawResponse = await responsePromise.asResponse();
112112
expect(rawResponse).toBeInstanceOf(Response);
113113
const response = await responsePromise;

tests/api-resources/agents/docs.test.ts

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ const client = new Julep({
1010

1111
describe('resource docs', () => {
1212
test('create: only required params', async () => {
13-
const responsePromise = client.agents.docs.create('agent_id', { content: 'string', title: 'title' });
13+
const responsePromise = client.agents.docs.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
14+
content: 'string',
15+
title: 'title',
16+
});
1417
const rawResponse = await responsePromise.asResponse();
1518
expect(rawResponse).toBeInstanceOf(Response);
1619
const response = await responsePromise;
@@ -21,15 +24,15 @@ describe('resource docs', () => {
2124
});
2225

2326
test('create: required and optional params', async () => {
24-
const response = await client.agents.docs.create('agent_id', {
27+
const response = await client.agents.docs.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
2528
content: 'string',
2629
title: 'title',
2730
metadata: {},
2831
});
2932
});
3033

3134
test('list', async () => {
32-
const responsePromise = client.agents.docs.list('agent_id');
35+
const responsePromise = client.agents.docs.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
3336
const rawResponse = await responsePromise.asResponse();
3437
expect(rawResponse).toBeInstanceOf(Response);
3538
const response = await responsePromise;
@@ -41,24 +44,27 @@ describe('resource docs', () => {
4144

4245
test('list: request options instead of params are passed correctly', async () => {
4346
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
44-
await expect(client.agents.docs.list('agent_id', { path: '/_stainless_unknown_path' })).rejects.toThrow(
45-
Julep.NotFoundError,
46-
);
47+
await expect(
48+
client.agents.docs.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }),
49+
).rejects.toThrow(Julep.NotFoundError);
4750
});
4851

4952
test('list: request options and params are passed correctly', async () => {
5053
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
5154
await expect(
5255
client.agents.docs.list(
53-
'agent_id',
56+
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
5457
{ direction: 'asc', limit: 0, metadata_filter: 'metadata_filter', offset: 0, sort_by: 'created_at' },
5558
{ path: '/_stainless_unknown_path' },
5659
),
5760
).rejects.toThrow(Julep.NotFoundError);
5861
});
5962

6063
test('delete', async () => {
61-
const responsePromise = client.agents.docs.delete('agent_id', 'doc_id');
64+
const responsePromise = client.agents.docs.delete(
65+
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
66+
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
67+
);
6268
const rawResponse = await responsePromise.asResponse();
6369
expect(rawResponse).toBeInstanceOf(Response);
6470
const response = await responsePromise;
@@ -71,12 +77,18 @@ describe('resource docs', () => {
7177
test('delete: request options instead of params are passed correctly', async () => {
7278
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
7379
await expect(
74-
client.agents.docs.delete('agent_id', 'doc_id', { path: '/_stainless_unknown_path' }),
80+
client.agents.docs.delete(
81+
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
82+
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
83+
{ path: '/_stainless_unknown_path' },
84+
),
7585
).rejects.toThrow(Julep.NotFoundError);
7686
});
7787

7888
test('search: only required params', async () => {
79-
const responsePromise = client.agents.docs.search('agent_id', { text: 'text' });
89+
const responsePromise = client.agents.docs.search('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
90+
text: 'text',
91+
});
8092
const rawResponse = await responsePromise.asResponse();
8193
expect(rawResponse).toBeInstanceOf(Response);
8294
const response = await responsePromise;
@@ -87,6 +99,10 @@ describe('resource docs', () => {
8799
});
88100

89101
test('search: required and optional params', async () => {
90-
const response = await client.agents.docs.search('agent_id', { text: 'text', lang: 'en-US', limit: 1 });
102+
const response = await client.agents.docs.search('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
103+
text: 'text',
104+
lang: 'en-US',
105+
limit: 1,
106+
});
91107
});
92108
});

tests/api-resources/docs.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('resource docs', () => {
2525
});
2626

2727
test('get', async () => {
28-
const responsePromise = client.docs.get('doc_id');
28+
const responsePromise = client.docs.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
2929
const rawResponse = await responsePromise.asResponse();
3030
expect(rawResponse).toBeInstanceOf(Response);
3131
const response = await responsePromise;
@@ -37,8 +37,8 @@ describe('resource docs', () => {
3737

3838
test('get: request options instead of params are passed correctly', async () => {
3939
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
40-
await expect(client.docs.get('doc_id', { path: '/_stainless_unknown_path' })).rejects.toThrow(
41-
Julep.NotFoundError,
42-
);
40+
await expect(
41+
client.docs.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }),
42+
).rejects.toThrow(Julep.NotFoundError);
4343
});
4444
});

0 commit comments

Comments
 (0)