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
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 21
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prompt-foundry%2Fprompt-foundry-sdk-89af1acee06cb9beab0634c1d49d2d7bd6ee4a8a65ac12463ffa1275e8b85a0c.yml
configured_endpoints: 22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prompt-foundry%2Fprompt-foundry-sdk-969bf55b04cabb6e8830e65b28eaab5803568e209120cd75d331ea4626772544.yml
10 changes: 10 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Completion

Types:

- <code><a href="./src/resources/completion.ts">CompletionCreateResponse</a></code>

Methods:

- <code title="post /sdk/v1/prompts/{id}/completion">client.completion.<a href="./src/resources/completion.ts">create</a>(id, { ...params }) -> CompletionCreateResponse</code>

# Prompts

Types:
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export class PromptFoundry extends Core.APIClient {
this.apiKey = apiKey;
}

completion: API.Completion = new API.Completion(this);
prompts: API.Prompts = new API.Prompts(this);
tools: API.Tools = new API.Tools(this);
evaluationAssertions: API.EvaluationAssertions = new API.EvaluationAssertions(this);
Expand Down Expand Up @@ -188,6 +189,10 @@ export import fileFromPath = Uploads.fileFromPath;
export namespace PromptFoundry {
export import RequestOptions = Core.RequestOptions;

export import Completion = API.Completion;
export import CompletionCreateResponse = API.CompletionCreateResponse;
export import CompletionCreateParams = API.CompletionCreateParams;

export import Prompts = API.Prompts;
export import ModelParameters = API.ModelParameters;
export import PromptConfiguration = API.PromptConfiguration;
Expand Down
320 changes: 320 additions & 0 deletions src/resources/completion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,320 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../resource';
import { isRequestOptions } from '../core';
import * as Core from '../core';
import * as CompletionAPI from './completion';

export class Completion extends APIResource {
/**
* Initiates a completion request to the configured LLM provider using specified
* parameters and provided variables. This endpoint abstracts the integration with
* different model providers, enabling seamless switching between models while
* maintaining a consistent data model for your application.
*/
create(
id: string,
body?: CompletionCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<CompletionCreateResponse>;
create(id: string, options?: Core.RequestOptions): Core.APIPromise<CompletionCreateResponse>;
create(
id: string,
body: CompletionCreateParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<CompletionCreateResponse> {
if (isRequestOptions(body)) {
return this.create(id, {}, body);
}
return this._client.post(`/sdk/v1/prompts/${id}/completion`, { body, ...options });
}
}

export interface CompletionCreateResponse {
/**
* The completion message generated by the model.
*/
message: CompletionCreateResponse.Message;

stats: CompletionCreateResponse.Stats;
}

export namespace CompletionCreateResponse {
/**
* The completion message generated by the model.
*/
export interface Message {
content: Array<
| Message.TextContentBlockSchema
| Message.ImageBase64ContentBlock
| Message.ToolCallContentBlock
| Message.ToolResultContentBlock
>;

role: 'assistant' | 'system' | 'tool' | 'user';
}

export namespace Message {
export interface TextContentBlockSchema {
text: string;

type: 'TEXT';
}

export interface ImageBase64ContentBlock {
imageBase64: string;

mediaType: string;

type: 'IMAGE_BASE64';
}

export interface ToolCallContentBlock {
toolCall: ToolCallContentBlock.ToolCall;

type: 'TOOL_CALL';
}

export namespace ToolCallContentBlock {
export interface ToolCall {
function: ToolCall.Function;

/**
* TOOL_CALL_1
*/
toolCallId: string;

/**
* The type of the tool. Currently, only `function` is supported.
*/
type: 'function';
}

export namespace ToolCall {
export interface Function {
/**
* The arguments to call the function with, as generated by the model in JSON
* format. Note that the model does not always generate valid JSON, and may
* hallucinate parameters not defined by your function schema. Validate the
* arguments in your code before calling your function.
*/
arguments: string;

/**
* The name of the function to call.
*/
name: string;
}
}
}

export interface ToolResultContentBlock {
result: string;

toolCallId: string;

type: 'TOOL_RESULT';
}
}

export interface Stats {
/**
* The cost of generating the completion.
*/
cost: number;

/**
* The number of tokens in the input prompt.
*/
inputTokenCount: number;

/**
* The time in milliseconds it took to generate the completion.
*/
latency: number;

/**
* The number of tokens in the output completion.
*/
outputTokenCount: number;
}
}

export interface CompletionCreateParams {
/**
* Appended the the end of the configured prompt messages before running the
* prompt.
*/
appendMessages?: Array<CompletionCreateParams.AppendMessage>;

/**
* Replaces the configured prompt messages when running the prompt.
*/
overrideMessages?: Array<CompletionCreateParams.OverrideMessage>;

/**
* A unique identifier representing your end-user, which can help monitor and
* detect abuse.
*/
user?: string;

/**
* The template variables added to the prompt when executing the prompt.
*/
variables?: Record<string, string | null>;
}

export namespace CompletionCreateParams {
export interface AppendMessage {
content: Array<
| AppendMessage.TextContentBlockSchema
| AppendMessage.ImageBase64ContentBlock
| AppendMessage.ToolCallContentBlock
| AppendMessage.ToolResultContentBlock
>;

role: 'assistant' | 'system' | 'tool' | 'user';
}

export namespace AppendMessage {
export interface TextContentBlockSchema {
text: string;

type: 'TEXT';
}

export interface ImageBase64ContentBlock {
imageBase64: string;

mediaType: string;

type: 'IMAGE_BASE64';
}

export interface ToolCallContentBlock {
toolCall: ToolCallContentBlock.ToolCall;

type: 'TOOL_CALL';
}

export namespace ToolCallContentBlock {
export interface ToolCall {
function: ToolCall.Function;

/**
* TOOL_CALL_1
*/
toolCallId: string;

/**
* The type of the tool. Currently, only `function` is supported.
*/
type: 'function';
}

export namespace ToolCall {
export interface Function {
/**
* The arguments to call the function with, as generated by the model in JSON
* format. Note that the model does not always generate valid JSON, and may
* hallucinate parameters not defined by your function schema. Validate the
* arguments in your code before calling your function.
*/
arguments: string;

/**
* The name of the function to call.
*/
name: string;
}
}
}

export interface ToolResultContentBlock {
result: string;

toolCallId: string;

type: 'TOOL_RESULT';
}
}

export interface OverrideMessage {
content: Array<
| OverrideMessage.TextContentBlockSchema
| OverrideMessage.ImageBase64ContentBlock
| OverrideMessage.ToolCallContentBlock
| OverrideMessage.ToolResultContentBlock
>;

role: 'assistant' | 'system' | 'tool' | 'user';
}

export namespace OverrideMessage {
export interface TextContentBlockSchema {
text: string;

type: 'TEXT';
}

export interface ImageBase64ContentBlock {
imageBase64: string;

mediaType: string;

type: 'IMAGE_BASE64';
}

export interface ToolCallContentBlock {
toolCall: ToolCallContentBlock.ToolCall;

type: 'TOOL_CALL';
}

export namespace ToolCallContentBlock {
export interface ToolCall {
function: ToolCall.Function;

/**
* TOOL_CALL_1
*/
toolCallId: string;

/**
* The type of the tool. Currently, only `function` is supported.
*/
type: 'function';
}

export namespace ToolCall {
export interface Function {
/**
* The arguments to call the function with, as generated by the model in JSON
* format. Note that the model does not always generate valid JSON, and may
* hallucinate parameters not defined by your function schema. Validate the
* arguments in your code before calling your function.
*/
arguments: string;

/**
* The name of the function to call.
*/
name: string;
}
}
}

export interface ToolResultContentBlock {
result: string;

toolCallId: string;

type: 'TOOL_RESULT';
}
}
}

export namespace Completion {
export import CompletionCreateResponse = CompletionAPI.CompletionCreateResponse;
export import CompletionCreateParams = CompletionAPI.CompletionCreateParams;
}
1 change: 1 addition & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { CompletionCreateResponse, CompletionCreateParams, Completion } from './completion';
export {
Evaluation,
EvaluationListResponse,
Expand Down
Loading