humanloop
TypeScript icon, indicating that this package has built-in type declarations

0.6.0-alpha.22 • Public • Published

Table of Contents

Installation

npm pnpm yarn
npm i humanloop
pnpm i humanloop
yarn add humanloop

Streaming Support

This SDK supports streaming, see example usage in a NextJS application here

Getting Started

import { Humanloop } from "humanloop";

const humanloop = new Humanloop({
  // Defining the base path is optional and defaults to https://api.humanloop.com/v4
  // basePath: "https://api.humanloop.com/v4",
  openaiApiKey: "openaiApiKey",
  anthropicApiKey: "anthropicApiKey",
  apiKey: "API_KEY",
});

const chatResponse = await humanloop.chat({
  project: "sdk-example",
  messages: [
    {
      role: "user",
      content: "Explain asynchronous programming.",
    },
  ],
  model_config: {
    model: "gpt-3.5-turbo",
    max_tokens: -1,
    temperature: 0.7,
    chat_template: [
      {
        role: "system",
        content:
          "You are a helpful assistant who replies in the style of {{persona}}.",
      },
    ],
  },
  inputs: {
    persona: "the pirate Blackbeard",
  },
  stream: false,
});

console.log(chatResponse);

const completeResponse = await humanloop.complete({
  project: "sdk-example",
  inputs: {
    text: "Llamas that are well-socialized and trained to halter and lead after weaning and are very friendly and pleasant to be around. They are extremely curious and most will approach people easily. However, llamas that are bottle-fed or over-socialized and over-handled as youth will become extremely difficult to handle when mature, when they will begin to treat humans as they treat each other, which is characterized by bouts of spitting, kicking and neck wrestling.[33]",
  },
  model_config: {
    model: "gpt-3.5-turbo",
    max_tokens: -1,
    temperature: 0.7,
    prompt_template:
      "Summarize this for a second-grade student:\n\nText:\n{{text}}\n\nSummary:\n",
  },
  stream: false,
});

console.log(completeResponse);

const feedbackResponse = await humanloop.feedback({
  type: "rating",
  value: "good",
  data_id: "data_[...]",
  user: "user@example.com",
});

console.log(feedbackResponse);

const logResponse = await humanloop.log({
  project: "sdk-example",
  inputs: {
    text: "Llamas that are well-socialized and trained to halter and lead after weaning and are very friendly and pleasant to be around. They are extremely curious and most will approach people easily. However, llamas that are bottle-fed or over-socialized and over-handled as youth will become extremely difficult to handle when mature, when they will begin to treat humans as they treat each other, which is characterized by bouts of spitting, kicking and neck wrestling.[33]",
  },
  output:
    "Llamas can be friendly and curious if they are trained to be around people, but if they are treated too much like pets when they are young, they can become difficult to handle when they grow up. This means they might spit, kick, and wrestle with their necks.",
  source: "sdk",
  config: {
    model: "gpt-3.5-turbo",
    max_tokens: -1,
    temperature: 0.7,
    prompt_template:
      "Summarize this for a second-grade student:\n\nText:\n{{text}}\n\nSummary:\n",
    type: "model",
  },
});

console.log(logResponse);

Reference

humanloop.chat

Get a chat response by providing details of the model configuration in the request.

🛠️ Usage

const createResponse = await humanloop.chat({
  save: true,
  num_samples: 1,
  stream: false,
  return_inputs: true,
  messages: [
    {
      role: "user",
    },
  ],
  model_config: {
    provider: "openai",
    model: "model_example",
    max_tokens: -1,
    temperature: 1,
    top_p: 1,
    presence_penalty: 0,
    frequency_penalty: 0,
    endpoint: "complete",
  },
});

⚙️ Parameters

The messages passed to the to provider chat endpoint.

model_config: ModelConfigChatRequest

The model configuration used to create a chat response.

project: string

Unique project name. If no project exists with this name, a new project will be created.

project_id: string

Unique ID of a project to associate to the log. Either this or project must be provided.

session_id: string

ID of the session to associate the datapoint.

session_reference_id: string

A unique string identifying the session to associate the datapoint to. Allows you to log multiple datapoints to a session (using an ID kept by your internal systems) by passing the same session_reference_id in subsequent log requests. Specify at most one of this or session_id.

parent_id: string

ID associated to the parent datapoint in a session.

parent_reference_id: string

A unique string identifying the previously-logged parent datapoint in a session. Allows you to log nested datapoints with your internal system IDs by passing the same reference ID as parent_id in a prior log request. Specify at most one of this or parent_id. Note that this cannot refer to a datapoint being logged in the same request.

inputs: object

The inputs passed to the prompt template.

source: string

Identifies where the model was called from.

metadata: object

Any additional metadata to record.

save: boolean

Whether the request/response payloads will be stored on Humanloop.

source_datapoint_id: string

ID of the source datapoint if this is a log derived from a datapoint in a dataset.

provider_api_keys: ProviderApiKeys

API keys required by each provider to make API calls. The API keys provided here are not stored by Humanloop. If not specified here, Humanloop will fall back to the key saved to your organization.

num_samples: number

The number of generations.

stream: boolean

If true, tokens will be sent as data-only server-sent events. If num_samples > 1, samples are streamed back independently.

user: string

End-user ID passed through to provider call.

seed: number

Deprecated field: the seed is instead set as part of the request.config object.

return_inputs: boolean

Whether to return the inputs in the response. If false, the response will contain an empty dictionary under inputs. This is useful for reducing the size of the response. Defaults to true.

tool_choice: ToolChoiceProperty
tool_call: ToolCallProperty
response_format: ResponseFormat

The format of the response. Only type json_object is currently supported for chat.

🔄 Return

ChatResponse

🌐 Endpoint

/chat POST

🔙 Back to Table of Contents


humanloop.chatDeployed

Get a chat response using the project's active deployment.

The active deployment can be a specific model configuration or an experiment.

🛠️ Usage

const createDeployedResponse = await humanloop.chatDeployed({
  save: true,
  num_samples: 1,
  stream: false,
  return_inputs: true,
  messages: [
    {
      role: "user",
    },
  ],
});

⚙️ Parameters

The messages passed to the to provider chat endpoint.

project: string

Unique project name. If no project exists with this name, a new project will be created.

project_id: string

Unique ID of a project to associate to the log. Either this or project must be provided.

session_id: string

ID of the session to associate the datapoint.

session_reference_id: string

A unique string identifying the session to associate the datapoint to. Allows you to log multiple datapoints to a session (using an ID kept by your internal systems) by passing the same session_reference_id in subsequent log requests. Specify at most one of this or session_id.

parent_id: string

ID associated to the parent datapoint in a session.

parent_reference_id: string

A unique string identifying the previously-logged parent datapoint in a session. Allows you to log nested datapoints with your internal system IDs by passing the same reference ID as parent_id in a prior log request. Specify at most one of this or parent_id. Note that this cannot refer to a datapoint being logged in the same request.

inputs: object

The inputs passed to the prompt template.

source: string

Identifies where the model was called from.

metadata: object

Any additional metadata to record.

save: boolean

Whether the request/response payloads will be stored on Humanloop.

source_datapoint_id: string

ID of the source datapoint if this is a log derived from a datapoint in a dataset.

provider_api_keys: ProviderApiKeys

API keys required by each provider to make API calls. The API keys provided here are not stored by Humanloop. If not specified here, Humanloop will fall back to the key saved to your organization.

num_samples: number

The number of generations.

stream: boolean

If true, tokens will be sent as data-only server-sent events. If num_samples > 1, samples are streamed back independently.

user: string

End-user ID passed through to provider call.

seed: number

Deprecated field: the seed is instead set as part of the request.config object.

return_inputs: boolean

Whether to return the inputs in the response. If false, the response will contain an empty dictionary under inputs. This is useful for reducing the size of the response. Defaults to true.

tool_choice: ToolChoiceProperty
tool_call: ToolCallProperty
response_format: ResponseFormat

The format of the response. Only type json_object is currently supported for chat.

environment: string

The environment name used to create a chat response. If not specified, the default environment will be used.

🔄 Return

ChatResponse

🌐 Endpoint

/chat-deployed POST

🔙 Back to Table of Contents


humanloop.chatExperiment

Get a chat response for a specific experiment.

🛠️ Usage

const createExperimentResponse = await humanloop.chatExperiment({
  save: true,
  num_samples: 1,
  stream: false,
  return_inputs: true,
  messages: [
    {
      role: "user",
    },
  ],
  experiment_id: "experiment_id_example",
});

⚙️ Parameters

The messages passed to the to provider chat endpoint.

experiment_id: string

If an experiment ID is provided a model configuration will be sampled from the experiments active model configurations.

project: string

Unique project name. If no project exists with this name, a new project will be created.

project_id: string

Unique ID of a project to associate to the log. Either this or project must be provided.

session_id: string

ID of the session to associate the datapoint.

session_reference_id: string

A unique string identifying the session to associate the datapoint to. Allows you to log multiple datapoints to a session (using an ID kept by your internal systems) by passing the same session_reference_id in subsequent log requests. Specify at most one of this or session_id.

parent_id: string

ID associated to the parent datapoint in a session.

parent_reference_id: string

A unique string identifying the previously-logged parent datapoint in a session. Allows you to log nested datapoints with your internal system IDs by passing the same reference ID as parent_id in a prior log request. Specify at most one of this or parent_id. Note that this cannot refer to a datapoint being logged in the same request.

inputs: object

The inputs passed to the prompt template.

source: string

Identifies where the model was called from.

metadata: object

Any additional metadata to record.

save: boolean

Whether the request/response payloads will be stored on Humanloop.

source_datapoint_id: string

ID of the source datapoint if this is a log derived from a datapoint in a dataset.

provider_api_keys: ProviderApiKeys

API keys required by each provider to make API calls. The API keys provided here are not stored by Humanloop. If not specified here, Humanloop will fall back to the key saved to your organization.

num_samples: number

The number of chat responses, where each chat response will use a model configuration sampled from the experiment.

stream: boolean

If true, tokens will be sent as data-only server-sent events. If num_samples > 1, samples are streamed back independently.

user: string

End-user ID passed through to provider call.

seed: number

Deprecated field: the seed is instead set as part of the request.config object.

return_inputs: boolean

Whether to return the inputs in the response. If false, the response will contain an empty dictionary under inputs. This is useful for reducing the size of the response. Defaults to true.

tool_choice: ToolChoiceProperty
tool_call: ToolCallProperty
response_format: ResponseFormat

The format of the response. Only type json_object is currently supported for chat.

🔄 Return

ChatResponse

🌐 Endpoint

/chat-experiment POST

🔙 Back to Table of Contents


humanloop.chatModelConfig

Get chat response for a specific model configuration.

🛠️ Usage

const createModelConfigResponse = await humanloop.chatModelConfig({
  save: true,
  num_samples: 1,
  stream: false,
  return_inputs: true,
  messages: [
    {
      role: "user",
    },
  ],
  model_config_id: "model_config_id_example",
});

⚙️ Parameters

The messages passed to the to provider chat endpoint.

model_config_id: string

Identifies the model configuration used to create a chat response.

project: string

Unique project name. If no project exists with this name, a new project will be created.

project_id: string

Unique ID of a project to associate to the log. Either this or project must be provided.

session_id: string

ID of the session to associate the datapoint.

session_reference_id: string

A unique string identifying the session to associate the datapoint to. Allows you to log multiple datapoints to a session (using an ID kept by your internal systems) by passing the same session_reference_id in subsequent log requests. Specify at most one of this or session_id.

parent_id: string

ID associated to the parent datapoint in a session.

parent_reference_id: string

A unique string identifying the previously-logged parent datapoint in a session. Allows you to log nested datapoints with your internal system IDs by passing the same reference ID as parent_id in a prior log request. Specify at most one of this or parent_id. Note that this cannot refer to a datapoint being logged in the same request.

inputs: object

The inputs passed to the prompt template.

source: string

Identifies where the model was called from.

metadata: object

Any additional metadata to record.

save: boolean

Whether the request/response payloads will be stored on Humanloop.

source_datapoint_id: string

ID of the source datapoint if this is a log derived from a datapoint in a dataset.

provider_api_keys: ProviderApiKeys

API keys required by each provider to make API calls. The API keys provided here are not stored by Humanloop. If not specified here, Humanloop will fall back to the key saved to your organization.

num_samples: number

The number of generations.

stream: boolean

If true, tokens will be sent as data-only server-sent events. If num_samples > 1, samples are streamed back independently.

user: string

End-user ID passed through to provider call.

seed: number

Deprecated field: the seed is instead set as part of the request.config object.

return_inputs: boolean

Whether to return the inputs in the response. If false, the response will contain an empty dictionary under inputs. This is useful for reducing the size of the response. Defaults to true.

tool_choice: ToolChoiceProperty
tool_call: ToolCallProperty
response_format: ResponseFormat

The format of the response. Only type json_object is currently supported for chat.

🔄 Return

ChatResponse

🌐 Endpoint

/chat-model-config POST

🔙 Back to Table of Contents


humanloop.complete

Create a completion by providing details of the model configuration in the request.

🛠️ Usage

const createResponse = await humanloop.complete({
  save: true,
  num_samples: 1,
  stream: false,
  return_inputs: true,
  model_config: {
    provider: "openai",
    model: "model_example",
    max_tokens: -1,
    temperature: 1,
    top_p: 1,
    presence_penalty: 0,
    frequency_penalty: 0,
    endpoint: "complete",
    prompt_template: "{{question}}",
  },
});

⚙️ Parameters

The model configuration used to generate.

project: string

Unique project name. If no project exists with this name, a new project will be created.

project_id: string

Unique ID of a project to associate to the log. Either this or project must be provided.

session_id: string

ID of the session to associate the datapoint.

session_reference_id: string

A unique string identifying the session to associate the datapoint to. Allows you to log multiple datapoints to a session (using an ID kept by your internal systems) by passing the same session_reference_id in subsequent log requests. Specify at most one of this or session_id.

parent_id: string

ID associated to the parent datapoint in a session.

parent_reference_id: string

A unique string identifying the previously-logged parent datapoint in a session. Allows you to log nested datapoints with your internal system IDs by passing the same reference ID as parent_id in a prior log request. Specify at most one of this or parent_id. Note that this cannot refer to a datapoint being logged in the same request.

inputs: object

The inputs passed to the prompt template.

source: string

Identifies where the model was called from.

metadata: object

Any additional metadata to record.

save: boolean

Whether the request/response payloads will be stored on Humanloop.

source_datapoint_id: string

ID of the source datapoint if this is a log derived from a datapoint in a dataset.

provider_api_keys: ProviderApiKeys

API keys required by each provider to make API calls. The API keys provided here are not stored by Humanloop. If not specified here, Humanloop will fall back to the key saved to your organization.

num_samples: number

The number of generations.

stream: boolean

If true, tokens will be sent as data-only server-sent events. If num_samples > 1, samples are streamed back independently.

user: string

End-user ID passed through to provider call.

seed: number

Deprecated field: the seed is instead set as part of the request.config object.

return_inputs: boolean

Whether to return the inputs in the response. If false, the response will contain an empty dictionary under inputs. This is useful for reducing the size of the response. Defaults to true.

logprobs: number

Include the log probabilities of the top n tokens in the provider_response

suffix: string

The suffix that comes after a completion of inserted text. Useful for completions that act like inserts.

🔄 Return

CompletionResponse

🌐 Endpoint

/completion POST

🔙 Back to Table of Contents


humanloop.completeDeployed

Create a completion using the project's active deployment.

The active deployment can be a specific model configuration or an experiment.

🛠️ Usage

const createDeployedResponse = await humanloop.completeDeployed({
  save: true,
  num_samples: 1,
  stream: false,
  return_inputs: true,
});

⚙️ Parameters

project: string

Unique project name. If no project exists with this name, a new project will be created.

project_id: string

Unique ID of a project to associate to the log. Either this or project must be provided.

session_id: string

ID of the session to associate the datapoint.

session_reference_id: string

A unique string identifying the session to associate the datapoint to. Allows you to log multiple datapoints to a session (using an ID kept by your internal systems) by passing the same session_reference_id in subsequent log requests. Specify at most one of this or session_id.

parent_id: string

ID associated to the parent datapoint in a session.

parent_reference_id: string

A unique string identifying the previously-logged parent datapoint in a session. Allows you to log nested datapoints with your internal system IDs by passing the same reference ID as parent_id in a prior log request. Specify at most one of this or parent_id. Note that this cannot refer to a datapoint being logged in the same request.

inputs: object

The inputs passed to the prompt template.

source: string

Identifies where the model was called from.

metadata: object

Any additional metadata to record.

save: boolean

Whether the request/response payloads will be stored on Humanloop.

source_datapoint_id: string

ID of the source datapoint if this is a log derived from a datapoint in a dataset.

provider_api_keys: ProviderApiKeys

API keys required by each provider to make API calls. The API keys provided here are not stored by Humanloop. If not specified here, Humanloop will fall back to the key saved to your organization.

num_samples: number

The number of generations.

stream: boolean

If true, tokens will be sent as data-only server-sent events. If num_samples > 1, samples are streamed back independently.

user: string

End-user ID passed through to provider call.

seed: number

Deprecated field: the seed is instead set as part of the request.config object.

return_inputs: boolean

Whether to return the inputs in the response. If false, the response will contain an empty dictionary under inputs. This is useful for reducing the size of the response. Defaults to true.

logprobs: number

Include the log probabilities of the top n tokens in the provider_response

suffix: string

The suffix that comes after a completion of inserted text. Useful for completions that act like inserts.

environment: string

The environment name used to create a chat response. If not specified, the default environment will be used.

🔄 Return

CompletionResponse

🌐 Endpoint

/completion-deployed POST

🔙 Back to Table of Contents


humanloop.completeExperiment

Create a completion for a specific experiment.

🛠️ Usage

const createExperimentResponse = await humanloop.completeExperiment({
  save: true,
  num_samples: 1,
  stream: false,
  return_inputs: true,
  experiment_id: "experiment_id_example",
});

⚙️ Parameters

experiment_id: string

If an experiment ID is provided a model configuration will be sampled from the experiments active model configurations.

project: string

Unique project name. If no project exists with this name, a new project will be created.

project_id: string

Unique ID of a project to associate to the log. Either this or project must be provided.

session_id: string

ID of the session to associate the datapoint.

session_reference_id: string

A unique string identifying the session to associate the datapoint to. Allows you to log multiple datapoints to a session (using an ID kept by your internal systems) by passing the same session_reference_id in subsequent log requests. Specify at most one of this or session_id.

parent_id: string

ID associated to the parent datapoint in a session.

parent_reference_id: string

A unique string identifying the previously-logged parent datapoint in a session. Allows you to log nested datapoints with your internal system IDs by passing the same reference ID as parent_id in a prior log request. Specify at most one of this or parent_id. Note that this cannot refer to a datapoint being logged in the same request.

inputs: object

The inputs passed to the prompt template.

source: string

Identifies where the model was called from.

metadata: object

Any additional metadata to record.

save: boolean

Whether the request/response payloads will be stored on Humanloop.

source_datapoint_id: string

ID of the source datapoint if this is a log derived from a datapoint in a dataset.

provider_api_keys: ProviderApiKeys

API keys required by each provider to make API calls. The API keys provided here are not stored by Humanloop. If not specified here, Humanloop will fall back to the key saved to your organization.

num_samples: number

The number of chat responses, where each chat response will use a model configuration sampled from the experiment.

stream: boolean

If true, tokens will be sent as data-only server-sent events. If num_samples > 1, samples are streamed back independently.

user: string

End-user ID passed through to provider call.

seed: number

Deprecated field: the seed is instead set as part of the request.config object.

return_inputs: boolean

Whether to return the inputs in the response. If false, the response will contain an empty dictionary under inputs. This is useful for reducing the size of the response. Defaults to true.

logprobs: number

Include the log probabilities of the top n tokens in the provider_response

suffix: string

The suffix that comes after a completion of inserted text. Useful for completions that act like inserts.

🔄 Return

CompletionResponse

🌐 Endpoint

/completion-experiment POST

🔙 Back to Table of Contents


humanloop.completeModelConfiguration

Create a completion for a specific model configuration.

🛠️ Usage

const createModelConfigResponse = await humanloop.completeModelConfiguration({
  save: true,
  num_samples: 1,
  stream: false,
  return_inputs: true,
  model_config_id: "model_config_id_example",
});

⚙️ Parameters

model_config_id: string

Identifies the model configuration used to create a chat response.

project: string

Unique project name. If no project exists with this name, a new project will be created.

project_id: string

Unique ID of a project to associate to the log. Either this or project must be provided.

session_id: string

ID of the session to associate the datapoint.

session_reference_id: string

A unique string identifying the session to associate the datapoint to. Allows you to log multiple datapoints to a session (using an ID kept by your internal systems) by passing the same session_reference_id in subsequent log requests. Specify at most one of this or session_id.

parent_id: string

ID associated to the parent datapoint in a session.

parent_reference_id: string

A unique string identifying the previously-logged parent datapoint in a session. Allows you to log nested datapoints with your internal system IDs by passing the same reference ID as parent_id in a prior log request. Specify at most one of this or parent_id. Note that this cannot refer to a datapoint being logged in the same request.

inputs: object

The inputs passed to the prompt template.

source: string

Identifies where the model was called from.

metadata: object

Any additional metadata to record.

save: boolean

Whether the request/response payloads will be stored on Humanloop.

source_datapoint_id: string

ID of the source datapoint if this is a log derived from a datapoint in a dataset.

provider_api_keys: ProviderApiKeys

API keys required by each provider to make API calls. The API keys provided here are not stored by Humanloop. If not specified here, Humanloop will fall back to the key saved to your organization.

num_samples: number

The number of generations.

stream: boolean

If true, tokens will be sent as data-only server-sent events. If num_samples > 1, samples are streamed back independently.

user: string

End-user ID passed through to provider call.

seed: number

Deprecated field: the seed is instead set as part of the request.config object.

return_inputs: boolean

Whether to return the inputs in the response. If false, the response will contain an empty dictionary under inputs. This is useful for reducing the size of the response. Defaults to true.

logprobs: number

Include the log probabilities of the top n tokens in the provider_response

suffix: string

The suffix that comes after a completion of inserted text. Useful for completions that act like inserts.

🔄 Return

CompletionResponse

🌐 Endpoint

/completion-model-config POST

🔙 Back to Table of Contents


humanloop.datapoints.delete

Delete a list of datapoints by their IDs.

WARNING: This endpoint has been decommisioned and no longer works. Please use the v5 datasets API instead.

🛠️ Usage

const deleteResponse = await humanloop.datapoints.delete();

🌐 Endpoint

/datapoints DELETE

🔙 Back to Table of Contents


humanloop.datapoints.get

Get a datapoint by ID.

🛠️ Usage

const getResponse = await humanloop.datapoints.get({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of datapoint.

🔄 Return

DatapointResponse

🌐 Endpoint

/datapoints/{id} GET

🔙 Back to Table of Contents


humanloop.datapoints.update

Edit the input, messages and criteria fields of a datapoint.

WARNING: This endpoint has been decommisioned and no longer works. Please use the v5 datasets API instead.

🛠️ Usage

const updateResponse = await humanloop.datapoints.update({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of datapoint.

🔄 Return

DatapointResponse

🌐 Endpoint

/datapoints/{id} PATCH

🔙 Back to Table of Contents


humanloop.datasets.create

Create a new dataset for a project.

🛠️ Usage

const createResponse = await humanloop.datasets.create({
  projectId: "projectId_example",
  description: "description_example",
  name: "name_example",
});

⚙️ Parameters

description: string

The description of the dataset.

name: string

The name of the dataset.

projectId: string

🔄 Return

DatasetResponse

🌐 Endpoint

/projects/{project_id}/datasets POST

🔙 Back to Table of Contents


humanloop.datasets.createDatapoint

Create a new datapoint for a dataset.

Here in the v4 API, this has the following behaviour:

  • Retrieve the current latest version of the dataset.
  • Construct a new version of the dataset with the new testcases added.
  • Store that latest version as a committed version with an autogenerated commit message and return the new datapoints

🛠️ Usage

const createDatapointResponse = await humanloop.datasets.createDatapoint({
  datasetId: "dataset_id_example",
  requestBody: {
    log_ids: ["log_ids_example"],
  },
});

⚙️ Parameters

datasetId: string

String ID of dataset. Starts with evts_.

🔄 Return

DatapointResponse

🌐 Endpoint

/datasets/{dataset_id}/datapoints POST

🔙 Back to Table of Contents


humanloop.datasets.delete

Delete a dataset by ID.

🛠️ Usage

const deleteResponse = await humanloop.datasets.delete({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of dataset. Starts with evts_.

🌐 Endpoint

/datasets/{id} DELETE

🔙 Back to Table of Contents


humanloop.datasets.get

Get a single dataset by ID.

🛠️ Usage

const getResponse = await humanloop.datasets.get({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of dataset. Starts with evts_.

🔄 Return

DatasetResponse

🌐 Endpoint

/datasets/{id} GET

🔙 Back to Table of Contents


humanloop.datasets.list

Get all Datasets for an organization.

🛠️ Usage

const listResponse = await humanloop.datasets.list();

🔄 Return

DatasetResponse

🌐 Endpoint

/datasets GET

🔙 Back to Table of Contents


humanloop.datasets.listAllForProject

Get all datasets for a project.

🛠️ Usage

const listAllForProjectResponse = await humanloop.datasets.listAllForProject({
  projectId: "projectId_example",
});

⚙️ Parameters

projectId: string

🔄 Return

DatasetResponse

🌐 Endpoint

/projects/{project_id}/datasets GET

🔙 Back to Table of Contents


humanloop.datasets.listDatapoints

Get datapoints for a dataset.

🛠️ Usage

const listDatapointsResponse = await humanloop.datasets.listDatapoints({
  datasetId: "datasetId_example",
  page: 0,
  size: 50,
});

⚙️ Parameters

datasetId: string

String ID of dataset. Starts with evts_.

page: number
size: number

🔄 Return

PaginatedDataDatapointResponse

🌐 Endpoint

/datasets/{dataset_id}/datapoints GET

🔙 Back to Table of Contents


humanloop.datasets.update

Update a testset by ID.

🛠️ Usage

const updateResponse = await humanloop.datasets.update({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of testset. Starts with evts_.

description: string

The description of the dataset.

name: string

The name of the dataset.

🔄 Return

DatasetResponse

🌐 Endpoint

/datasets/{id} PATCH

🔙 Back to Table of Contents


humanloop.evaluations.addEvaluators

Add evaluators to an existing evaluation run.

🛠️ Usage

const addEvaluatorsResponse = await humanloop.evaluations.addEvaluators({
  id: "id_example",
  evaluator_ids: ["evaluator_ids_example"],
});

⚙️ Parameters

evaluator_ids: string[]

IDs of evaluators to add to the evaluation run. IDs start with evfn_

id: string

String ID of evaluation run. Starts with ev_.

🔄 Return

EvaluationResponse

🌐 Endpoint

/evaluations/{id}/evaluators PATCH

🔙 Back to Table of Contents


humanloop.evaluations.create

Create an evaluation.

🛠️ Usage

const createResponse = await humanloop.evaluations.create({
  projectId: "projectId_example",
  config_id: "config_id_example",
  evaluator_ids: ["evaluator_ids_example"],
  dataset_id: "dataset_id_example",
  max_concurrency: 5,
  hl_generated: true,
});

⚙️ Parameters

config_id: string

ID of the config to evaluate. Starts with config_.

evaluator_ids: string[]

IDs of evaluators to run on the dataset. IDs start with evfn_

dataset_id: string

ID of the dataset to use in this evaluation. Starts with evts_.

projectId: string

String ID of project. Starts with pr_.

provider_api_keys: ProviderApiKeys

API keys required by each provider to make API calls. The API keys provided here are not stored by Humanloop. If not specified here, Humanloop will fall back to the key saved to your organization. Ensure you provide an API key for the provider for the model config you are evaluating, or have one saved to your organization.

max_concurrency: number

The maximum number of concurrent generations to run. A higher value will result in faster completion of the evaluation but may place higher load on your provider rate-limits.

hl_generated: boolean

Whether the log generations for this evaluation should be performed by Humanloop. If False, the log generations should be submitted by the user via the API.

🔄 Return

EvaluationResponse

🌐 Endpoint

/projects/{project_id}/evaluations POST

🔙 Back to Table of Contents


humanloop.evaluations.get

Get evaluation by ID.

🛠️ Usage

const getResponse = await humanloop.evaluations.get({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of evaluation run. Starts with ev_.

evaluatorAggregates: boolean

Whether to include evaluator aggregates in the response.

🔄 Return

EvaluationResponse

🌐 Endpoint

/evaluations/{id} GET

🔙 Back to Table of Contents


humanloop.evaluations.list

Get the evaluations associated with a project.

Sorting and filtering are supported through query params for categorical columns and the created_at timestamp.

Sorting is supported for the dataset, config, status and evaluator-{evaluator_id} columns. Specify sorting with the sort query param, with values {column}.{ordering}. E.g. ?sort=dataset.asc&sort=status.desc will yield a multi-column sort. First by dataset then by status.

Filtering is supported for the id, dataset, config and status columns.

Specify filtering with the id_filter, dataset_filter, config_filter and status_filter query params.

E.g. ?dataset_filter=my_dataset&dataset_filter=my_other_dataset&status_filter=running will only show rows where the dataset is "my_dataset" or "my_other_dataset", and where the status is "running".

An additional date range filter is supported for the created_at column. Use the start_date and end_date query parameters to configure this.

🛠️ Usage

const listResponse = await humanloop.evaluations.list({
  projectId: "projectId_example",
  size: 50,
  page: 0,
});

⚙️ Parameters

projectId: string

String ID of project. Starts with pr_.

id: string[]

A list of evaluation run ids to filter on. Starts with ev_.

startDate: string | Date

Only return evaluations created after this date.

endDate: string | Date

Only return evaluations created before this date.

size: number
page: number

🔄 Return

PaginatedDataEvaluationResponse

🌐 Endpoint

/evaluations GET

🔙 Back to Table of Contents


humanloop.evaluations.listAllForProject

Get all the evaluations associated with your project.

Deprecated: This is a legacy unpaginated endpoint. Use /evaluations instead, with appropriate sorting, filtering and pagination options.

🛠️ Usage

const listAllForProjectResponse = await humanloop.evaluations.listAllForProject(
  {
    projectId: "projectId_example",
  }
);

⚙️ Parameters

projectId: string

String ID of project. Starts with pr_.

evaluatorAggregates: boolean

Whether to include evaluator aggregates in the response.

🔄 Return

EvaluationResponse

🌐 Endpoint

/projects/{project_id}/evaluations GET

🔙 Back to Table of Contents


humanloop.evaluations.listDatapoints

Get testcases by evaluation ID.

🛠️ Usage

const listDatapointsResponse = await humanloop.evaluations.listDatapoints({
  id: "id_example",
  page: 1,
  size: 10,
});

⚙️ Parameters

id: string

String ID of evaluation. Starts with ev_.

page: number

Page to fetch. Starts from 1.

size: number

Number of evaluation results to retrieve.

🔄 Return

PaginatedDataEvaluationDatapointSnapshotResponse

🌐 Endpoint

/evaluations/{id}/datapoints GET

🔙 Back to Table of Contents


humanloop.evaluations.log

Log an external generation to an evaluation run for a datapoint.

The run must have status 'running'.

🛠️ Usage

const logResponse = await humanloop.evaluations.log({
  evaluationId: "evaluationId_example",
  datapoint_id: "datapoint_id_example",
  log: {
    save: true,
  },
});

⚙️ Parameters

datapoint_id: string

The datapoint for which a log was generated. Must be one of the datapoints in the dataset being evaluated.

The log generated for the datapoint.

evaluationId: string

ID of the evaluation run. Starts with evrun_.

🔄 Return

CreateLogResponse

🌐 Endpoint

/evaluations/{evaluation_id}/log POST

🔙 Back to Table of Contents


humanloop.evaluations.result

Log an evaluation result to an evaluation run.

The run must have status 'running'. One of result or error must be provided.

🛠️ Usage

const resultResponse = await humanloop.evaluations.result({
  evaluationId: "evaluationId_example",
  log_id: "log_id_example",
  evaluator_id: "evaluator_id_example",
});

⚙️ Parameters

log_id: string

The log that was evaluated. Must have as its source_datapoint_id one of the datapoints in the dataset being evaluated.

evaluator_id: string

ID of the evaluator that evaluated the log. Starts with evfn_. Must be one of the evaluator IDs associated with the evaluation run being logged to.

evaluationId: string

ID of the evaluation run. Starts with evrun_.

result: ValueProperty
error: string

An error that occurred during evaluation.

🔄 Return

EvaluationResultResponse

🌐 Endpoint

/evaluations/{evaluation_id}/result POST

🔙 Back to Table of Contents


humanloop.evaluations.updateStatus

Update the status of an evaluation run.

Can only be used to update the status of an evaluation run that uses external or human evaluators. The evaluation must currently have status 'running' if swithcing to completed, or it must have status 'completed' if switching back to 'running'.

🛠️ Usage

const updateStatusResponse = await humanloop.evaluations.updateStatus({
  id: "id_example",
  status: "pending",
});

⚙️ Parameters

The new status of the evaluation.

id: string

String ID of evaluation run. Starts with ev_.

🔄 Return

EvaluationResponse

🌐 Endpoint

/evaluations/{id}/status PATCH

🔙 Back to Table of Contents


humanloop.evaluators.create

Create an evaluator within your organization.

🛠️ Usage

const createResponse = await humanloop.evaluators.create({
  description: "description_example",
  name: "name_example",
  arguments_type: "target_free",
  return_type: "boolean",
  type: "python",
});

⚙️ Parameters

description: string

The description of the evaluator.

name: string

The name of the evaluator.

arguments_type: EvaluatorArgumentsType

Whether this evaluator is target-free or target-required.

The type of the return value of the evaluator.

The type of the evaluator.

code: string

The code for the evaluator. This code will be executed in a sandboxed environment.

The model configuration used to generate.

🔄 Return

EvaluatorResponse

🌐 Endpoint

/evaluators POST

🔙 Back to Table of Contents


humanloop.evaluators.delete

Delete an evaluator within your organization.

🛠️ Usage

const deleteResponse = await humanloop.evaluators.delete({
  id: "id_example",
});

⚙️ Parameters

id: string

🌐 Endpoint

/evaluators/{id} DELETE

🔙 Back to Table of Contents


humanloop.evaluators.get

Get an evaluator within your organization.

🛠️ Usage

const getResponse = await humanloop.evaluators.get({
  id: "id_example",
});

⚙️ Parameters

id: string

🔄 Return

EvaluatorResponse

🌐 Endpoint

/evaluators/{id} GET

🔙 Back to Table of Contents


humanloop.evaluators.list

Get all evaluators within your organization.

🛠️ Usage

const listResponse = await humanloop.evaluators.list();

🔄 Return

EvaluatorResponse

🌐 Endpoint

/evaluators GET

🔙 Back to Table of Contents


humanloop.evaluators.update

Update an evaluator within your organization.

🛠️ Usage

const updateResponse = await humanloop.evaluators.update({
  id: "id_example",
  arguments_type: "target_free",
  return_type: "boolean",
});

⚙️ Parameters

id: string
description: string

The description of the evaluator.

name: string

The name of the evaluator.

arguments_type: EvaluatorArgumentsType

Whether this evaluator is target-free or target-required.

The type of the return value of the evaluator.

code: string

The code for the evaluator. This code will be executed in a sandboxed environment.

The model configuration used to generate.

🔄 Return

EvaluatorResponse

🌐 Endpoint

/evaluators/{id} PATCH

🔙 Back to Table of Contents


humanloop.experiments.create

Create an experiment for your project.

You can optionally specify IDs of your project's model configs to include in the experiment, along with a set of labels to consider as positive feedback and whether the experiment should be set as active.

🛠️ Usage

const createResponse = await humanloop.experiments.create({
  projectId: "projectId_example",
  name: "name_example",
  positive_labels: [
    {
      type: "type_example",
      value: "value_example",
    },
  ],
  set_active: false,
});

⚙️ Parameters

name: string

Name of experiment.

positive_labels: PositiveLabel[]

Feedback labels to treat as positive user feedback. Used to monitor the performance of model configs in the experiment.

projectId: string

String ID of project. Starts with pr_.

config_ids: string[]

Configs to add to this experiment. Further configs can be added later.

set_active: boolean

Whether to set the created project as the project\'s active experiment.

🔄 Return

ExperimentResponse

🌐 Endpoint

/projects/{project_id}/experiments POST

🔙 Back to Table of Contents


humanloop.experiments.delete

Delete the experiment with the specified ID.

🛠️ Usage

const deleteResponse = await humanloop.experiments.delete({
  experimentId: "experimentId_example",
});

⚙️ Parameters

experimentId: string

String ID of experiment. Starts with exp_.

🌐 Endpoint

/experiments/{experiment_id} DELETE

🔙 Back to Table of Contents


humanloop.experiments.list

Get an array of experiments associated to your project.

🛠️ Usage

const listResponse = await humanloop.experiments.list({
  projectId: "projectId_example",
});

⚙️ Parameters

projectId: string

String ID of project. Starts with pr_.

🔄 Return

ExperimentResponse

🌐 Endpoint

/projects/{project_id}/experiments GET

🔙 Back to Table of Contents


humanloop.experiments.sample

Samples a model config from the experiment's active model configs.

🛠️ Usage

const sampleResponse = await humanloop.experiments.sample({
  experimentId: "experimentId_example",
});

⚙️ Parameters

experimentId: string

String ID of experiment. Starts with exp_.

🔄 Return

GetModelConfigResponse

🌐 Endpoint

/experiments/{experiment_id}/model-config GET

🔙 Back to Table of Contents


humanloop.experiments.update

Update your experiment, including registering and de-registering model configs.

🛠️ Usage

const updateResponse = await humanloop.experiments.update({
  experimentId: "experimentId_example",
});

⚙️ Parameters

experimentId: string

String ID of experiment. Starts with exp_.

name: string

Name of experiment.

positive_labels: PositiveLabel[]

Feedback labels to treat as positive user feedback. Used to monitor the performance of model configs in the experiment.

config_ids_to_register: string[]

Model configs to add to this experiment.

config_ids_to_deregister: string[]

Model configs in this experiment to be deactivated.

🔄 Return

ExperimentResponse

🌐 Endpoint

/experiments/{experiment_id} PATCH

🔙 Back to Table of Contents


humanloop.feedback

Submit an array of feedback for existing data_ids

🛠️ Usage

const feedbackResponse = await humanloop.feedback({
  type: "string_example",
});

⚙️ Parameters

value: string

The feedback value to be set. This field should be left blank when unsetting \'rating\', \'correction\' or \'comment\', but is required otherwise.

data_id: string

ID to associate the feedback to a previously logged datapoint.

user: string

A unique identifier to who provided the feedback.

created_at: string

User defined timestamp for when the feedback was created.

unset: boolean

If true, the value for this feedback is unset.

🔄 Return

FeedbackSubmitResponse

🌐 Endpoint

/feedback POST

🔙 Back to Table of Contents


humanloop.logs.delete

Delete

🛠️ Usage

const deleteResponse = await humanloop.logs.delete({});

⚙️ Parameters

id: string[]

🌐 Endpoint

/logs DELETE

🔙 Back to Table of Contents


humanloop.logs.get

Retrieve a log by log id.

🛠️ Usage

const getResponse = await humanloop.logs.get({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of log to return. Starts with data_.

🔄 Return

LogResponse

🌐 Endpoint

/logs/{id} GET

🔙 Back to Table of Contents


humanloop.logs.list

Retrieve paginated logs from the server.

Sorting and filtering are supported through query params.

Sorting is supported for the source, model, timestamp, and feedback-{output_name} columns. Specify sorting with the sort query param, with values {column}.{ordering}. E.g. ?sort=source.asc&sort=model.desc will yield a multi-column sort. First by source then by model.

Filtering is supported for the source, model, feedback-{output_name}, evaluator-{evaluator_external_id} columns.

Specify filtering with the source_filter, model_filter, feedback-{output.name}_filter and evaluator-{evaluator_external_id}_filter query params.

E.g. ?source_filter=AI&source_filter=user_1234&feedback-explicit_filter=good will only show rows where the source is "AI" or "user_1234", and where the latest feedback for the "explicit" output group is "good".

An additional date range filter is supported for the Timestamp column (i.e. Log.created_at). These are supported through the start_date and end_date query parameters.

Searching is supported for the model inputs and output. Specify a search term with the search query param. E.g. ?search=hello%20there will cause a case-insensitive search across model inputs and output.

🛠️ Usage

const listResponse = await humanloop.logs.list({
  projectId: "projectId_example",
  versionStatus: "uncommitted",
  size: 50,
  page: 0,
});

⚙️ Parameters

projectId: string
search: string
metadataSearch: string
versionStatus: VersionStatus
startDate: string | Date
endDate: string | Date
size: number
page: number

🔄 Return

PaginatedDataLogResponse

🌐 Endpoint

/logs GET

🔙 Back to Table of Contents


humanloop.log

Log a datapoint or array of datapoints to your Humanloop project.

🛠️ Usage

const logResponse = await humanloop.log({
  save: true,
});

⚙️ Parameters

project: string

Unique project name. If no project exists with this name, a new project will be created.

project_id: string

Unique ID of a project to associate to the log. Either this or project must be provided.

session_id: string

ID of the session to associate the datapoint.

session_reference_id: string

A unique string identifying the session to associate the datapoint to. Allows you to log multiple datapoints to a session (using an ID kept by your internal systems) by passing the same session_reference_id in subsequent log requests. Specify at most one of this or session_id.

parent_id: string

ID associated to the parent datapoint in a session.

parent_reference_id: string

A unique string identifying the previously-logged parent datapoint in a session. Allows you to log nested datapoints with your internal system IDs by passing the same reference ID as parent_id in a prior log request. Specify at most one of this or parent_id. Note that this cannot refer to a datapoint being logged in the same request.

inputs: object

The inputs passed to the prompt template.

source: string

Identifies where the model was called from.

metadata: object

Any additional metadata to record.

save: boolean

Whether the request/response payloads will be stored on Humanloop.

source_datapoint_id: string

ID of the source datapoint if this is a log derived from a datapoint in a dataset.

reference_id: string

A unique string to reference the datapoint. Allows you to log nested datapoints with your internal system IDs by passing the same reference ID as parent_id in a subsequent log request.

trial_id: string

Unique ID of an experiment trial to associate to the log.

The messages passed to the to provider chat endpoint.

output: string

Generated output from your model for the provided inputs. Can be None if logging an error, or if logging a parent datapoint with the intention to populate it later

config_id: string

Unique ID of a config to associate to the log.

environment: string

The environment name used to create the log.

created_at: string

User defined timestamp for when the log was created.

error: string

Error message if the log is an error.

duration: number

Duration of the logged event in seconds.

output_message: ChatMessageWithToolCall

The message returned by the provider.

prompt_tokens: number

Number of tokens in the prompt used to generate the output.

output_tokens: number

Number of tokens in the output generated by the model.

prompt_cost: number

Cost in dollars associated to the tokens in the prompt.

output_cost: number

Cost in dollars associated to the tokens in the output.

provider_request: object

Raw request sent to provider.

provider_response: object

Raw response received the provider.

🔄 Return

LogsLogResponse

🌐 Endpoint

/logs POST

🔙 Back to Table of Contents


humanloop.logs.update

Update a logged datapoint in your Humanloop project.

🛠️ Usage

const updateResponse = await humanloop.logs.update({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of logged datapoint to return. Starts with data_.

output: string

Generated output from your model for the provided inputs.

error: string

Error message if the log is an error.

duration: number

Duration of the logged event in seconds.

🔄 Return

LogResponse

🌐 Endpoint

/logs/{id} PATCH

🔙 Back to Table of Contents


humanloop.logs.updateByRef

Update a logged datapoint by its reference ID.

The reference_id query parameter must be provided, and refers to the reference_id of a previously-logged datapoint.

🛠️ Usage

const updateByRefResponse = await humanloop.logs.updateByRef({
  referenceId: "referenceId_example",
});

⚙️ Parameters

referenceId: string

A unique string to reference the datapoint. Identifies the logged datapoint created with the same reference_id.

output: string

Generated output from your model for the provided inputs.

error: string

Error message if the log is an error.

duration: number

Duration of the logged event in seconds.

🔄 Return

LogResponse

🌐 Endpoint

/logs PATCH

🔙 Back to Table of Contents


humanloop.modelConfigs.deserialize

Deserialize a model config from a .prompt file format.

🛠️ Usage

const deserializeResponse = await humanloop.modelConfigs.deserialize({
  config: "config_example",
});

⚙️ Parameters

config: string

🔄 Return

ModelConfigResponse

🌐 Endpoint

/model-configs/deserialize POST

🔙 Back to Table of Contents


humanloop.modelConfigs.export

Export a model config to a .prompt file by ID.

🛠️ Usage

const exportResponse = await humanloop.modelConfigs.export({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of the model config. Starts with config_.

🌐 Endpoint

/model-configs/{id}/export POST

🔙 Back to Table of Contents


humanloop.modelConfigs.get

Get a specific model config by ID.

🛠️ Usage

const getResponse = await humanloop.modelConfigs.get({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of the model config. Starts with config_.

🔄 Return

ModelConfigResponse

🌐 Endpoint

/model-configs/{id} GET

🔙 Back to Table of Contents


humanloop.modelConfigs.register

Register a model config to a project and optionally add it to an experiment.

If the project name provided does not exist, a new project will be created automatically.

If an experiment name is provided, the specified experiment must already exist. Otherwise, an error will be raised.

If the model config is the first to be associated to the project, it will be set as the active model config.

🛠️ Usage

const registerResponse = await humanloop.modelConfigs.register({
  provider: "openai",
  model: "model_example",
  max_tokens: -1,
  temperature: 1,
  top_p: 1,
  presence_penalty: 0,
  frequency_penalty: 0,
  endpoint: "complete",
});

⚙️ Parameters

model: string

The model instance used. E.g. text-davinci-002.

description: string

A description of the model config.

name: string

A friendly display name for the model config. If not provided, a name will be generated.

provider: ModelProviders

The company providing the underlying model service.

max_tokens: number

The maximum number of tokens to generate. Provide max_tokens=-1 to dynamically calculate the maximum number of tokens to generate given the length of the prompt

temperature: number

What sampling temperature to use when making a generation. Higher values means the model will be more creative.

top_p: number

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.

presence_penalty: number

Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the generation so far.

frequency_penalty: number

Number between -2.0 and 2.0. Positive values penalize new tokens based on how frequently they appear in the generation so far.

other: object

Other parameter values to be passed to the provider call.

seed: number

If specified, model will make a best effort to sample deterministically, but it is not guaranteed.

response_format: ResponseFormat

The format of the response. Only type json_object is currently supported for chat.

project: string

Unique project name. If it does not exist, a new project will be created.

project_id: string

Unique project ID

experiment: string

If specified, the model config will be added to this experiment. Experiments are used for A/B testing and optimizing hyperparameters.

prompt_template: string

Prompt template that will take your specified inputs to form your final request to the provider model. NB: Input variables within the prompt template should be specified with syntax: {{INPUT_NAME}}.

chat_template: ChatMessageWithToolCall[]

Messages prepended to the list of messages sent to the provider. These messages that will take your specified inputs to form your final request to the provider model. NB: Input variables within the prompt template should be specified with syntax: {{INPUT_NAME}}.

endpoint: ModelEndpoints

Which of the providers model endpoints to use. For example Complete or Edit.

Make tools available to OpenAIs chat model as functions.

🔄 Return

ProjectConfigResponse

🌐 Endpoint

/model-configs POST

🔙 Back to Table of Contents


humanloop.modelConfigs.serialize

Serialize a model config to a .prompt file format.

🛠️ Usage

const serializeResponse = await humanloop.modelConfigs.serialize({
  provider: "openai",
  model: "model_example",
  max_tokens: -1,
  temperature: 1,
  top_p: 1,
  presence_penalty: 0,
  frequency_penalty: 0,
  endpoint: "complete",
});

⚙️ Parameters

description: string

A description of the model config.

name: string

A friendly display name for the model config. If not provided, a name will be generated.

provider: ModelProviders

The company providing the underlying model service.

model: string

The model instance used. E.g. text-davinci-002.

max_tokens: number

The maximum number of tokens to generate. Provide max_tokens=-1 to dynamically calculate the maximum number of tokens to generate given the length of the prompt

temperature: number

What sampling temperature to use when making a generation. Higher values means the model will be more creative.

top_p: number

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.

presence_penalty: number

Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the generation so far.

frequency_penalty: number

Number between -2.0 and 2.0. Positive values penalize new tokens based on how frequently they appear in the generation so far.

other: object

Other parameter values to be passed to the provider call.

seed: number

If specified, model will make a best effort to sample deterministically, but it is not guaranteed.

response_format: ResponseFormat

The format of the response. Only type json_object is currently supported for chat.

endpoint: ModelEndpoints

The provider model endpoint used.

chat_template: ChatMessageWithToolCall[]

Messages prepended to the list of messages sent to the provider. These messages that will take your specified inputs to form your final request to the provider model. Input variables within the template should be specified with syntax: {{INPUT_NAME}}.

Make tools available to OpenAIs chat model as functions.

prompt_template: string

Prompt template that will take your specified inputs to form your final request to the model. Input variables within the prompt template should be specified with syntax: {{INPUT_NAME}}.

🌐 Endpoint

/model-configs/serialize POST

🔙 Back to Table of Contents


humanloop.projects.create

Create a new project.

🛠️ Usage

const createResponse = await humanloop.projects.create({
  name: "name_example",
});

⚙️ Parameters

name: string

Unique project name.

feedback_types: FeedbackTypeRequest[]

Feedback types to be created.

directory_id: string

ID of directory to assign project to. Starts with dir_. If not provided, the project will be created in the root directory.

🔄 Return

ProjectResponse

🌐 Endpoint

/projects POST

🔙 Back to Table of Contents


humanloop.projects.createFeedbackType

Create Feedback Type

🛠️ Usage

const createFeedbackTypeResponse = await humanloop.projects.createFeedbackType({
  id: "id_example",
  type: "type_example",
  _class: "select",
});

⚙️ Parameters

type: string

The type of feedback to update.

id: string

String ID of project. Starts with pr_.

The feedback values to be available. This field should only be populated when updating a \'select\' or \'multi_select\' feedback class.

The data type associated to this feedback type; whether it is a \'text\'/\'select\'/\'multi_select\'. This is optional when updating the default feedback types (i.e. when type is \'rating\', \'action\' or \'issue\').

🔄 Return

FeedbackTypeModel

🌐 Endpoint

/projects/{id}/feedback-types POST

🔙 Back to Table of Contents


humanloop.projects.deactivateConfig

Remove the project's active config, if set.

This has no effect if the project does not have an active model config set.

🛠️ Usage

const deactivateConfigResponse = await humanloop.projects.deactivateConfig({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of project. Starts with pr_.

environment: string

Name for the environment. E.g. 'production'. If not provided, will delete the active config for the default environment.

🔄 Return

ProjectResponse

🌐 Endpoint

/projects/{id}/active-config DELETE

🔙 Back to Table of Contents


humanloop.projects.deactivateExperiment

Remove the project's active experiment, if set.

This has no effect if the project does not have an active experiment set.

🛠️ Usage

const deactivateExperimentResponse =
  await humanloop.projects.deactivateExperiment({
    id: "id_example",
  });

⚙️ Parameters

id: string

String ID of project. Starts with pr_.

environment: string

Name for the environment. E.g. 'producton'. If not provided, will return the experiment for the default environment.

🔄 Return

ProjectResponse

🌐 Endpoint

/projects/{id}/active-experiment DELETE

🔙 Back to Table of Contents


humanloop.projects.delete

Delete a specific file.

🛠️ Usage

const deleteResponse = await humanloop.projects.delete({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of project. Starts with pr_.

🌐 Endpoint

/projects/{id} DELETE

🔙 Back to Table of Contents


humanloop.projects.deleteDeployedConfig

Remove the verion deployed to environment.

This has no effect if the project does not have an active version set.

🛠️ Usage

const deleteDeployedConfigResponse =
  await humanloop.projects.deleteDeployedConfig({
    projectId: "projectId_example",
    environmentId: "environmentId_example",
  });

⚙️ Parameters

projectId: string
environmentId: string

🌐 Endpoint

/projects/{project_id}/deployed-config/{environment_id} DELETE

🔙 Back to Table of Contents


humanloop.projects.deployConfig

Deploy a model config to an environment.

If the environment already has a model config deployed, it will be replaced.

🛠️ Usage

const deployConfigResponse = await humanloop.projects.deployConfig({
  projectId: "projectId_example",
});

⚙️ Parameters

projectId: string
config_id: string

Model config unique identifier generated by Humanloop.

experiment_id: string

String ID of experiment. Starts with exp_.

environments: EnvironmentRequest[]

List of environments to associate with the model config.

🔄 Return

EnvironmentProjectConfigResponse

🌐 Endpoint

/projects/{project_id}/deploy-config PATCH

🔙 Back to Table of Contents


humanloop.projects.export

Export all logged datapoints associated to your project.

Results are paginated and sorts the datapoints based on created_at in descending order.

🛠️ Usage

const exportResponse = await humanloop.projects.export({
  id: "id_example",
  page: 0,
  size: 10,
});

⚙️ Parameters

id: string

String ID of project. Starts with pr_.

page: number

Page offset for pagination.

size: number

Page size for pagination. Number of logs to export.

🔄 Return

PaginatedDataLogResponse

🌐 Endpoint

/projects/{id}/export POST

🔙 Back to Table of Contents


humanloop.projects.get

Get a specific project.

🛠️ Usage

const getResponse = await humanloop.projects.get({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of project. Starts with pr_.

🔄 Return

ProjectResponse

🌐 Endpoint

/projects/{id} GET

🔙 Back to Table of Contents


humanloop.projects.getActiveConfig

Retrieves a config to use to execute your model.

A config will be selected based on the project's active config/experiment settings.

🛠️ Usage

const getActiveConfigResponse = await humanloop.projects.getActiveConfig({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of project. Starts with pr_.

environment: string

Name for the environment. E.g. 'producton'. If not provided, will return the active config for the default environment.

🔄 Return

GetModelConfigResponse

🌐 Endpoint

/projects/{id}/active-config GET

🔙 Back to Table of Contents


humanloop.projects.list

Get a paginated list of files.

🛠️ Usage

const listResponse = await humanloop.projects.list({
  page: 0,
  size: 10,
  sortBy: "created_at",
  order: "asc",
});

⚙️ Parameters

page: number

Page offset for pagination.

size: number

Page size for pagination. Number of projects to fetch.

filter: string

Case-insensitive filter for project name.

userFilter: string

Case-insensitive filter for users in the project. This filter matches against both email address and name of users.

sortBy: ProjectSortBy

Field to sort projects by

order: SortOrder

Direction to sort by.

🔄 Return

PaginatedDataProjectResponse

🌐 Endpoint

/projects GET

🔙 Back to Table of Contents


humanloop.projects.listConfigs

Get an array of versions associated to your file.

🛠️ Usage

const listConfigsResponse = await humanloop.projects.listConfigs({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of project. Starts with pr_.

evaluationAggregates: boolean

🔄 Return

ProjectConfigResponse

🌐 Endpoint

/projects/{id}/configs GET

🔙 Back to Table of Contents


humanloop.projects.listDeployedConfigs

Get an array of environments with the deployed configs associated to your project.

🛠️ Usage

const listDeployedConfigsResponse =
  await humanloop.projects.listDeployedConfigs({
    id: "id_example",
  });

⚙️ Parameters

id: string

String ID of project. Starts with pr_.

🔄 Return

EnvironmentProjectConfigResponse

🌐 Endpoint

/projects/{id}/deployed-configs GET

🔙 Back to Table of Contents


humanloop.projects.update

Update a specific project.

Set the project's active model config/experiment by passing either active_experiment_id or active_model_config_id. These will be set to the Default environment unless a list of environments are also passed in specifically detailing which environments to assign the active config or experiment.

Set the feedback labels to be treated as positive user feedback used in calculating top-level project metrics by passing a list of labels in positive_labels.

🛠️ Usage

const updateResponse = await humanloop.projects.update({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of project. Starts with pr_.

name: string

The new unique project name. Caution, if you are using the project name as the unique identifier in your API calls, changing the name will break the calls.

active_experiment_id: string

ID for an experiment to set as the project\'s active deployment. Starts with \'exp_\'. At most one of \'active_experiment_id\' and \'active_model_config_id\' can be set.

active_config_id: string

ID for a config to set as the project\'s active deployment. Starts with \'config_\'. At most one of \'active_experiment_id\' and \'active_config_id\' can be set.

positive_labels: PositiveLabel[]

The full list of labels to treat as positive user feedback.

directory_id: string

ID of directory to assign project to. Starts with dir_.

🔄 Return

ProjectResponse

🌐 Endpoint

/projects/{id} PATCH

🔙 Back to Table of Contents


humanloop.projects.updateFeedbackTypes

Update feedback types.

Allows enabling the available feedback types and setting status of feedback types/categorical values.

This behaves like an upsert; any feedback categorical values that do not already exist in the project will be created.

🛠️ Usage

const updateFeedbackTypesResponse =
  await humanloop.projects.updateFeedbackTypes({
    id: "id_example",
    requestBody: [
      {
        type: "type_example",
        _class: "select",
      },
    ],
  });

⚙️ Parameters

id: string

String ID of project. Starts with pr_.

requestBody: FeedbackTypeRequest[]

🔄 Return

FeedbackTypeModel

🌐 Endpoint

/projects/{id}/feedback-types PATCH

🔙 Back to Table of Contents


humanloop.sessions.create

Create a new session.

Returns a session ID that can be used to log datapoints to the session.

🛠️ Usage

const createResponse = await humanloop.sessions.create();

🔄 Return

CreateSessionResponse

🌐 Endpoint

/sessions POST

🔙 Back to Table of Contents


humanloop.sessions.get

Get a session by ID.

🛠️ Usage

const getResponse = await humanloop.sessions.get({
  id: "id_example",
});

⚙️ Parameters

id: string

String ID of session to return. Starts with sesh_.

🔄 Return

SessionResponse

🌐 Endpoint

/sessions/{id} GET

🔙 Back to Table of Contents


humanloop.sessions.list

Get a page of sessions.

🛠️ Usage

const listResponse = await humanloop.sessions.list({
  projectId: "projectId_example",
  page: 1,
  size: 10,
});

⚙️ Parameters

projectId: string

String ID of project to return sessions for. Sessions that contain any datapoints associated to this project will be returned. Starts with pr_.

page: number

Page to fetch. Starts from 1.

size: number

Number of sessions to retrieve.

🔄 Return

PaginatedDataSessionResponse

🌐 Endpoint

/sessions GET

🔙 Back to Table of Contents


Author

This TypeScript package is automatically generated by Konfig

Package Sidebar

Install

npm i humanloop

Weekly Downloads

37,171

Version

0.6.0-alpha.22

License

Unlicense

Unpacked Size

1.46 MB

Total Files

382

Last publish

Collaborators

  • konfig-publisher