From 57555b3f058f2dc62f37dd7a2f99dae353b1e7ea Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 20:06:15 +0000 Subject: [PATCH] feat(api): deduplication (#68) --- api.md | 8 +- src/index.ts | 8 +- src/resources/functions.ts | 337 ++-------------------------------- src/resources/index.ts | 3 +- src/resources/shared.ts | 365 +++++++++++++++++++------------------ 5 files changed, 210 insertions(+), 511 deletions(-) diff --git a/api.md b/api.md index a14c920..54caae2 100755 --- a/api.md +++ b/api.md @@ -5,6 +5,7 @@ Types: - AISecret - ACL - APIKey +- Code - CreateAPIKeyOutput - CrossObjectInsertResponse - DataSummary @@ -28,10 +29,10 @@ Types: - InsertExperimentEventReplace - InsertProjectLogsEventMerge - InsertProjectLogsEventReplace +- Messages - MetricSummary - Organization - PathLookupFilter -- Position - Project - ProjectLogsEvent - ProjectScore @@ -39,11 +40,15 @@ Types: - ProjectTag - Prompt - PromptData +- PromptImageURL - RepoInfo - Role - ScoreSummary +- Scorer - SummarizeDatasetResponse - SummarizeExperimentResponse +- Task +- ToolChoiceFunction - User - View - ViewData @@ -190,6 +195,7 @@ Methods: Types: +- ImageURL - FunctionInvokeResponse Methods: diff --git a/src/index.ts b/src/index.ts index 7c175fa..ae76708 100755 --- a/src/index.ts +++ b/src/index.ts @@ -270,6 +270,7 @@ export namespace Braintrust { export import ProjectTagReplaceParams = API.ProjectTagReplaceParams; export import Functions = API.Functions; + export import ImageURL = API.ImageURL; export import FunctionInvokeResponse = API.FunctionInvokeResponse; export import FunctionCreateParams = API.FunctionCreateParams; export import FunctionUpdateParams = API.FunctionUpdateParams; @@ -303,6 +304,7 @@ export namespace Braintrust { export import AISecret = API.AISecret; export import ACL = API.ACL; export import APIKey = API.APIKey; + export import Code = API.Code; export import CreateAPIKeyOutput = API.CreateAPIKeyOutput; export import CrossObjectInsertResponse = API.CrossObjectInsertResponse; export import DataSummary = API.DataSummary; @@ -326,10 +328,10 @@ export namespace Braintrust { export import InsertExperimentEventReplace = API.InsertExperimentEventReplace; export import InsertProjectLogsEventMerge = API.InsertProjectLogsEventMerge; export import InsertProjectLogsEventReplace = API.InsertProjectLogsEventReplace; + export import Messages = API.Messages; export import MetricSummary = API.MetricSummary; export import Organization = API.Organization; export import PathLookupFilter = API.PathLookupFilter; - export import Position = API.Position; export import Project = API.Project; export import ProjectLogsEvent = API.ProjectLogsEvent; export import ProjectScore = API.ProjectScore; @@ -337,11 +339,15 @@ export namespace Braintrust { export import ProjectTag = API.ProjectTag; export import Prompt = API.Prompt; export import PromptData = API.PromptData; + export import PromptImageURL = API.PromptImageURL; export import RepoInfo = API.RepoInfo; export import Role = API.Role; export import ScoreSummary = API.ScoreSummary; + export import Scorer = API.Scorer; export import SummarizeDatasetResponse = API.SummarizeDatasetResponse; export import SummarizeExperimentResponse = API.SummarizeExperimentResponse; + export import Task = API.Task; + export import ToolChoiceFunction = API.ToolChoiceFunction; export import User = API.User; export import View = API.View; export import ViewData = API.ViewData; diff --git a/src/resources/functions.ts b/src/resources/functions.ts index 13143de..739c7c3 100644 --- a/src/resources/functions.ts +++ b/src/resources/functions.ts @@ -103,10 +103,16 @@ export class Functions extends APIResource { } } +export interface ImageURL { + url: string; + + detail?: 'auto' | 'low' | 'high'; +} + export type FunctionInvokeResponse = unknown; export interface FunctionCreateParams { - function_data: FunctionCreateParams.Prompt | FunctionCreateParams.Code | FunctionCreateParams.Global; + function_data: FunctionCreateParams.Prompt | Shared.Code | FunctionCreateParams.Global; /** * Name of the prompt @@ -153,79 +159,6 @@ export namespace FunctionCreateParams { type: 'prompt'; } - export interface Code { - data: Code.Bundle | Code.Inline; - - type: 'code'; - } - - export namespace Code { - export interface Bundle { - bundle_id: string; - - location: Bundle.Experiment | Bundle.Function; - - runtime_context: Bundle.RuntimeContext; - - type: 'bundle'; - - /** - * A preview of the code - */ - preview?: string | null; - } - - export namespace Bundle { - export interface Experiment { - eval_name: string; - - position: Experiment.Type | Experiment.Scorer; - - type: 'experiment'; - } - - export namespace Experiment { - export interface Type { - type: 'task'; - } - - export interface Scorer { - index: number; - - type: 'scorer'; - } - } - - export interface Function { - index: number; - - type: 'function'; - } - - export interface RuntimeContext { - runtime: 'node' | 'python'; - - version: string; - } - } - - export interface Inline { - code: string; - - runtime_context: Inline.RuntimeContext; - - type: 'inline'; - } - - export namespace Inline { - export interface RuntimeContext { - runtime: 'node' | 'python'; - - version: string; - } - } - } - export interface Global { name: string; @@ -280,7 +213,7 @@ export interface FunctionUpdateParams { function_data?: | FunctionUpdateParams.Prompt - | FunctionUpdateParams.Code + | Shared.Code | FunctionUpdateParams.Global | FunctionUpdateParams.NullableVariant | null; @@ -306,79 +239,6 @@ export namespace FunctionUpdateParams { type: 'prompt'; } - export interface Code { - data: Code.Bundle | Code.Inline; - - type: 'code'; - } - - export namespace Code { - export interface Bundle { - bundle_id: string; - - location: Bundle.Experiment | Bundle.Function; - - runtime_context: Bundle.RuntimeContext; - - type: 'bundle'; - - /** - * A preview of the code - */ - preview?: string | null; - } - - export namespace Bundle { - export interface Experiment { - eval_name: string; - - position: Experiment.Type | Experiment.Scorer; - - type: 'experiment'; - } - - export namespace Experiment { - export interface Type { - type: 'task'; - } - - export interface Scorer { - index: number; - - type: 'scorer'; - } - } - - export interface Function { - index: number; - - type: 'function'; - } - - export interface RuntimeContext { - runtime: 'node' | 'python'; - - version: string; - } - } - - export interface Inline { - code: string; - - runtime_context: Inline.RuntimeContext; - - type: 'inline'; - } - - export namespace Inline { - export interface RuntimeContext { - runtime: 'node' | 'python'; - - version: string; - } - } - } - export interface Global { name: string; @@ -438,14 +298,7 @@ export interface FunctionInvokeParams { /** * If the function is an LLM, additional messages to pass along to it */ - messages?: Array< - | FunctionInvokeParams.System - | FunctionInvokeParams.User - | FunctionInvokeParams.Assistant - | FunctionInvokeParams.Tool - | FunctionInvokeParams.Function - | FunctionInvokeParams.Fallback - >; + messages?: Array; /** * The mode format of the returned value (defaults to 'auto') @@ -470,102 +323,6 @@ export interface FunctionInvokeParams { } export namespace FunctionInvokeParams { - export interface System { - role: 'system'; - - content?: string; - - name?: string; - } - - export interface User { - role: 'user'; - - content?: string | Array; - - name?: string; - } - - export namespace User { - export interface Text { - type: 'text'; - - text?: string; - } - - export interface ImageURL { - image_url: ImageURL.ImageURL; - - type: 'image_url'; - } - - export namespace ImageURL { - export interface ImageURL { - url: string; - - detail?: 'auto' | 'low' | 'high'; - } - } - } - - export interface Assistant { - role: 'assistant'; - - content?: string | null; - - function_call?: Assistant.FunctionCall | null; - - name?: string | null; - - tool_calls?: Array | null; - } - - export namespace Assistant { - export interface FunctionCall { - arguments: string; - - name: string; - } - - export interface ToolCall { - id: string; - - function: ToolCall.Function; - - type: 'function'; - } - - export namespace ToolCall { - export interface Function { - arguments: string; - - name: string; - } - } - } - - export interface Tool { - role: 'tool'; - - content?: string; - - tool_call_id?: string; - } - - export interface Function { - name: string; - - role: 'function'; - - content?: string; - } - - export interface Fallback { - role: 'model'; - - content?: string | null; - } - /** * Span parent properties */ @@ -612,7 +369,7 @@ export namespace FunctionInvokeParams { } export interface FunctionReplaceParams { - function_data: FunctionReplaceParams.Prompt | FunctionReplaceParams.Code | FunctionReplaceParams.Global; + function_data: FunctionReplaceParams.Prompt | Shared.Code | FunctionReplaceParams.Global; /** * Name of the prompt @@ -659,79 +416,6 @@ export namespace FunctionReplaceParams { type: 'prompt'; } - export interface Code { - data: Code.Bundle | Code.Inline; - - type: 'code'; - } - - export namespace Code { - export interface Bundle { - bundle_id: string; - - location: Bundle.Experiment | Bundle.Function; - - runtime_context: Bundle.RuntimeContext; - - type: 'bundle'; - - /** - * A preview of the code - */ - preview?: string | null; - } - - export namespace Bundle { - export interface Experiment { - eval_name: string; - - position: Experiment.Type | Experiment.Scorer; - - type: 'experiment'; - } - - export namespace Experiment { - export interface Type { - type: 'task'; - } - - export interface Scorer { - index: number; - - type: 'scorer'; - } - } - - export interface Function { - index: number; - - type: 'function'; - } - - export interface RuntimeContext { - runtime: 'node' | 'python'; - - version: string; - } - } - - export interface Inline { - code: string; - - runtime_context: Inline.RuntimeContext; - - type: 'inline'; - } - - export namespace Inline { - export interface RuntimeContext { - runtime: 'node' | 'python'; - - version: string; - } - } - } - export interface Global { name: string; @@ -779,6 +463,7 @@ export namespace FunctionReplaceParams { } export namespace Functions { + export import ImageURL = FunctionsAPI.ImageURL; export import FunctionInvokeResponse = FunctionsAPI.FunctionInvokeResponse; export import FunctionCreateParams = FunctionsAPI.FunctionCreateParams; export import FunctionUpdateParams = FunctionsAPI.FunctionUpdateParams; diff --git a/src/resources/index.ts b/src/resources/index.ts index f471656..8da8fe3 100755 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -40,7 +40,9 @@ export { ExperimentSummarizeParams, Experiments, } from './experiments'; +export { GroupCreateParams, GroupUpdateParams, GroupListParams, GroupReplaceParams, Groups } from './groups'; export { + ImageURL, FunctionInvokeResponse, FunctionCreateParams, FunctionUpdateParams, @@ -49,7 +51,6 @@ export { FunctionReplaceParams, Functions, } from './functions'; -export { GroupCreateParams, GroupUpdateParams, GroupListParams, GroupReplaceParams, Groups } from './groups'; export { OrganizationUpdateParams, OrganizationListParams, diff --git a/src/resources/shared.ts b/src/resources/shared.ts index 22fd177..3942965 100755 --- a/src/resources/shared.ts +++ b/src/resources/shared.ts @@ -1,6 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import * as Shared from './shared'; +import * as FunctionsAPI from './functions'; import { ListObjects } from '../pagination'; export interface AISecret { @@ -162,6 +163,67 @@ export interface APIKey { user_id?: string | null; } +export interface Code { + data: Code.Bundle | Code.Inline; + + type: 'code'; +} + +export namespace Code { + export interface Bundle { + bundle_id: string; + + location: Bundle.Experiment | Bundle.Function; + + runtime_context: Bundle.RuntimeContext; + + type: 'bundle'; + + /** + * A preview of the code + */ + preview?: string | null; + } + + export namespace Bundle { + export interface Experiment { + eval_name: string; + + position: Shared.Task | Shared.Scorer; + + type: 'experiment'; + } + + export interface Function { + index: number; + + type: 'function'; + } + + export interface RuntimeContext { + runtime: 'node' | 'python'; + + version: string; + } + } + + export interface Inline { + code: string; + + runtime_context: Inline.RuntimeContext; + + type: 'inline'; + } + + export namespace Inline { + export interface RuntimeContext { + runtime: 'node' | 'python'; + + version: string; + } + } +} + export interface CreateAPIKeyOutput { /** * Unique identifier for the api key @@ -785,7 +847,7 @@ export interface Function { */ _xact_id: string; - function_data: Function.Prompt | Function.Code | Function.Global; + function_data: Function.Prompt | Code | Function.Global; /** * A literal 'p' which identifies the object as a project prompt @@ -852,67 +914,6 @@ export namespace Function { type: 'prompt'; } - export interface Code { - data: Code.Bundle | Code.Inline; - - type: 'code'; - } - - export namespace Code { - export interface Bundle { - bundle_id: string; - - location: Bundle.Experiment | Bundle.Function; - - runtime_context: Bundle.RuntimeContext; - - type: 'bundle'; - - /** - * A preview of the code - */ - preview?: string | null; - } - - export namespace Bundle { - export interface Experiment { - eval_name: string; - - position: Shared.Position; - - type: 'experiment'; - } - - export interface Function { - index: number; - - type: 'function'; - } - - export interface RuntimeContext { - runtime: 'node' | 'python'; - - version: string; - } - } - - export interface Inline { - code: string; - - runtime_context: Inline.RuntimeContext; - - type: 'inline'; - } - - export namespace Inline { - export interface RuntimeContext { - runtime: 'node' | 'python'; - - version: string; - } - } - } - export interface Global { name: string; @@ -2020,6 +2021,104 @@ export namespace InsertProjectLogsEventReplace { } } +export type Messages = + | Messages.System + | Messages.User + | Messages.Assistant + | Messages.Tool + | Messages.Function + | Messages.Fallback; + +export namespace Messages { + export interface System { + role: 'system'; + + content?: string; + + name?: string; + } + + export interface User { + role: 'user'; + + content?: string | Array; + + name?: string; + } + + export namespace User { + export interface Text { + type: 'text'; + + text?: string; + } + + export interface ImageURL { + image_url: FunctionsAPI.ImageURL; + + type: 'image_url'; + } + } + + export interface Assistant { + role: 'assistant'; + + content?: string | null; + + function_call?: Assistant.FunctionCall | null; + + name?: string | null; + + tool_calls?: Array | null; + } + + export namespace Assistant { + export interface FunctionCall { + arguments: string; + + name: string; + } + + export interface ToolCall { + id: string; + + function: ToolCall.Function; + + type: 'function'; + } + + export namespace ToolCall { + export interface Function { + arguments: string; + + name: string; + } + } + } + + export interface Tool { + role: 'tool'; + + content?: string; + + tool_call_id?: string; + } + + export interface Function { + name: string; + + role: 'function'; + + content?: string; + } + + export interface Fallback { + role: 'model'; + + content?: string | null; + } +} + /** * Summary of a metric's performance */ @@ -2109,20 +2208,6 @@ export interface PathLookupFilter { value?: unknown; } -export type Position = Position.Type | Position.Scorer; - -export namespace Position { - export interface Type { - type: 'task'; - } - - export interface Scorer { - index: number; - - type: 'scorer'; - } -} - export interface Project { /** * Unique identifier for the project @@ -2667,16 +2752,10 @@ export namespace PromptData { } export interface Function { - function: Function.Function; + function: Shared.ToolChoiceFunction; type: 'function'; } - - export namespace Function { - export interface Function { - name: string; - } - } } export interface AnthropicModelParams { @@ -2746,111 +2825,13 @@ export namespace PromptData { } export interface Chat { - messages: Array; + messages: Array; type: 'chat'; tools?: string; } - export namespace Chat { - export interface System { - role: 'system'; - - content?: string; - - name?: string; - } - - export interface User { - role: 'user'; - - content?: string | Array; - - name?: string; - } - - export namespace User { - export interface Text { - type: 'text'; - - text?: string; - } - - export interface ImageURL { - image_url: ImageURL.ImageURL; - - type: 'image_url'; - } - - export namespace ImageURL { - export interface ImageURL { - url: string; - - detail?: 'auto' | 'low' | 'high'; - } - } - } - - export interface Assistant { - role: 'assistant'; - - content?: string | null; - - function_call?: Assistant.FunctionCall | null; - - name?: string | null; - - tool_calls?: Array | null; - } - - export namespace Assistant { - export interface FunctionCall { - arguments: string; - - name: string; - } - - export interface ToolCall { - id: string; - - function: ToolCall.Function; - - type: 'function'; - } - - export namespace ToolCall { - export interface Function { - arguments: string; - - name: string; - } - } - } - - export interface Tool { - role: 'tool'; - - content?: string; - - tool_call_id?: string; - } - - export interface Function { - name: string; - - role: 'function'; - - content?: string; - } - - export interface Fallback { - role: 'model'; - - content?: string | null; - } - } - export interface NullableVariant {} export interface Function { @@ -2866,6 +2847,12 @@ export namespace PromptData { } } +export interface PromptImageURL { + url: string; + + detail?: 'auto' | 'low' | 'high'; +} + /** * Metadata about the state of the repo when the experiment was created */ @@ -3046,6 +3033,12 @@ export interface ScoreSummary { diff?: number; } +export interface Scorer { + index: number; + + type: 'scorer'; +} + /** * Summary of a dataset */ @@ -3116,6 +3109,14 @@ export interface SummarizeExperimentResponse { scores?: Record | null; } +export interface Task { + type: 'task'; +} + +export interface ToolChoiceFunction { + name: string; +} + export interface User { /** * Unique identifier for the user