Skip to content

Commit 08c54a3

Browse files
authored
Sync updates from stainless branch: main (#15)
* Sync updates from stainless branch: main * fix agent test
1 parent 0630f1f commit 08c54a3

File tree

14 files changed

+55
-157
lines changed

14 files changed

+55
-157
lines changed

examples/agents.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ describe('RAG Integration Tests', () => {
6060
for await (const chunk of turnResponse) {
6161
if (chunk.event.payload.event_type === 'turn_complete') {
6262
expect(chunk.event.payload.turn.output_message).toBeTruthy();
63-
break;
6463
}
6564
}
6665
}

src/core.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ async function defaultParseResponse<T>(props: APIResponseProps): Promise<T> {
6262
}
6363

6464
const contentType = response.headers.get('content-type');
65-
const isJSON =
66-
contentType?.includes('application/json') || contentType?.includes('application/vnd.api+json');
65+
const mediaType = contentType?.split(';')[0]?.trim();
66+
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
6767
if (isJSON) {
6868
const json = await response.json();
6969

src/resources/agents.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
export * from './agents/index';

src/resources/agents/turn.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,9 @@ export type TurnResumeParams = TurnResumeParamsNonStreaming | TurnResumeParamsSt
482482

483483
export interface TurnResumeParamsBase {
484484
/**
485-
* The tool call responses to resume the turn with. NOTE: ToolResponseMessage will
486-
* be deprecated. Use ToolResponse.
485+
* The tool call responses to resume the turn with.
487486
*/
488-
tool_responses: Array<AgentsAPI.ToolResponse> | Array<Shared.ToolResponseMessage>;
487+
tool_responses: Array<AgentsAPI.ToolResponse>;
489488

490489
/**
491490
* Whether to stream the response.

src/resources/eval-tasks.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/resources/eval.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
export * from './eval/index';

src/resources/inference.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,9 @@ export namespace ChatCompletionResponseStreamChunk {
113113
export interface Metric {
114114
metric: string;
115115

116-
span_id: string;
117-
118-
timestamp: string;
119-
120-
trace_id: string;
121-
122-
type: 'metric';
123-
124-
unit: string;
125-
126116
value: number;
127117

128-
attributes?: Record<string, string | number | boolean | null>;
118+
unit?: string;
129119
}
130120
}
131121

@@ -147,6 +137,18 @@ export interface CompletionResponse {
147137
* Optional log probabilities for generated tokens
148138
*/
149139
logprobs?: Array<TokenLogProbs>;
140+
141+
metrics?: Array<CompletionResponse.Metric>;
142+
}
143+
144+
export namespace CompletionResponse {
145+
export interface Metric {
146+
metric: string;
147+
148+
value: number;
149+
150+
unit?: string;
151+
}
150152
}
151153

152154
/**

src/resources/inspect.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export interface HealthInfo {
2020
export interface ProviderInfo {
2121
api: string;
2222

23+
config: Record<string, boolean | number | string | Array<unknown> | unknown | null>;
24+
2325
provider_id: string;
2426

2527
provider_type: string;

src/resources/post-training.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
export * from './post-training/index';

src/resources/providers.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ import * as Core from '../core';
55
import * as InspectAPI from './inspect';
66

77
export class Providers extends APIResource {
8+
retrieve(providerId: string, options?: Core.RequestOptions): Core.APIPromise<InspectAPI.ProviderInfo> {
9+
return this._client.get(`/v1/providers/${providerId}`, options);
10+
}
11+
812
list(options?: Core.RequestOptions): Core.APIPromise<ProviderListResponse> {
913
return (
10-
this._client.get('/v1/inspect/providers', options) as Core.APIPromise<{ data: ProviderListResponse }>
14+
this._client.get('/v1/providers', options) as Core.APIPromise<{ data: ProviderListResponse }>
1115
)._thenUnwrap((obj) => obj.data);
1216
}
1317
}

src/resources/shared.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,9 @@ export namespace ChatCompletionResponse {
110110
export interface Metric {
111111
metric: string;
112112

113-
span_id: string;
114-
115-
timestamp: string;
116-
117-
trace_id: string;
118-
119-
type: 'metric';
120-
121-
unit: string;
122-
123113
value: number;
124114

125-
attributes?: Record<string, string | number | boolean | null>;
115+
unit?: string;
126116
}
127117
}
128118

@@ -663,11 +653,6 @@ export interface ToolResponseMessage {
663653
* Must be "tool" to identify this as a tool response
664654
*/
665655
role: 'tool';
666-
667-
/**
668-
* Name of the tool that was called
669-
*/
670-
tool_name: 'brave_search' | 'wolfram_alpha' | 'photogen' | 'code_interpreter' | (string & {});
671656
}
672657

673658
/**

src/resources/tool-runtime.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
export * from './tool-runtime/index';

tests/api-resources/eval-tasks.test.ts

Lines changed: 0 additions & 70 deletions
This file was deleted.

tests/api-resources/providers.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@ 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 providers', () => {
9+
test('retrieve', async () => {
10+
const responsePromise = client.providers.retrieve('provider_id');
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('retrieve: request options instead of params are passed correctly', async () => {
21+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
22+
await expect(
23+
client.providers.retrieve('provider_id', { path: '/_stainless_unknown_path' }),
24+
).rejects.toThrow(LlamaStackClient.NotFoundError);
25+
});
26+
927
test('list', async () => {
1028
const responsePromise = client.providers.list();
1129
const rawResponse = await responsePromise.asResponse();

0 commit comments

Comments
 (0)