From f00d288446a4caea90c9c03dc7e834b8055d9ed2 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 15:59:46 +0000 Subject: [PATCH 1/4] Release 0.8.11 --- reference.md | 73 +------------------ src/api/resources/datasets/client/Client.ts | 2 +- .../requests/CreateEvaluatorLogRequest.ts | 2 - src/api/resources/files/client/Client.ts | 14 ++-- ...dyRetrieveByPathFilesRetrieveByPathPost.ts | 18 ----- ...FilesGetRequest.ts => FilesListRequest.ts} | 6 +- .../resources/files/client/requests/index.ts | 3 +- src/api/resources/files/index.ts | 1 - ...veByPathFilesRetrieveByPathPostResponse.ts | 12 --- src/api/resources/files/types/index.ts | 1 - src/api/resources/index.ts | 3 +- src/api/resources/logs/client/Client.ts | 8 -- .../client/requests/ListLogsGetRequest.ts | 4 - .../prompts/client/requests/PromptRequest.ts | 6 -- src/api/types/ChatRole.ts | 3 +- src/api/types/CodeEvaluatorRequest.ts | 6 -- src/api/types/DatasetResponse.ts | 6 -- src/api/types/DirectoryResponse.ts | 6 -- ...DirectoryWithParentsAndChildrenResponse.ts | 6 -- src/api/types/EvaluatorLogResponse.ts | 2 - src/api/types/EvaluatorResponse.ts | 6 -- src/api/types/ExternalEvaluatorRequest.ts | 6 -- src/api/types/FlowResponse.ts | 6 -- src/api/types/HumanEvaluatorRequest.ts | 12 +-- src/api/types/LlmEvaluatorRequest.ts | 6 -- src/api/types/PromptResponse.ts | 6 -- src/api/types/ToolResponse.ts | 6 -- .../requests/CreateEvaluatorLogRequest.ts | 3 - .../resources/files/client/index.ts | 1 - ...dyRetrieveByPathFilesRetrieveByPathPost.ts | 20 ----- .../resources/files/client/requests/index.ts | 1 - src/serialization/resources/files/index.ts | 2 - ...veByPathFilesRetrieveByPathPostResponse.ts | 28 ------- .../resources/files/types/index.ts | 1 - src/serialization/resources/index.ts | 3 - .../prompts/client/requests/PromptRequest.ts | 6 -- src/serialization/types/ChatRole.ts | 4 +- .../types/CodeEvaluatorRequest.ts | 9 --- src/serialization/types/DatasetResponse.ts | 6 -- src/serialization/types/DirectoryResponse.ts | 6 -- ...DirectoryWithParentsAndChildrenResponse.ts | 6 -- .../types/EvaluatorLogResponse.ts | 3 - src/serialization/types/EvaluatorResponse.ts | 6 -- .../types/ExternalEvaluatorRequest.ts | 9 --- src/serialization/types/FlowResponse.ts | 6 -- .../types/HumanEvaluatorRequest.ts | 8 +- .../types/LlmEvaluatorRequest.ts | 9 --- src/serialization/types/PromptResponse.ts | 6 -- src/serialization/types/ToolResponse.ts | 6 -- 49 files changed, 26 insertions(+), 353 deletions(-) delete mode 100644 src/api/resources/files/client/requests/BodyRetrieveByPathFilesRetrieveByPathPost.ts rename src/api/resources/files/client/requests/{ListFilesFilesGetRequest.ts => FilesListRequest.ts} (86%) delete mode 100644 src/api/resources/files/types/RetrieveByPathFilesRetrieveByPathPostResponse.ts delete mode 100644 src/api/resources/files/types/index.ts delete mode 100644 src/serialization/resources/files/client/index.ts delete mode 100644 src/serialization/resources/files/client/requests/BodyRetrieveByPathFilesRetrieveByPathPost.ts delete mode 100644 src/serialization/resources/files/client/requests/index.ts delete mode 100644 src/serialization/resources/files/index.ts delete mode 100644 src/serialization/resources/files/types/RetrieveByPathFilesRetrieveByPathPostResponse.ts delete mode 100644 src/serialization/resources/files/types/index.ts diff --git a/reference.md b/reference.md index b1e16768..49ccc2e7 100644 --- a/reference.md +++ b/reference.md @@ -2411,7 +2411,7 @@ By default, the new Dataset version will be set to the list of Datapoints provid the request. You can also create a new version by adding or removing Datapoints from an existing version by specifying `action` as `add` or `remove` respectively. In this case, you may specify the `version_id` or `environment` query parameters to identify the existing version to base -the new version on. If neither is provided, the latest created version will be used. +the new version on. If neither is provided, the default deployed version will be used. If you provide a commit message, then the new version will be committed; otherwise it will be uncommitted. If you try to commit an already committed version, @@ -5641,7 +5641,7 @@ await client.directories.update("id"); ## Files -
client.files.listFiles({ ...params }) -> Humanloop.PaginatedDataUnionPromptResponseToolResponseDatasetResponseEvaluatorResponseFlowResponse +
client.files.list({ ...params }) -> Humanloop.PaginatedDataUnionPromptResponseToolResponseDatasetResponseEvaluatorResponseFlowResponse
@@ -5669,7 +5669,7 @@ Get a paginated list of files.
```typescript -await client.files.listFiles(); +await client.files.list(); ```
@@ -5685,72 +5685,7 @@ await client.files.listFiles();
-**request:** `Humanloop.ListFilesFilesGetRequest` - -
-
- -
-
- -**requestOptions:** `Files.RequestOptions` - -
-
- -
- - - -
- -
client.files.retrieveByPath({ ...params }) -> Humanloop.RetrieveByPathFilesRetrieveByPathPostResponse -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieve a File by path. - -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.files.retrieveByPath({ - path: "path", -}); -``` - -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Humanloop.BodyRetrieveByPathFilesRetrieveByPathPost` +**request:** `Humanloop.FilesListRequest`
diff --git a/src/api/resources/datasets/client/Client.ts b/src/api/resources/datasets/client/Client.ts index d606a787..b1c281f9 100644 --- a/src/api/resources/datasets/client/Client.ts +++ b/src/api/resources/datasets/client/Client.ts @@ -176,7 +176,7 @@ export class Datasets { * the request. You can also create a new version by adding or removing Datapoints from an existing version * by specifying `action` as `add` or `remove` respectively. In this case, you may specify * the `version_id` or `environment` query parameters to identify the existing version to base - * the new version on. If neither is provided, the latest created version will be used. + * the new version on. If neither is provided, the default deployed version will be used. * * If you provide a commit message, then the new version will be committed; * otherwise it will be uncommitted. If you try to commit an already committed version, diff --git a/src/api/resources/evaluators/client/requests/CreateEvaluatorLogRequest.ts b/src/api/resources/evaluators/client/requests/CreateEvaluatorLogRequest.ts index e6b1873d..36729aa7 100644 --- a/src/api/resources/evaluators/client/requests/CreateEvaluatorLogRequest.ts +++ b/src/api/resources/evaluators/client/requests/CreateEvaluatorLogRequest.ts @@ -61,8 +61,6 @@ export interface CreateEvaluatorLogRequest { save?: boolean; /** This will identify a Log. If you don't provide a Log ID, Humanloop will generate one for you. */ logId?: string; - /** The message returned by the LLM. Only populated for LLM Evaluator Logs. */ - outputMessage?: Humanloop.ChatMessage; /** Evaluator assessment of the Log. */ judgment?: Humanloop.CreateEvaluatorLogRequestJudgment; /** Whether the Log has been manually marked as completed by a user. */ diff --git a/src/api/resources/files/client/Client.ts b/src/api/resources/files/client/Client.ts index 77bfacaf..9c3d1481 100644 --- a/src/api/resources/files/client/Client.ts +++ b/src/api/resources/files/client/Client.ts @@ -32,19 +32,19 @@ export class Files { /** * Get a paginated list of files. * - * @param {Humanloop.ListFilesFilesGetRequest} request + * @param {Humanloop.FilesListRequest} request * @param {Files.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Humanloop.UnprocessableEntityError} * * @example - * await client.files.listFiles() + * await client.files.list() */ - public async listFiles( - request: Humanloop.ListFilesFilesGetRequest = {}, + public async list( + request: Humanloop.FilesListRequest = {}, requestOptions?: Files.RequestOptions, ): Promise { - const { page, size, name, template, type: type_, environment, sortBy, order } = request; + const { page, size, name, type: type_, environment, sortBy, order } = request; const _queryParams: Record = {}; if (page != null) { _queryParams["page"] = page.toString(); @@ -58,10 +58,6 @@ export class Files { _queryParams["name"] = name; } - if (template != null) { - _queryParams["template"] = template.toString(); - } - if (type_ != null) { if (Array.isArray(type_)) { _queryParams["type"] = type_.map((item) => item); diff --git a/src/api/resources/files/client/requests/BodyRetrieveByPathFilesRetrieveByPathPost.ts b/src/api/resources/files/client/requests/BodyRetrieveByPathFilesRetrieveByPathPost.ts deleted file mode 100644 index 7c5c0012..00000000 --- a/src/api/resources/files/client/requests/BodyRetrieveByPathFilesRetrieveByPathPost.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -/** - * @example - * { - * path: "path" - * } - */ -export interface BodyRetrieveByPathFilesRetrieveByPathPost { - /** - * Name of the Environment to retrieve a deployed Version from. - */ - environment?: string; - /** Path of the File to retrieve. */ - path: string; -} diff --git a/src/api/resources/files/client/requests/ListFilesFilesGetRequest.ts b/src/api/resources/files/client/requests/FilesListRequest.ts similarity index 86% rename from src/api/resources/files/client/requests/ListFilesFilesGetRequest.ts rename to src/api/resources/files/client/requests/FilesListRequest.ts index 592e4e8b..88e10fce 100644 --- a/src/api/resources/files/client/requests/ListFilesFilesGetRequest.ts +++ b/src/api/resources/files/client/requests/FilesListRequest.ts @@ -8,7 +8,7 @@ import * as Humanloop from "../../../../index"; * @example * {} */ -export interface ListFilesFilesGetRequest { +export interface FilesListRequest { /** * Page offset for pagination. */ @@ -21,10 +21,6 @@ export interface ListFilesFilesGetRequest { * Case-insensitive filter for file name. */ name?: string; - /** - * Filter to include only template files. - */ - template?: boolean; /** * List of file types to filter for. */ diff --git a/src/api/resources/files/client/requests/index.ts b/src/api/resources/files/client/requests/index.ts index b43526ff..80e3623c 100644 --- a/src/api/resources/files/client/requests/index.ts +++ b/src/api/resources/files/client/requests/index.ts @@ -1,2 +1 @@ -export { type ListFilesFilesGetRequest } from "./ListFilesFilesGetRequest"; -export { type BodyRetrieveByPathFilesRetrieveByPathPost } from "./BodyRetrieveByPathFilesRetrieveByPathPost"; +export { type FilesListRequest } from "./FilesListRequest"; diff --git a/src/api/resources/files/index.ts b/src/api/resources/files/index.ts index c9240f83..5ec76921 100644 --- a/src/api/resources/files/index.ts +++ b/src/api/resources/files/index.ts @@ -1,2 +1 @@ -export * from "./types"; export * from "./client"; diff --git a/src/api/resources/files/types/RetrieveByPathFilesRetrieveByPathPostResponse.ts b/src/api/resources/files/types/RetrieveByPathFilesRetrieveByPathPostResponse.ts deleted file mode 100644 index 3adf1e5e..00000000 --- a/src/api/resources/files/types/RetrieveByPathFilesRetrieveByPathPostResponse.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as Humanloop from "../../../index"; - -export type RetrieveByPathFilesRetrieveByPathPostResponse = - | Humanloop.PromptResponse - | Humanloop.ToolResponse - | Humanloop.DatasetResponse - | Humanloop.EvaluatorResponse - | Humanloop.FlowResponse; diff --git a/src/api/resources/files/types/index.ts b/src/api/resources/files/types/index.ts deleted file mode 100644 index 05e9be09..00000000 --- a/src/api/resources/files/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./RetrieveByPathFilesRetrieveByPathPostResponse"; diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts index 24cf2361..cada3384 100644 --- a/src/api/resources/index.ts +++ b/src/api/resources/index.ts @@ -2,14 +2,13 @@ export * as prompts from "./prompts"; export * from "./prompts/types"; export * as evaluators from "./evaluators"; export * from "./evaluators/types"; -export * as files from "./files"; -export * from "./files/types"; export * as evaluations from "./evaluations"; export * from "./evaluations/types"; export * as tools from "./tools"; export * as datasets from "./datasets"; export * as flows from "./flows"; export * as directories from "./directories"; +export * as files from "./files"; export * as logs from "./logs"; export * from "./prompts/client/requests"; export * from "./tools/client/requests"; diff --git a/src/api/resources/logs/client/Client.ts b/src/api/resources/logs/client/Client.ts index 00daeb8a..c24d4a71 100644 --- a/src/api/resources/logs/client/Client.ts +++ b/src/api/resources/logs/client/Client.ts @@ -67,7 +67,6 @@ export class Logs { size, versionId, versionStatus, - id, search, metadataSearch, startDate, @@ -91,13 +90,6 @@ export class Logs { if (versionStatus != null) { _queryParams["version_status"] = versionStatus; } - if (id != null) { - if (Array.isArray(id)) { - _queryParams["id"] = id.map((item) => item); - } else { - _queryParams["id"] = id; - } - } if (search != null) { _queryParams["search"] = search; } diff --git a/src/api/resources/logs/client/requests/ListLogsGetRequest.ts b/src/api/resources/logs/client/requests/ListLogsGetRequest.ts index 3ce9e985..9191ff95 100644 --- a/src/api/resources/logs/client/requests/ListLogsGetRequest.ts +++ b/src/api/resources/logs/client/requests/ListLogsGetRequest.ts @@ -32,10 +32,6 @@ export interface ListLogsGetRequest { * If provided, only Logs belonging to Versions with the specified status will be returned. */ versionStatus?: Humanloop.VersionStatus; - /** - * If provided, returns Logs whose IDs contain any of the specified values as substrings. - */ - id?: string | string[]; /** * If provided, only Logs that contain the provided string in its inputs and output will be returned. */ diff --git a/src/api/resources/prompts/client/requests/PromptRequest.ts b/src/api/resources/prompts/client/requests/PromptRequest.ts index 13acb883..196ca636 100644 --- a/src/api/resources/prompts/client/requests/PromptRequest.ts +++ b/src/api/resources/prompts/client/requests/PromptRequest.ts @@ -66,10 +66,4 @@ export interface PromptRequest { attributes?: Record; /** Message describing the changes made. */ commitMessage?: string; - /** Description of the Prompt. */ - description?: string; - /** List of tags associated with this prompt. */ - tags?: string[]; - /** Long description of the Prompt. */ - readme?: string; } diff --git a/src/api/types/ChatRole.ts b/src/api/types/ChatRole.ts index 0932a9af..e7d8d364 100644 --- a/src/api/types/ChatRole.ts +++ b/src/api/types/ChatRole.ts @@ -5,12 +5,11 @@ /** * An enumeration. */ -export type ChatRole = "user" | "assistant" | "system" | "tool" | "developer"; +export type ChatRole = "user" | "assistant" | "system" | "tool"; export const ChatRole = { User: "user", Assistant: "assistant", System: "system", Tool: "tool", - Developer: "developer", } as const; diff --git a/src/api/types/CodeEvaluatorRequest.ts b/src/api/types/CodeEvaluatorRequest.ts index bc56d58d..2161a617 100644 --- a/src/api/types/CodeEvaluatorRequest.ts +++ b/src/api/types/CodeEvaluatorRequest.ts @@ -11,12 +11,6 @@ export interface CodeEvaluatorRequest { returnType: Humanloop.EvaluatorReturnTypeEnum; /** Additional fields to describe the Evaluator. Helpful to separate Evaluator versions from each other with details on how they were created or used. */ attributes?: Record; - /** The options that can be applied as judgments. Only for Evaluators with `return_type` of 'boolean', 'select' or 'multi_select'. */ - options?: Humanloop.EvaluatorJudgmentOptionResponse[]; - /** Limits on the judgment that can be applied. Only for Evaluators with `return_type` of 'number'. */ - numberLimits?: Humanloop.EvaluatorJudgmentNumberLimit; - /** The valence of the number judgment. Only for Evaluators with `return_type` of 'number'. If 'positive', a higher number is better. If 'negative', a lower number is better. */ - numberValence?: Humanloop.Valence; evaluatorType: "python"; /** The code for the Evaluator. This code will be executed in a sandboxed environment. */ code: string; diff --git a/src/api/types/DatasetResponse.ts b/src/api/types/DatasetResponse.ts index 42ca17cf..1dd841fc 100644 --- a/src/api/types/DatasetResponse.ts +++ b/src/api/types/DatasetResponse.ts @@ -19,12 +19,6 @@ export interface DatasetResponse { directoryId?: string; /** Name of the Dataset, which is used as a unique identifier. */ name: string; - /** Description of the Dataset. */ - description?: string; - /** Long description of the file. */ - readme?: string; - /** List of tags associated with the file. */ - tags?: string[]; /** Unique identifier for the specific Dataset Version. If no query params provided, the default deployed Dataset Version is returned. Starts with `dsv_`. */ versionId: string; type?: "dataset"; diff --git a/src/api/types/DirectoryResponse.ts b/src/api/types/DirectoryResponse.ts index 437a20b6..ec931d63 100644 --- a/src/api/types/DirectoryResponse.ts +++ b/src/api/types/DirectoryResponse.ts @@ -9,14 +9,8 @@ export interface DirectoryResponse { parentId?: string; /** Name of the directory. */ name: string; - /** Description of the directory. */ - description?: string; /** Path to the directory, relative to the root directory. Includes name, e.g. `path/to/directory`. */ path: string; - /** Long description of the directory. */ - readme?: string; - /** List of tags associated with the directory. */ - tags: string[]; createdAt: Date; updatedAt: Date; } diff --git a/src/api/types/DirectoryWithParentsAndChildrenResponse.ts b/src/api/types/DirectoryWithParentsAndChildrenResponse.ts index 88eb481c..b5b0ac22 100644 --- a/src/api/types/DirectoryWithParentsAndChildrenResponse.ts +++ b/src/api/types/DirectoryWithParentsAndChildrenResponse.ts @@ -11,14 +11,8 @@ export interface DirectoryWithParentsAndChildrenResponse { parentId?: string; /** Name of the directory. */ name: string; - /** Description of the directory. */ - description?: string; /** Path to the directory, relative to the root directory. Includes name, e.g. `path/to/directory`. */ path: string; - /** Long description of the directory. */ - readme?: string; - /** List of tags associated with the directory. */ - tags: string[]; createdAt: Date; updatedAt: Date; /** List of subdirectories in the directory. */ diff --git a/src/api/types/EvaluatorLogResponse.ts b/src/api/types/EvaluatorLogResponse.ts index 0c6deecd..bb8ebf30 100644 --- a/src/api/types/EvaluatorLogResponse.ts +++ b/src/api/types/EvaluatorLogResponse.ts @@ -48,8 +48,6 @@ export interface EvaluatorLogResponse { save?: boolean; /** This will identify a Log. If you don't provide a Log ID, Humanloop will generate one for you. */ logId?: string; - /** The message returned by the LLM. Only populated for LLM Evaluator Logs. */ - outputMessage?: Humanloop.ChatMessage; /** Evaluator assessment of the Log. */ judgment?: Humanloop.EvaluatorLogResponseJudgment; /** Whether the Log has been manually marked as completed by a user. */ diff --git a/src/api/types/EvaluatorResponse.ts b/src/api/types/EvaluatorResponse.ts index 80d40ac3..926e61fa 100644 --- a/src/api/types/EvaluatorResponse.ts +++ b/src/api/types/EvaluatorResponse.ts @@ -19,12 +19,6 @@ export interface EvaluatorResponse { spec: Humanloop.EvaluatorResponseSpec; /** Name of the Evaluator, which is used as a unique identifier. */ name: string; - /** Description of the Evaluator. */ - description?: string; - /** Long description of the file. */ - readme?: string; - /** List of tags associated with the file. */ - tags?: string[]; /** Unique identifier for the specific Evaluator Version. If no query params provided, the default deployed Evaluator Version is returned. */ versionId: string; type?: "evaluator"; diff --git a/src/api/types/ExternalEvaluatorRequest.ts b/src/api/types/ExternalEvaluatorRequest.ts index 1c7bce04..03a78ac1 100644 --- a/src/api/types/ExternalEvaluatorRequest.ts +++ b/src/api/types/ExternalEvaluatorRequest.ts @@ -11,11 +11,5 @@ export interface ExternalEvaluatorRequest { returnType: Humanloop.EvaluatorReturnTypeEnum; /** Additional fields to describe the Evaluator. Helpful to separate Evaluator versions from each other with details on how they were created or used. */ attributes?: Record; - /** The options that can be applied as judgments. Only for Evaluators with `return_type` of 'boolean', 'select' or 'multi_select'. */ - options?: Humanloop.EvaluatorJudgmentOptionResponse[]; - /** Limits on the judgment that can be applied. Only for Evaluators with `return_type` of 'number'. */ - numberLimits?: Humanloop.EvaluatorJudgmentNumberLimit; - /** The valence of the number judgment. Only for Evaluators with `return_type` of 'number'. If 'positive', a higher number is better. If 'negative', a lower number is better. */ - numberValence?: Humanloop.Valence; evaluatorType: "external"; } diff --git a/src/api/types/FlowResponse.ts b/src/api/types/FlowResponse.ts index 2fa4867e..5c7c4e2a 100644 --- a/src/api/types/FlowResponse.ts +++ b/src/api/types/FlowResponse.ts @@ -20,12 +20,6 @@ export interface FlowResponse { commitMessage?: string; /** Name of the Flow. */ name: string; - /** Description of the Flow. */ - description?: string; - /** Long description of the file. */ - readme?: string; - /** List of tags associated with the file. */ - tags?: string[]; /** Unique identifier for the specific Flow Version. If no query params provided, the default deployed Flow Version is returned. */ versionId: string; type?: "flow"; diff --git a/src/api/types/HumanEvaluatorRequest.ts b/src/api/types/HumanEvaluatorRequest.ts index 7703f1b7..8f922b30 100644 --- a/src/api/types/HumanEvaluatorRequest.ts +++ b/src/api/types/HumanEvaluatorRequest.ts @@ -11,13 +11,13 @@ export interface HumanEvaluatorRequest { returnType: Humanloop.HumanEvaluatorRequestReturnType; /** Additional fields to describe the Evaluator. Helpful to separate Evaluator versions from each other with details on how they were created or used. */ attributes?: Record; - /** The options that can be applied as judgments. */ + evaluatorType: "human"; + /** Instructions for the Human annotating the . */ + instructions?: string; + /** The options that the Human annotator can choose from. */ options?: Humanloop.EvaluatorJudgmentOptionResponse[]; - /** Limits on the judgment that can be applied. Only for Evaluators with `return_type` of 'number'. */ + /** Limits on the judgment that can be applied. Only for Evaluators with `return_type` of `'number'`. */ numberLimits?: Humanloop.EvaluatorJudgmentNumberLimit; - /** The valence of the number judgment. Only for Evaluators with `return_type` of 'number'. If 'positive', a higher number is better. If 'negative', a lower number is better. */ + /** The valence of the number judgment. Only for Evaluators with `return_type` of `'number'`. If 'positive', a higher number is better. If 'negative', a lower number is better. */ numberValence?: Humanloop.Valence; - evaluatorType: "human"; - /** Instructions and guidelines for applying judgments. */ - instructions?: string; } diff --git a/src/api/types/LlmEvaluatorRequest.ts b/src/api/types/LlmEvaluatorRequest.ts index 526594a8..2b604453 100644 --- a/src/api/types/LlmEvaluatorRequest.ts +++ b/src/api/types/LlmEvaluatorRequest.ts @@ -11,12 +11,6 @@ export interface LlmEvaluatorRequest { returnType: Humanloop.EvaluatorReturnTypeEnum; /** Additional fields to describe the Evaluator. Helpful to separate Evaluator versions from each other with details on how they were created or used. */ attributes?: Record; - /** The options that can be applied as judgments. Only for Evaluators with `return_type` of 'boolean', 'select' or 'multi_select'. */ - options?: Humanloop.EvaluatorJudgmentOptionResponse[]; - /** Limits on the judgment that can be applied. Only for Evaluators with `return_type` of 'number'. */ - numberLimits?: Humanloop.EvaluatorJudgmentNumberLimit; - /** The valence of the number judgment. Only for Evaluators with `return_type` of 'number'. If 'positive', a higher number is better. If 'negative', a lower number is better. */ - numberValence?: Humanloop.Valence; evaluatorType: "llm"; /** The prompt parameters used to generate. */ prompt?: Humanloop.PromptKernelRequest; diff --git a/src/api/types/PromptResponse.ts b/src/api/types/PromptResponse.ts index 12f6183d..8e071825 100644 --- a/src/api/types/PromptResponse.ts +++ b/src/api/types/PromptResponse.ts @@ -58,12 +58,6 @@ export interface PromptResponse { attributes?: Record; /** Message describing the changes made. */ commitMessage?: string; - /** Description of the Prompt. */ - description?: string; - /** List of tags associated with the file. */ - tags?: string[]; - /** Long description of the file. */ - readme?: string; /** Name of the Prompt. */ name: string; /** Unique identifier for the specific Prompt Version. If no query params provided, the default deployed Prompt Version is returned. */ diff --git a/src/api/types/ToolResponse.ts b/src/api/types/ToolResponse.ts index 7a35f855..a85d17c3 100644 --- a/src/api/types/ToolResponse.ts +++ b/src/api/types/ToolResponse.ts @@ -31,12 +31,6 @@ export interface ToolResponse { commitMessage?: string; /** Name of the Tool, which is used as a unique identifier. */ name: string; - /** Description of the Tool. */ - description?: string; - /** Long description of the file. */ - readme?: string; - /** List of tags associated with the file. */ - tags?: string[]; /** Unique identifier for the specific Tool Version. If no query params provided, the default deployed Tool Version is returned. */ versionId: string; type?: "tool"; diff --git a/src/serialization/resources/evaluators/client/requests/CreateEvaluatorLogRequest.ts b/src/serialization/resources/evaluators/client/requests/CreateEvaluatorLogRequest.ts index c4a61898..320e5502 100644 --- a/src/serialization/resources/evaluators/client/requests/CreateEvaluatorLogRequest.ts +++ b/src/serialization/resources/evaluators/client/requests/CreateEvaluatorLogRequest.ts @@ -5,7 +5,6 @@ import * as serializers from "../../../../index"; import * as Humanloop from "../../../../../api/index"; import * as core from "../../../../../core"; -import { ChatMessage } from "../../../../types/ChatMessage"; import { CreateEvaluatorLogRequestJudgment } from "../../types/CreateEvaluatorLogRequestJudgment"; import { CreateEvaluatorLogRequestSpec } from "../../types/CreateEvaluatorLogRequestSpec"; @@ -43,7 +42,6 @@ export const CreateEvaluatorLogRequest: core.serialization.Schema< ), save: core.serialization.boolean().optional(), logId: core.serialization.property("log_id", core.serialization.string().optional()), - outputMessage: core.serialization.property("output_message", ChatMessage.optional()), judgment: CreateEvaluatorLogRequestJudgment.optional(), markedCompleted: core.serialization.property("marked_completed", core.serialization.boolean().optional()), spec: CreateEvaluatorLogRequestSpec.optional(), @@ -72,7 +70,6 @@ export declare namespace CreateEvaluatorLogRequest { environment?: string | null; save?: boolean | null; log_id?: string | null; - output_message?: ChatMessage.Raw | null; judgment?: CreateEvaluatorLogRequestJudgment.Raw | null; marked_completed?: boolean | null; spec?: CreateEvaluatorLogRequestSpec.Raw | null; diff --git a/src/serialization/resources/files/client/index.ts b/src/serialization/resources/files/client/index.ts deleted file mode 100644 index 415726b7..00000000 --- a/src/serialization/resources/files/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests"; diff --git a/src/serialization/resources/files/client/requests/BodyRetrieveByPathFilesRetrieveByPathPost.ts b/src/serialization/resources/files/client/requests/BodyRetrieveByPathFilesRetrieveByPathPost.ts deleted file mode 100644 index b1493ade..00000000 --- a/src/serialization/resources/files/client/requests/BodyRetrieveByPathFilesRetrieveByPathPost.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../../../index"; -import * as Humanloop from "../../../../../api/index"; -import * as core from "../../../../../core"; - -export const BodyRetrieveByPathFilesRetrieveByPathPost: core.serialization.Schema< - serializers.BodyRetrieveByPathFilesRetrieveByPathPost.Raw, - Omit -> = core.serialization.object({ - path: core.serialization.string(), -}); - -export declare namespace BodyRetrieveByPathFilesRetrieveByPathPost { - interface Raw { - path: string; - } -} diff --git a/src/serialization/resources/files/client/requests/index.ts b/src/serialization/resources/files/client/requests/index.ts deleted file mode 100644 index bd582f85..00000000 --- a/src/serialization/resources/files/client/requests/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { BodyRetrieveByPathFilesRetrieveByPathPost } from "./BodyRetrieveByPathFilesRetrieveByPathPost"; diff --git a/src/serialization/resources/files/index.ts b/src/serialization/resources/files/index.ts deleted file mode 100644 index c9240f83..00000000 --- a/src/serialization/resources/files/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./types"; -export * from "./client"; diff --git a/src/serialization/resources/files/types/RetrieveByPathFilesRetrieveByPathPostResponse.ts b/src/serialization/resources/files/types/RetrieveByPathFilesRetrieveByPathPostResponse.ts deleted file mode 100644 index 6b65bd82..00000000 --- a/src/serialization/resources/files/types/RetrieveByPathFilesRetrieveByPathPostResponse.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../../index"; -import * as Humanloop from "../../../../api/index"; -import * as core from "../../../../core"; -import { DatasetResponse } from "../../../types/DatasetResponse"; - -export const RetrieveByPathFilesRetrieveByPathPostResponse: core.serialization.Schema< - serializers.RetrieveByPathFilesRetrieveByPathPostResponse.Raw, - Humanloop.RetrieveByPathFilesRetrieveByPathPostResponse -> = core.serialization.undiscriminatedUnion([ - core.serialization.lazyObject(() => serializers.PromptResponse), - core.serialization.lazyObject(() => serializers.ToolResponse), - DatasetResponse, - core.serialization.lazyObject(() => serializers.EvaluatorResponse), - core.serialization.lazyObject(() => serializers.FlowResponse), -]); - -export declare namespace RetrieveByPathFilesRetrieveByPathPostResponse { - type Raw = - | serializers.PromptResponse.Raw - | serializers.ToolResponse.Raw - | DatasetResponse.Raw - | serializers.EvaluatorResponse.Raw - | serializers.FlowResponse.Raw; -} diff --git a/src/serialization/resources/files/types/index.ts b/src/serialization/resources/files/types/index.ts deleted file mode 100644 index 05e9be09..00000000 --- a/src/serialization/resources/files/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./RetrieveByPathFilesRetrieveByPathPostResponse"; diff --git a/src/serialization/resources/index.ts b/src/serialization/resources/index.ts index 2a899983..0a6b0d3b 100644 --- a/src/serialization/resources/index.ts +++ b/src/serialization/resources/index.ts @@ -2,8 +2,6 @@ export * as prompts from "./prompts"; export * from "./prompts/types"; export * as evaluators from "./evaluators"; export * from "./evaluators/types"; -export * as files from "./files"; -export * from "./files/types"; export * as evaluations from "./evaluations"; export * from "./evaluations/types"; export * as tools from "./tools"; @@ -16,5 +14,4 @@ export * from "./datasets/client/requests"; export * from "./evaluators/client/requests"; export * from "./flows/client/requests"; export * from "./directories/client/requests"; -export * from "./files/client/requests"; export * from "./evaluations/client/requests"; diff --git a/src/serialization/resources/prompts/client/requests/PromptRequest.ts b/src/serialization/resources/prompts/client/requests/PromptRequest.ts index 39afa466..a7d926d1 100644 --- a/src/serialization/resources/prompts/client/requests/PromptRequest.ts +++ b/src/serialization/resources/prompts/client/requests/PromptRequest.ts @@ -36,9 +36,6 @@ export const PromptRequest: core.serialization.Schema | null; commit_message?: string | null; - description?: string | null; - tags?: string[] | null; - readme?: string | null; } } diff --git a/src/serialization/types/ChatRole.ts b/src/serialization/types/ChatRole.ts index 18df2458..b15be1d7 100644 --- a/src/serialization/types/ChatRole.ts +++ b/src/serialization/types/ChatRole.ts @@ -7,8 +7,8 @@ import * as Humanloop from "../../api/index"; import * as core from "../../core"; export const ChatRole: core.serialization.Schema = - core.serialization.enum_(["user", "assistant", "system", "tool", "developer"]); + core.serialization.enum_(["user", "assistant", "system", "tool"]); export declare namespace ChatRole { - type Raw = "user" | "assistant" | "system" | "tool" | "developer"; + type Raw = "user" | "assistant" | "system" | "tool"; } diff --git a/src/serialization/types/CodeEvaluatorRequest.ts b/src/serialization/types/CodeEvaluatorRequest.ts index 008ab8bc..795a8d3d 100644 --- a/src/serialization/types/CodeEvaluatorRequest.ts +++ b/src/serialization/types/CodeEvaluatorRequest.ts @@ -7,9 +7,6 @@ import * as Humanloop from "../../api/index"; import * as core from "../../core"; import { EvaluatorArgumentsType } from "./EvaluatorArgumentsType"; import { EvaluatorReturnTypeEnum } from "./EvaluatorReturnTypeEnum"; -import { EvaluatorJudgmentOptionResponse } from "./EvaluatorJudgmentOptionResponse"; -import { EvaluatorJudgmentNumberLimit } from "./EvaluatorJudgmentNumberLimit"; -import { Valence } from "./Valence"; export const CodeEvaluatorRequest: core.serialization.ObjectSchema< serializers.CodeEvaluatorRequest.Raw, @@ -18,9 +15,6 @@ export const CodeEvaluatorRequest: core.serialization.ObjectSchema< argumentsType: core.serialization.property("arguments_type", EvaluatorArgumentsType), returnType: core.serialization.property("return_type", EvaluatorReturnTypeEnum), attributes: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), - options: core.serialization.list(EvaluatorJudgmentOptionResponse).optional(), - numberLimits: core.serialization.property("number_limits", EvaluatorJudgmentNumberLimit.optional()), - numberValence: core.serialization.property("number_valence", Valence.optional()), evaluatorType: core.serialization.property("evaluator_type", core.serialization.stringLiteral("python")), code: core.serialization.string(), }); @@ -30,9 +24,6 @@ export declare namespace CodeEvaluatorRequest { arguments_type: EvaluatorArgumentsType.Raw; return_type: EvaluatorReturnTypeEnum.Raw; attributes?: Record | null; - options?: EvaluatorJudgmentOptionResponse.Raw[] | null; - number_limits?: EvaluatorJudgmentNumberLimit.Raw | null; - number_valence?: Valence.Raw | null; evaluator_type: "python"; code: string; } diff --git a/src/serialization/types/DatasetResponse.ts b/src/serialization/types/DatasetResponse.ts index 46d3ad66..bd22f28e 100644 --- a/src/serialization/types/DatasetResponse.ts +++ b/src/serialization/types/DatasetResponse.ts @@ -18,9 +18,6 @@ export const DatasetResponse: core.serialization.ObjectSchema< id: core.serialization.string(), directoryId: core.serialization.property("directory_id", core.serialization.string().optional()), name: core.serialization.string(), - description: core.serialization.string().optional(), - readme: core.serialization.string().optional(), - tags: core.serialization.list(core.serialization.string()).optional(), versionId: core.serialization.property("version_id", core.serialization.string()), type: core.serialization.stringLiteral("dataset").optional(), environments: core.serialization.list(EnvironmentResponse).optional(), @@ -43,9 +40,6 @@ export declare namespace DatasetResponse { id: string; directory_id?: string | null; name: string; - description?: string | null; - readme?: string | null; - tags?: string[] | null; version_id: string; type?: "dataset" | null; environments?: EnvironmentResponse.Raw[] | null; diff --git a/src/serialization/types/DirectoryResponse.ts b/src/serialization/types/DirectoryResponse.ts index 822c0573..27be20e8 100644 --- a/src/serialization/types/DirectoryResponse.ts +++ b/src/serialization/types/DirectoryResponse.ts @@ -13,10 +13,7 @@ export const DirectoryResponse: core.serialization.ObjectSchema< id: core.serialization.string(), parentId: core.serialization.property("parent_id", core.serialization.string().optional()), name: core.serialization.string(), - description: core.serialization.string().optional(), path: core.serialization.string(), - readme: core.serialization.string().optional(), - tags: core.serialization.list(core.serialization.string()), createdAt: core.serialization.property("created_at", core.serialization.date()), updatedAt: core.serialization.property("updated_at", core.serialization.date()), }); @@ -26,10 +23,7 @@ export declare namespace DirectoryResponse { id: string; parent_id?: string | null; name: string; - description?: string | null; path: string; - readme?: string | null; - tags: string[]; created_at: string; updated_at: string; } diff --git a/src/serialization/types/DirectoryWithParentsAndChildrenResponse.ts b/src/serialization/types/DirectoryWithParentsAndChildrenResponse.ts index 2918c95d..732c8ef1 100644 --- a/src/serialization/types/DirectoryWithParentsAndChildrenResponse.ts +++ b/src/serialization/types/DirectoryWithParentsAndChildrenResponse.ts @@ -15,10 +15,7 @@ export const DirectoryWithParentsAndChildrenResponse: core.serialization.ObjectS id: core.serialization.string(), parentId: core.serialization.property("parent_id", core.serialization.string().optional()), name: core.serialization.string(), - description: core.serialization.string().optional(), path: core.serialization.string(), - readme: core.serialization.string().optional(), - tags: core.serialization.list(core.serialization.string()), createdAt: core.serialization.property("created_at", core.serialization.date()), updatedAt: core.serialization.property("updated_at", core.serialization.date()), subdirectories: core.serialization.list(DirectoryResponse), @@ -31,10 +28,7 @@ export declare namespace DirectoryWithParentsAndChildrenResponse { id: string; parent_id?: string | null; name: string; - description?: string | null; path: string; - readme?: string | null; - tags: string[]; created_at: string; updated_at: string; subdirectories: DirectoryResponse.Raw[]; diff --git a/src/serialization/types/EvaluatorLogResponse.ts b/src/serialization/types/EvaluatorLogResponse.ts index 6dcdfa3f..17f40eb7 100644 --- a/src/serialization/types/EvaluatorLogResponse.ts +++ b/src/serialization/types/EvaluatorLogResponse.ts @@ -5,7 +5,6 @@ import * as serializers from "../index"; import * as Humanloop from "../../api/index"; import * as core from "../../core"; -import { ChatMessage } from "./ChatMessage"; import { EvaluatorLogResponseJudgment } from "./EvaluatorLogResponseJudgment"; export const EvaluatorLogResponse: core.serialization.ObjectSchema< @@ -38,7 +37,6 @@ export const EvaluatorLogResponse: core.serialization.ObjectSchema< environment: core.serialization.string().optional(), save: core.serialization.boolean().optional(), logId: core.serialization.property("log_id", core.serialization.string().optional()), - outputMessage: core.serialization.property("output_message", ChatMessage.optional()), judgment: EvaluatorLogResponseJudgment.optional(), markedCompleted: core.serialization.property("marked_completed", core.serialization.boolean().optional()), id: core.serialization.string(), @@ -78,7 +76,6 @@ export declare namespace EvaluatorLogResponse { environment?: string | null; save?: boolean | null; log_id?: string | null; - output_message?: ChatMessage.Raw | null; judgment?: EvaluatorLogResponseJudgment.Raw | null; marked_completed?: boolean | null; id: string; diff --git a/src/serialization/types/EvaluatorResponse.ts b/src/serialization/types/EvaluatorResponse.ts index 35122d90..a9600ae3 100644 --- a/src/serialization/types/EvaluatorResponse.ts +++ b/src/serialization/types/EvaluatorResponse.ts @@ -22,9 +22,6 @@ export const EvaluatorResponse: core.serialization.ObjectSchema< commitMessage: core.serialization.property("commit_message", core.serialization.string().optional()), spec: EvaluatorResponseSpec, name: core.serialization.string(), - description: core.serialization.string().optional(), - readme: core.serialization.string().optional(), - tags: core.serialization.list(core.serialization.string()).optional(), versionId: core.serialization.property("version_id", core.serialization.string()), type: core.serialization.stringLiteral("evaluator").optional(), environments: core.serialization.list(EnvironmentResponse).optional(), @@ -56,9 +53,6 @@ export declare namespace EvaluatorResponse { commit_message?: string | null; spec: EvaluatorResponseSpec.Raw; name: string; - description?: string | null; - readme?: string | null; - tags?: string[] | null; version_id: string; type?: "evaluator" | null; environments?: EnvironmentResponse.Raw[] | null; diff --git a/src/serialization/types/ExternalEvaluatorRequest.ts b/src/serialization/types/ExternalEvaluatorRequest.ts index 91a5e69a..d5111980 100644 --- a/src/serialization/types/ExternalEvaluatorRequest.ts +++ b/src/serialization/types/ExternalEvaluatorRequest.ts @@ -7,9 +7,6 @@ import * as Humanloop from "../../api/index"; import * as core from "../../core"; import { EvaluatorArgumentsType } from "./EvaluatorArgumentsType"; import { EvaluatorReturnTypeEnum } from "./EvaluatorReturnTypeEnum"; -import { EvaluatorJudgmentOptionResponse } from "./EvaluatorJudgmentOptionResponse"; -import { EvaluatorJudgmentNumberLimit } from "./EvaluatorJudgmentNumberLimit"; -import { Valence } from "./Valence"; export const ExternalEvaluatorRequest: core.serialization.ObjectSchema< serializers.ExternalEvaluatorRequest.Raw, @@ -18,9 +15,6 @@ export const ExternalEvaluatorRequest: core.serialization.ObjectSchema< argumentsType: core.serialization.property("arguments_type", EvaluatorArgumentsType), returnType: core.serialization.property("return_type", EvaluatorReturnTypeEnum), attributes: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), - options: core.serialization.list(EvaluatorJudgmentOptionResponse).optional(), - numberLimits: core.serialization.property("number_limits", EvaluatorJudgmentNumberLimit.optional()), - numberValence: core.serialization.property("number_valence", Valence.optional()), evaluatorType: core.serialization.property("evaluator_type", core.serialization.stringLiteral("external")), }); @@ -29,9 +23,6 @@ export declare namespace ExternalEvaluatorRequest { arguments_type: EvaluatorArgumentsType.Raw; return_type: EvaluatorReturnTypeEnum.Raw; attributes?: Record | null; - options?: EvaluatorJudgmentOptionResponse.Raw[] | null; - number_limits?: EvaluatorJudgmentNumberLimit.Raw | null; - number_valence?: Valence.Raw | null; evaluator_type: "external"; } } diff --git a/src/serialization/types/FlowResponse.ts b/src/serialization/types/FlowResponse.ts index 9ba24f15..3f977ad3 100644 --- a/src/serialization/types/FlowResponse.ts +++ b/src/serialization/types/FlowResponse.ts @@ -18,9 +18,6 @@ export const FlowResponse: core.serialization.ObjectSchema; commit_message?: string | null; name: string; - description?: string | null; - readme?: string | null; - tags?: string[] | null; version_id: string; type?: "flow" | null; environments?: EnvironmentResponse.Raw[] | null; diff --git a/src/serialization/types/HumanEvaluatorRequest.ts b/src/serialization/types/HumanEvaluatorRequest.ts index 3fae0485..271894ea 100644 --- a/src/serialization/types/HumanEvaluatorRequest.ts +++ b/src/serialization/types/HumanEvaluatorRequest.ts @@ -18,11 +18,11 @@ export const HumanEvaluatorRequest: core.serialization.ObjectSchema< argumentsType: core.serialization.property("arguments_type", EvaluatorArgumentsType), returnType: core.serialization.property("return_type", HumanEvaluatorRequestReturnType), attributes: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), + evaluatorType: core.serialization.property("evaluator_type", core.serialization.stringLiteral("human")), + instructions: core.serialization.string().optional(), options: core.serialization.list(EvaluatorJudgmentOptionResponse).optional(), numberLimits: core.serialization.property("number_limits", EvaluatorJudgmentNumberLimit.optional()), numberValence: core.serialization.property("number_valence", Valence.optional()), - evaluatorType: core.serialization.property("evaluator_type", core.serialization.stringLiteral("human")), - instructions: core.serialization.string().optional(), }); export declare namespace HumanEvaluatorRequest { @@ -30,10 +30,10 @@ export declare namespace HumanEvaluatorRequest { arguments_type: EvaluatorArgumentsType.Raw; return_type: HumanEvaluatorRequestReturnType.Raw; attributes?: Record | null; + evaluator_type: "human"; + instructions?: string | null; options?: EvaluatorJudgmentOptionResponse.Raw[] | null; number_limits?: EvaluatorJudgmentNumberLimit.Raw | null; number_valence?: Valence.Raw | null; - evaluator_type: "human"; - instructions?: string | null; } } diff --git a/src/serialization/types/LlmEvaluatorRequest.ts b/src/serialization/types/LlmEvaluatorRequest.ts index f247b474..65e3d954 100644 --- a/src/serialization/types/LlmEvaluatorRequest.ts +++ b/src/serialization/types/LlmEvaluatorRequest.ts @@ -7,9 +7,6 @@ import * as Humanloop from "../../api/index"; import * as core from "../../core"; import { EvaluatorArgumentsType } from "./EvaluatorArgumentsType"; import { EvaluatorReturnTypeEnum } from "./EvaluatorReturnTypeEnum"; -import { EvaluatorJudgmentOptionResponse } from "./EvaluatorJudgmentOptionResponse"; -import { EvaluatorJudgmentNumberLimit } from "./EvaluatorJudgmentNumberLimit"; -import { Valence } from "./Valence"; import { PromptKernelRequest } from "./PromptKernelRequest"; export const LlmEvaluatorRequest: core.serialization.ObjectSchema< @@ -19,9 +16,6 @@ export const LlmEvaluatorRequest: core.serialization.ObjectSchema< argumentsType: core.serialization.property("arguments_type", EvaluatorArgumentsType), returnType: core.serialization.property("return_type", EvaluatorReturnTypeEnum), attributes: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), - options: core.serialization.list(EvaluatorJudgmentOptionResponse).optional(), - numberLimits: core.serialization.property("number_limits", EvaluatorJudgmentNumberLimit.optional()), - numberValence: core.serialization.property("number_valence", Valence.optional()), evaluatorType: core.serialization.property("evaluator_type", core.serialization.stringLiteral("llm")), prompt: PromptKernelRequest.optional(), }); @@ -31,9 +25,6 @@ export declare namespace LlmEvaluatorRequest { arguments_type: EvaluatorArgumentsType.Raw; return_type: EvaluatorReturnTypeEnum.Raw; attributes?: Record | null; - options?: EvaluatorJudgmentOptionResponse.Raw[] | null; - number_limits?: EvaluatorJudgmentNumberLimit.Raw | null; - number_valence?: Valence.Raw | null; evaluator_type: "llm"; prompt?: PromptKernelRequest.Raw | null; } diff --git a/src/serialization/types/PromptResponse.ts b/src/serialization/types/PromptResponse.ts index 24f480aa..1455521e 100644 --- a/src/serialization/types/PromptResponse.ts +++ b/src/serialization/types/PromptResponse.ts @@ -43,9 +43,6 @@ export const PromptResponse: core.serialization.ObjectSchema | null; commit_message?: string | null; - description?: string | null; - tags?: string[] | null; - readme?: string | null; name: string; version_id: string; type?: "prompt" | null; diff --git a/src/serialization/types/ToolResponse.ts b/src/serialization/types/ToolResponse.ts index b4a46079..fa390bec 100644 --- a/src/serialization/types/ToolResponse.ts +++ b/src/serialization/types/ToolResponse.ts @@ -28,9 +28,6 @@ export const ToolResponse: core.serialization.ObjectSchema Date: Wed, 29 Jan 2025 17:35:20 +0000 Subject: [PATCH 2/4] add prompt_utils; tests --- src/prompt_utils.ts | 162 +++++++++++++++++++++++++ tests/utilities/populatePrompt.test.ts | 107 ++++++++++++++++ 2 files changed, 269 insertions(+) create mode 100644 src/prompt_utils.ts create mode 100644 tests/utilities/populatePrompt.test.ts diff --git a/src/prompt_utils.ts b/src/prompt_utils.ts new file mode 100644 index 00000000..3a5a974c --- /dev/null +++ b/src/prompt_utils.ts @@ -0,0 +1,162 @@ +import { ChatMessage, PromptRequestTemplate } from "api"; + +/** + * Custom error type for missing prompt variables. + */ +export class PromptVariablesNotFoundError extends Error { + public missingVariables: string[]; + + constructor(missingVariables: string[]) { + super( + `Prompt requires inputs for the following variables: ${missingVariables.join( + ", ", + )}`, + ); + this.missingVariables = missingVariables; + + // Set the prototype explicitly (needed when extending built-ins in TypeScript). + Object.setPrototypeOf(this, PromptVariablesNotFoundError.prototype); + } +} + +/** + * Escape special characters in a string for use in a regular expression pattern. + */ +function escapeRegExp(str: string): string { + // Replaces characters that have special meaning in RegExp with escaped versions. + return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + +/** + * Replace backslashes with escaped backslashes. + */ +function sanitizePrompt(prompt: string): string { + return prompt.replace(/\\/g, "\\\\"); +} + +/** + * Find and replace {{variable}} occurrences in a template string with the supplied inputs. + * Throws PromptVariablesNotFoundError if any template variables are missing. + */ +export function populatePromptTemplate( + template: string, + inputs?: Record, +): string { + // Regex to match variables like {{ variable_2 }} + const variableRegex1 = /{{\s?([a-zA-Z_\d.\[\]]+)\s?}}/g; + // Regex to match calls like {{ tool_2("args") }} + const variableRegex2 = /\{\{\s?([a-zA-Z_\-\d]+\([a-zA-Z_\-\d,\s"]+\))\s?\}\}/g; + + // Collect all template variables + const templateVariables: string[] = []; + + let match: RegExpExecArray | null; + while ((match = variableRegex1.exec(template)) !== null) { + templateVariables.push(match[1]); + } + while ((match = variableRegex2.exec(template)) !== null) { + templateVariables.push(match[1]); + } + + // Populate the template variables; track missing variables + let prompt = template; + const missingVars: string[] = []; + + if (!inputs) { + inputs = {}; + } + + for (const variable of templateVariables) { + let text: string | undefined = inputs[variable]; + + // If not provided, record as missing + if (text === undefined || text === null) { + missingVars.push(variable); + } else { + // Convert any non-string value to string + if (typeof text !== "string") { + console.info( + `Converting input value for variable '${variable}' to string: ${text}`, + ); + text = String(text); + } + const replacement = sanitizePrompt(text); + const variablePattern = new RegExp( + `{{\\s?${escapeRegExp(variable)}\\s?}}`, + "g", + ); + prompt = prompt.replace(variablePattern, replacement); + } + } + + if (missingVars.length > 0) { + missingVars.sort(); + throw new PromptVariablesNotFoundError(missingVars); + } + + return prompt; +} + +/** + * Accepts a sequence of ChatMessage and interpolates template variables in each message's content. + */ +export function populateChatTemplate( + chatTemplate: ChatMessage[], + inputs?: Record, +): ChatMessage[] { + const messages: ChatMessage[] = []; + + for (const message of chatTemplate) { + // If there's no "content", push as-is. + if (!("content" in message)) { + messages.push(message); + continue; + } + + // Deep copy the content so we don't mutate the original object. + // (Depending on your environment, you might prefer a structured clone + // or a third-party solution for deep copying.) + let messageContent = JSON.parse(JSON.stringify(message.content)); + + if (typeof messageContent === "string") { + messageContent = populatePromptTemplate(messageContent, inputs); + } else if (Array.isArray(messageContent)) { + // If content is an array, try to populate any "text" fields + for (let i = 0; i < messageContent.length; i++) { + const contentItem = messageContent[i]; + if ( + contentItem.type === "text" && + typeof contentItem.text === "string" + ) { + contentItem.text = populatePromptTemplate(contentItem.text, inputs); + } + } + } + + messages.push({ + role: message.role, + content: messageContent, + }); + } + return messages; +} + +/** + * Populates a string-based prompt or chat-based prompt with the given inputs. + * For string prompts, all occurrences of {{var}} are replaced using populatePromptTemplate. + * For chat prompts (array of ChatMessageParams), each message is handled by populateChatTemplate. + */ +export function populateTemplate( + template: T, + inputs: Record, +): T { + if (typeof template === "string") { + // String-based prompt + return populatePromptTemplate(template, inputs) as T; + } else if (Array.isArray(template)) { + // Chat-based prompt + return populateChatTemplate(template, inputs) as T; + } + // If you have other template forms, handle them here. + return template; +} diff --git a/tests/utilities/populatePrompt.test.ts b/tests/utilities/populatePrompt.test.ts new file mode 100644 index 00000000..b174e66c --- /dev/null +++ b/tests/utilities/populatePrompt.test.ts @@ -0,0 +1,107 @@ +import { ChatMessage } from "../../src/api"; +import { + PromptVariablesNotFoundError, + populateChatTemplate, + populatePromptTemplate, + populateTemplate, +} from "../../src/prompt_utils"; + +describe("Prompt Utils", () => { + describe("populatePromptTemplate", () => { + it("replaces simple variables", () => { + const template = "Hello {{name}}!"; + const result = populatePromptTemplate(template, { name: "Alice" }); + expect(result).toBe("Hello Alice!"); + }); + + it("handles multiple variables", () => { + const template = "{{greeting}} {{name}}, how are you?"; + const result = populatePromptTemplate(template, { + greeting: "Hi", + name: "Bob", + }); + expect(result).toBe("Hi Bob, how are you?"); + }); + + it("handles whitespace in variable syntax", () => { + const template = "Hello {{ name }}!"; + const result = populatePromptTemplate(template, { name: "Charlie" }); + expect(result).toBe("Hello Charlie!"); + }); + + it("handles tool calls", () => { + const template = 'Using tool: {{ tool_1("arg1", "arg2") }}'; + const result = populatePromptTemplate(template, { + 'tool_1("arg1", "arg2")': "result", + }); + expect(result).toBe("Using tool: result"); + }); + + it("converts non-string values to strings", () => { + const template = "Number: {{num}}"; + const result = populatePromptTemplate(template, { num: 42 }); + expect(result).toBe("Number: 42"); + }); + + it("throws PromptVariablesNotFoundError for missing variables", () => { + const template = "Hello {{name}}!"; + expect(() => populatePromptTemplate(template, {})).toThrow( + PromptVariablesNotFoundError, + ); + }); + }); + + describe("populateChatTemplate", () => { + it("populates string content in chat messages", () => { + const template: ChatMessage[] = [ + { role: "user", content: "My name is {{name}}" }, + ]; + const result = populateChatTemplate(template, { name: "David" }); + expect(result).toEqual([{ role: "user", content: "My name is David" }]); + }); + + it("populates array content in chat messages", () => { + const template: ChatMessage[] = [ + { + role: "user", + content: [ + { type: "text", text: "Hello {{name}}" }, + { type: "text", text: "Second text" }, + ], + }, + ]; + const result = populateChatTemplate(template, { name: "Eve" }); + expect(result).toEqual([ + { + role: "user", + content: [ + { type: "text", text: "Hello Eve" }, + { type: "text", text: "Second text" }, + ], + }, + ]); + }); + + it("preserves messages without content", () => { + const template: ChatMessage[] = [{ role: "system", content: "" }]; + const result = populateChatTemplate(template); + expect(result).toEqual(template); + }); + }); + + describe("populateTemplate", () => { + it("handles string templates", () => { + const template = "Hello {{name}}!"; + const result = populateTemplate(template, { name: "Frank" }); + expect(result).toBe("Hello Frank!"); + }); + + it("handles chat templates", () => { + const template: ChatMessage[] = [ + { role: "user", content: "Hello {{name}}!" }, + ]; + const result = populateTemplate(template, { name: "Grace" }); + expect(result).toEqual([{ role: "user", content: "Hello Grace!" }]); + }); + }); +}); From 6ffb3a45fe134ee910ab287117d6414c5b06e7b6 Mon Sep 17 00:00:00 2001 From: Harry Xie Date: Wed, 29 Jan 2025 17:36:15 +0000 Subject: [PATCH 3/4] add prompt_utils to fernignore --- .fernignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.fernignore b/.fernignore index 32936243..4bd805f5 100644 --- a/.fernignore +++ b/.fernignore @@ -4,6 +4,7 @@ src/otel src/eval_utils +src/prompt_utils.ts src/utilities src/index.ts src/humanloop.client.ts From 4d95329fce0a54a2594d02451ee077a40d301d81 Mon Sep 17 00:00:00 2001 From: Harry Xie Date: Wed, 29 Jan 2025 18:13:07 +0000 Subject: [PATCH 4/4] remove ai comments --- src/prompt_utils.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/prompt_utils.ts b/src/prompt_utils.ts index 3a5a974c..6fe1b217 100644 --- a/src/prompt_utils.ts +++ b/src/prompt_utils.ts @@ -1,8 +1,5 @@ import { ChatMessage, PromptRequestTemplate } from "api"; -/** - * Custom error type for missing prompt variables. - */ export class PromptVariablesNotFoundError extends Error { public missingVariables: string[]; @@ -114,8 +111,6 @@ export function populateChatTemplate( } // Deep copy the content so we don't mutate the original object. - // (Depending on your environment, you might prefer a structured clone - // or a third-party solution for deep copying.) let messageContent = JSON.parse(JSON.stringify(message.content)); if (typeof messageContent === "string") { @@ -144,7 +139,7 @@ export function populateChatTemplate( /** * Populates a string-based prompt or chat-based prompt with the given inputs. * For string prompts, all occurrences of {{var}} are replaced using populatePromptTemplate. - * For chat prompts (array of ChatMessageParams), each message is handled by populateChatTemplate. + * For chat prompts (array of ChatMessage), each message is handled by populateChatTemplate. */ export function populateTemplate( template: T, @@ -157,6 +152,5 @@ export function populateTemplate( // Chat-based prompt return populateChatTemplate(template, inputs) as T; } - // If you have other template forms, handle them here. return template; }