Skip to content
Closed
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
7 changes: 3 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,16 @@ import {
ListEvalTasksResponse,
} from './resources/eval-tasks';
import {
ChatCompletionResponseStreamChunk,
CompletionResponse,
EmbeddingsResponse,
Inference,
InferenceChatCompletionParams,
InferenceChatCompletionParamsNonStreaming,
InferenceChatCompletionParamsStreaming,
InferenceChatCompletionResponse,
InferenceCompletionParams,
InferenceCompletionParamsNonStreaming,
InferenceCompletionParamsStreaming,
InferenceCompletionResponse,
InferenceEmbeddingsParams,
TokenLogProbs,
} from './resources/inference';
Expand Down Expand Up @@ -407,11 +406,10 @@ export declare namespace LlamaStackClient {

export {
Inference as Inference,
type ChatCompletionResponseStreamChunk as ChatCompletionResponseStreamChunk,
type CompletionResponse as CompletionResponse,
type EmbeddingsResponse as EmbeddingsResponse,
type TokenLogProbs as TokenLogProbs,
type InferenceChatCompletionResponse as InferenceChatCompletionResponse,
type InferenceCompletionResponse as InferenceCompletionResponse,
type InferenceChatCompletionParams as InferenceChatCompletionParams,
type InferenceChatCompletionParamsNonStreaming as InferenceChatCompletionParamsNonStreaming,
type InferenceChatCompletionParamsStreaming as InferenceChatCompletionParamsStreaming,
Expand Down Expand Up @@ -538,6 +536,7 @@ export declare namespace LlamaStackClient {

export type AgentConfig = API.AgentConfig;
export type BatchCompletion = API.BatchCompletion;
export type ChatCompletionResponse = API.ChatCompletionResponse;
export type CompletionMessage = API.CompletionMessage;
export type ContentDelta = API.ContentDelta;
export type Document = API.Document;
Expand Down
4 changes: 2 additions & 2 deletions src/resources/agents/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import * as StepsAPI from './steps';
import { StepRetrieveResponse, Steps } from './steps';
import * as TurnAPI from './turn';
import {
AgentTurnResponseStreamChunk,
Turn,
TurnCreateParams,
TurnCreateParamsNonStreaming,
TurnCreateParamsStreaming,
TurnCreateResponse,
TurnResource,
TurnResponseEvent,
TurnResponseEventPayload,
Expand Down Expand Up @@ -145,10 +145,10 @@ export declare namespace Agents {

export {
TurnResource as TurnResource,
type AgentTurnResponseStreamChunk as AgentTurnResponseStreamChunk,
type Turn as Turn,
type TurnResponseEvent as TurnResponseEvent,
type TurnResponseEventPayload as TurnResponseEventPayload,
type TurnCreateResponse as TurnCreateResponse,
type TurnCreateParams as TurnCreateParams,
type TurnCreateParamsNonStreaming as TurnCreateParamsNonStreaming,
type TurnCreateParamsStreaming as TurnCreateParamsStreaming,
Expand Down
2 changes: 1 addition & 1 deletion src/resources/agents/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export {
export { Steps, type StepRetrieveResponse } from './steps';
export {
TurnResource,
type AgentTurnResponseStreamChunk,
type Turn,
type TurnResponseEvent,
type TurnResponseEventPayload,
type TurnCreateResponse,
type TurnCreateParams,
type TurnCreateParamsNonStreaming,
type TurnCreateParamsStreaming,
Expand Down
69 changes: 54 additions & 15 deletions src/resources/agents/turn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,30 @@ export class TurnResource extends APIResource {
sessionId: string,
body: TurnCreateParamsNonStreaming,
options?: Core.RequestOptions,
): APIPromise<TurnCreateResponse>;
): APIPromise<Turn>;
create(
agentId: string,
sessionId: string,
body: TurnCreateParamsStreaming,
options?: Core.RequestOptions,
): APIPromise<Stream<TurnCreateResponse>>;
): APIPromise<Stream<AgentTurnResponseStreamChunk>>;
create(
agentId: string,
sessionId: string,
body: TurnCreateParamsBase,
options?: Core.RequestOptions,
): APIPromise<Stream<TurnCreateResponse> | TurnCreateResponse>;
): APIPromise<Stream<AgentTurnResponseStreamChunk> | Turn>;
create(
agentId: string,
sessionId: string,
body: TurnCreateParams,
options?: Core.RequestOptions,
): APIPromise<TurnCreateResponse> | APIPromise<Stream<TurnCreateResponse>> {
): APIPromise<Turn> | APIPromise<Stream<AgentTurnResponseStreamChunk>> {
return this._client.post(`/v1/agents/${agentId}/session/${sessionId}/turn`, {
body,
...options,
headers: { Accept: 'text/event-stream', ...options?.headers },
stream: body.stream ?? false,
}) as APIPromise<TurnCreateResponse> | APIPromise<Stream<TurnCreateResponse>>;
}) as APIPromise<Turn> | APIPromise<Stream<AgentTurnResponseStreamChunk>>;
}

retrieve(
Expand All @@ -51,6 +50,10 @@ export class TurnResource extends APIResource {
}
}

export interface AgentTurnResponseStreamChunk {
event: TurnResponseEvent;
}

export interface Turn {
input_messages: Array<Shared.UserMessage | Shared.ToolResponseMessage>;

Expand Down Expand Up @@ -88,22 +91,44 @@ export namespace Turn {

export namespace OutputAttachment {
export interface ImageContentItem {
/**
* Image as a base64 encoded string or an URL
*/
image: ImageContentItem.Image;

/**
* Discriminator type of the content item. Always "image"
*/
type: 'image';
}

export namespace ImageContentItem {
/**
* Image as a base64 encoded string or an URL
*/
export interface Image {
/**
* base64 encoded image data as string
*/
data?: string;

/**
* A URL of the image or data URL in the format of data:image/{type};base64,{data}.
* Note that URL could have length limits.
*/
url?: Shared.URL;
}
}

export interface TextContentItem {
/**
* Text content
*/
text: string;

/**
* Discriminator type of the content item. Always "text"
*/
type: 'text';
}
}
Expand Down Expand Up @@ -168,14 +193,6 @@ export namespace TurnResponseEventPayload {
}
}

export type TurnCreateResponse = Turn | TurnCreateResponse.AgentTurnResponseStreamChunk;

export namespace TurnCreateResponse {
export interface AgentTurnResponseStreamChunk {
event: TurnAPI.TurnResponseEvent;
}
}

export type TurnCreateParams = TurnCreateParamsNonStreaming | TurnCreateParamsStreaming;

export interface TurnCreateParamsBase {
Expand All @@ -202,22 +219,44 @@ export namespace TurnCreateParams {

export namespace Document {
export interface ImageContentItem {
/**
* Image as a base64 encoded string or an URL
*/
image: ImageContentItem.Image;

/**
* Discriminator type of the content item. Always "image"
*/
type: 'image';
}

export namespace ImageContentItem {
/**
* Image as a base64 encoded string or an URL
*/
export interface Image {
/**
* base64 encoded image data as string
*/
data?: string;

/**
* A URL of the image or data URL in the format of data:image/{type};base64,{data}.
* Note that URL could have length limits.
*/
url?: Shared.URL;
}
}

export interface TextContentItem {
/**
* Text content
*/
text: string;

/**
* Discriminator type of the content item. Always "text"
*/
type: 'text';
}
}
Expand All @@ -242,10 +281,10 @@ export interface TurnCreateParamsStreaming extends TurnCreateParamsBase {

export declare namespace TurnResource {
export {
type AgentTurnResponseStreamChunk as AgentTurnResponseStreamChunk,
type Turn as Turn,
type TurnResponseEvent as TurnResponseEvent,
type TurnResponseEventPayload as TurnResponseEventPayload,
type TurnCreateResponse as TurnCreateResponse,
type TurnCreateParams as TurnCreateParams,
type TurnCreateParamsNonStreaming as TurnCreateParamsNonStreaming,
type TurnCreateParamsStreaming as TurnCreateParamsStreaming,
Expand Down
17 changes: 1 addition & 16 deletions src/resources/batch-inference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { APIResource } from '../resource';
import * as Core from '../core';
import * as InferenceAPI from './inference';
import * as Shared from './shared';

export class BatchInference extends APIResource {
Expand All @@ -22,21 +21,7 @@ export class BatchInference extends APIResource {
}

export interface BatchInferenceChatCompletionResponse {
batch: Array<BatchInferenceChatCompletionResponse.Batch>;
}

export namespace BatchInferenceChatCompletionResponse {
export interface Batch {
/**
* The complete response message
*/
completion_message: Shared.CompletionMessage;

/**
* Optional log probabilities for generated tokens
*/
logprobs?: Array<InferenceAPI.TokenLogProbs>;
}
batch: Array<Shared.ChatCompletionResponse>;
}

export interface BatchInferenceChatCompletionParams {
Expand Down
20 changes: 1 addition & 19 deletions src/resources/datasets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,7 @@ export class Datasets extends APIResource {
}

export interface ListDatasetsResponse {
data: Array<ListDatasetsResponse.Data>;
}

export namespace ListDatasetsResponse {
export interface Data {
dataset_schema: Record<string, Shared.ParamType>;

identifier: string;

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

provider_id: string;

provider_resource_id: string;

type: 'dataset';

url: Shared.URL;
}
data: DatasetListResponse;
}

export interface DatasetRetrieveResponse {
Expand Down
2 changes: 1 addition & 1 deletion src/resources/eval-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface EvalTask {
}

export interface ListEvalTasksResponse {
data: Array<EvalTask>;
data: EvalTaskListResponse;
}

export type EvalTaskListResponse = Array<EvalTask>;
Expand Down
3 changes: 1 addition & 2 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ export {
} from './eval-tasks';
export {
Inference,
type ChatCompletionResponseStreamChunk,
type CompletionResponse,
type EmbeddingsResponse,
type TokenLogProbs,
type InferenceChatCompletionResponse,
type InferenceCompletionResponse,
type InferenceChatCompletionParams,
type InferenceChatCompletionParamsNonStreaming,
type InferenceChatCompletionParamsStreaming,
Expand Down
Loading