For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sign inBook a demo
DocsReferenceChangelog
DocsReferenceChangelog
  • Getting Started
    • Overview
    • Why Humanloop?
    • Quickstart Tutorial
  • Tutorials
    • Create your first GPT-4 App
    • ChatGPT clone with streaming
  • Guides
    • Create a Prompt
      • Overview
      • Generate completions
      • Generate chat responses
      • Capture user feedback
      • Upload historic data
      • Logging
      • Chaining calls (Sessions)
    • Fine-tune a model
    • Manage API keys
    • Invite collaborators
    • Deploy to environments
  • Core concepts
    • Prompts
    • Tools
    • Datasets
    • Evaluators
    • Logs
    • Environments
    • Key Concepts
  • Reference
    • Supported Models
    • Access Roles
    • .prompt files
    • Postman Workspace
LogoLogo
Sign inBook a demo
On this page
  • Prerequisites
  • Log historic data
GuidesGenerate and Log

Upload historic data

Uploading historic model inputs and generations to an existing Humanloop project.
Was this page helpful?
Previous

Logging

Integrating Humanloop and running an experiment when using your own models.
Next
Built with

The Humanloop Python SDK allows you to upload your historic model data to an existing Humanloop project. This can be used to warm-start your project. The data can be considered for feedback and review alongside your new user generated data.

Prerequisites

  • You already have a Prompt — if not, please follow our Prompt creation guide first.
Install and initialize the SDK

First you need to install and initialize the SDK. If you have already done this, skip to the next section.

Open up your terminal and follow these steps:

  1. Install the Humanloop SDK:
1pip install humanloop
  1. Initialize the SDK with your Humanloop API key (you can get it from the Organization Settings page).
1from humanloop import Humanloop
2humanloop = Humanloop(api_key="<YOUR HUMANLOOP KEY>")
3
4# Check that the authentication was successful
5print(humanloop.prompts.list())

Log historic data

Grab your API key from your Settings page.

  1. Set up your code to first load up your historic data and then log this to Humanloop, explicitly passing details of the model config (if available) alongside the inputs and output:

    1from humanloop import Humanloop
    2import openai
    3
    4# Initialize Humanloop with your API key
    5humanloop = Humanloop(api_key="<YOUR Humanloop API KEY>")
    6
    7# NB: Add code here to load your existing model data before logging it to Humanloop
    8
    9# Log the inputs, outputs and model config to your project - this log call can take batches of data.
    10log_response = humanloop.log(
    11 project="<YOUR UNIQUE PROJECT NAME>",
    12 inputs={"question": "How should I think about competition for my startup?"},
    13 output=output,
    14 config={
    15 "model": "gpt-4",
    16 "prompt_template": "Answer the following question like Paul Graham from YCombinator: {{question}}",
    17 "temperature": 0.2,
    18 },
    19 source="sdk",
    20)
    21
    22# Use the datapoint IDs to associate feedback received later to this datapoint.
    23data_id = log_response.id
  2. The process of capturing feedback then uses the returned log_id as before.

    See our guide on capturing user feedback.

  3. You can also log immediate feedback alongside the input and outputs:

    1# Log the inputs, outputs and model config to your project.
    2log_response = humanloop.log(
    3 project="<YOUR UNIQUE PROJECT NAME>",
    4 inputs={"question": "How should I think about competition for my startup?"},
    5 output=output,
    6 config={
    7 "model": "gpt-4",
    8 "prompt_template": "Answer the following question like Paul Graham from YCombinator: {{question}}",
    9 "temperature": 0.2,
    10 },
    11 source="sdk",
    12 feedback={"type": "rating", "value": "good"}
    13)