> ## Documentation Index
> Fetch the complete documentation index at: https://docs.honeyhive.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload datasets

> How to upload a dataset in HoneyHive

We support uploading datasets to HoneyHive both through the UI and the SDK.

## Upload a dataset through the UI

We currently support `JSON`, `JSONL` and `CSV` file uploads in HoneyHive.

Here's an example `JSONL` file that you can upload:

```json theme={null}
{ "user_query": "What's the history of AI?", "response": "The history of AI is a long one." }
{ "user_query": "What is AI?", "response": "AI is the simulation of human intelligence in machines." }
{ "user_query": "What is the future of AI?", "response": "The future of AI is bright." }
{ "user_query": "How can I build AI?", "response": "You can build AI by learning the basics of programming." }
{ "user_query": "How does AI work?", "response": "AI works by learning from data." }
```

Here's an example `CSV` file that you can upload:

```csv theme={null}
user_query,response
What's the history of AI?,The history of AI is a long one.
What is AI?,AI is the simulation of human intelligence in machines.
What is the future of AI?,The future of AI is bright.
How can I build AI?,You can build AI by learning the basics of programming.
How does AI work?,AI works by learning from data.
```

In the below tutorial, we will use the `JSON` file format.

**Expected time:** few minutes

**Steps:**

<Steps>
  <Step title="Create a file with your JSON data">
    We will use a file called `AI_bot_queries.json` with the content as shown above.
  </Step>

  <Step title="Upload & view your dataset">
    Follow the steps after to upload & view your dataset:

    <div style={{ position: 'relative', paddingBottom: 'calc(57.25% + 42px)', height: '0' }}>
      <iframe src="https://app.supademo.com/embed/3EWC9-uKv-EOYDplh5pFM" allow="clipboard-write" frameborder="0" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen style={{ position: 'absolute', top: '0', left: '0', width: '100%', height: '100%' }} />
    </div>
  </Step>
</Steps>

## Upload a dataset through the SDK

Both our TypeScript and Python SDKs have been designed to ingest completely custom JSON lists.

All you need to do is to define which fields in each row map to inputs, ground truth, conversation history. All other fields are placed in metadata.

**Prerequisites**

* You have already created a project in HoneyHive, as explained [here](/workspace/projects).
* You have an API key for your project, as explained [here](/sdk-reference/authentication).

**Expected time:** few minutes

<Steps>
  <Step title="Installation">
    To install our SDKs, run the following commands in the shell.

    <CodeGroup>
      ```shell Python theme={null}
      pip install honeyhive
      ```

      ```shell TypeScript theme={null}
      npm install honeyhive
      ```
    </CodeGroup>
  </Step>

  <Step title="Authentication & Imports">
    To authenticate your SDK, you need to pass your API key.

    <CodeGroup>
      ```python Python theme={null}
      import honeyhive
      from honeyhive.models import components, operations

      hhai = honeyhive.HoneyHive(bearer_auth='YOUR_API_KEY')
      ```

      ```typescript TypeScript theme={null}
      import { HoneyHive } from "honeyhive";

      const hhai = new HoneyHive({
        bearerAuth: "YOUR_API_KEY",
      });
      ```
    </CodeGroup>
  </Step>

  <Step title="Create the dataset object">
    Give your new dataset a name and pass the project name to which you want to associate the dataset.

    Keep the generated `dataset_id` handy for future reference.

    <CodeGroup>
      ```python Python theme={null}
      eval_dataset = hhai.datasets.create_dataset(request=components.CreateDatasetRequest(
        project='YOUR_PROJECT_NAME',
        name='DATASET_NAME',
      ))

      dataset_id = eval_dataset.object.result.inserted_id
      ```

      ```typescript TypeScript theme={null}
      const evalDataset = await sdk.datasets.createDataset({
        project: "YOUR_PROJECT_NAME",
        name: "DATASET_NAME",
      })

      const datasetId = evalDataset.result.insertedId;
      ```
    </CodeGroup>
  </Step>

  <Step title="Pass your data and provide a mapping">
    Now, using the `dataset_id`, you can pass your data list and provide a mapping to the fields.

    We'll create unique datapoints for each entry in the JSON list. The `datapoint_id` on those entries will be used for joining traces in experiment runs in the future.

    <Note>Any field not defined in the mapping is set on the `metadata` of the datapoint.</Note>

    <CodeGroup>
      ```python Python theme={null}
      dataset = [
          {"question": "how do i make lightweight tables?"},
          {"question": "how do i make lightweight modals?"},
          {"question": "how do i make lightweight wireframes?"},
      ]

      dataset_request = operations.AddDatapointsRequestBody(
          project = 'YOUR_PROJECT_NAME',
          data = dataset, # list of dictionaries
          mapping = operations.Mapping(
              inputs=[
                'question', # input fields
              ],
              ground_truth=[],
              history=[]
          ),
      )

      datapoints = hhai.datasets.add_datapoints(
          dataset_id = dataset_id, # dataset_id from the previous step
          request_body = dataset_request
      )

      datapoint_ids = datapoints.object.datapoint_ids
      ```

      ```typescript TypeScript theme={null}
      var dataset: Array[any] = [
          {"question": "how do i make lightweight tables?"},
          {"question": "how do i make lightweight modals?"},
          {"question": "how do i make lightweight wireframes?"},
      ]

      const requestBody = {
        project: "YOUR_PROJECT_NAME",
        data: dataset,
        mapping: {
          inputs: [
            "question",
          ],
          groundTruth: [],
          history: [],
        },
      };

      const res = await sdk.datasets.addDatapoints(datasetId, requestBody);

      var datapointIds = res.datapointIds;
      ```
    </CodeGroup>
  </Step>
</Steps>

You have successfully uploaded your dataset to HoneyHive using the SDK.

You can now view your dataset in the HoneyHive UI.

## Next steps

<CardGroup cols={1}>
  <Card title="Running experiments" icon="table" href="/evaluation/quickstart">
    Learn how to run experiments on your dataset.
  </Card>
</CardGroup>
