Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/agents.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ describe('RAG Integration Tests', () => {
for await (const chunk of turnResponse) {
if (chunk.event.payload.event_type === 'turn_complete') {
expect(chunk.event.payload.turn.output_message).toBeTruthy();
break;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ async function defaultParseResponse<T>(props: APIResponseProps): Promise<T> {
}

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

Expand Down
3 changes: 3 additions & 0 deletions src/resources/agents.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export * from './agents/index';
5 changes: 2 additions & 3 deletions src/resources/agents/turn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,9 @@ export type TurnResumeParams = TurnResumeParamsNonStreaming | TurnResumeParamsSt

export interface TurnResumeParamsBase {
/**
* The tool call responses to resume the turn with. NOTE: ToolResponseMessage will
* be deprecated. Use ToolResponse.
* The tool call responses to resume the turn with.
*/
tool_responses: Array<AgentsAPI.ToolResponse> | Array<Shared.ToolResponseMessage>;
tool_responses: Array<AgentsAPI.ToolResponse>;

/**
* Whether to stream the response.
Expand Down
53 changes: 0 additions & 53 deletions src/resources/eval-tasks.ts

This file was deleted.

3 changes: 3 additions & 0 deletions src/resources/eval.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export * from './eval/index';
24 changes: 13 additions & 11 deletions src/resources/inference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,9 @@ export namespace ChatCompletionResponseStreamChunk {
export interface Metric {
metric: string;

span_id: string;

timestamp: string;

trace_id: string;

type: 'metric';

unit: string;

value: number;

attributes?: Record<string, string | number | boolean | null>;
unit?: string;
}
}

Expand All @@ -147,6 +137,18 @@ export interface CompletionResponse {
* Optional log probabilities for generated tokens
*/
logprobs?: Array<TokenLogProbs>;

metrics?: Array<CompletionResponse.Metric>;
}

export namespace CompletionResponse {
export interface Metric {
metric: string;

value: number;

unit?: string;
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/resources/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export interface HealthInfo {
export interface ProviderInfo {
api: string;

config: Record<string, boolean | number | string | Array<unknown> | unknown | null>;

provider_id: string;

provider_type: string;
Expand Down
3 changes: 3 additions & 0 deletions src/resources/post-training.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export * from './post-training/index';
6 changes: 5 additions & 1 deletion src/resources/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import * as Core from '../core';
import * as InspectAPI from './inspect';

export class Providers extends APIResource {
retrieve(providerId: string, options?: Core.RequestOptions): Core.APIPromise<InspectAPI.ProviderInfo> {
return this._client.get(`/v1/providers/${providerId}`, options);
}

list(options?: Core.RequestOptions): Core.APIPromise<ProviderListResponse> {
return (
this._client.get('/v1/inspect/providers', options) as Core.APIPromise<{ data: ProviderListResponse }>
this._client.get('/v1/providers', options) as Core.APIPromise<{ data: ProviderListResponse }>
)._thenUnwrap((obj) => obj.data);
}
}
Expand Down
17 changes: 1 addition & 16 deletions src/resources/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,9 @@ export namespace ChatCompletionResponse {
export interface Metric {
metric: string;

span_id: string;

timestamp: string;

trace_id: string;

type: 'metric';

unit: string;

value: number;

attributes?: Record<string, string | number | boolean | null>;
unit?: string;
}
}

Expand Down Expand Up @@ -663,11 +653,6 @@ export interface ToolResponseMessage {
* Must be "tool" to identify this as a tool response
*/
role: 'tool';

/**
* Name of the tool that was called
*/
tool_name: 'brave_search' | 'wolfram_alpha' | 'photogen' | 'code_interpreter' | (string & {});
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/resources/tool-runtime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export * from './tool-runtime/index';
70 changes: 0 additions & 70 deletions tests/api-resources/eval-tasks.test.ts

This file was deleted.

18 changes: 18 additions & 0 deletions tests/api-resources/providers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ import { Response } from 'node-fetch';
const client = new LlamaStackClient({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });

describe('resource providers', () => {
test('retrieve', async () => {
const responsePromise = client.providers.retrieve('provider_id');
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
expect(response).not.toBeInstanceOf(Response);
const dataAndResponse = await responsePromise.withResponse();
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});

test('retrieve: request options instead of params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
client.providers.retrieve('provider_id', { path: '/_stainless_unknown_path' }),
).rejects.toThrow(LlamaStackClient.NotFoundError);
});

test('list', async () => {
const responsePromise = client.providers.list();
const rawResponse = await responsePromise.asResponse();
Expand Down