Using the SDK
How to set up a project in Humanloop using the Python SDK.
The Humanloop Python SDK allows you to programmatically set up Humanloop projects with model configs and a feedback schema.
Prerequisites
- A Humanloop account. If you don't have one, you can create an account now by going to the Sign up page.
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. Otherwise, open up your terminal and follow these steps:
- Install the Humanloop Python SDK:
$ pip install humanloop
- Start a Python interpreter:
$ python
- Initialize the SDK with your Humanloop API key (get your API key from your Organisation Settings page)
>>> from humanloop import Humanloop >>> humanloop = Humanloop(api_key="<YOUR Humanloop API KEY>")
Create a project
Continue in the same Python interpreter (where you have run humanloop = Humanloop(...)
).
-
Create the project
project_response = humanloop.projects.create(name="{{your-organization}}-sdk-tutorial") project_id = project_response.body["id"]
-
Add your own feedback types and values
By default your project has a feedback typerating
with labelsgood
andbad
.humanloop.projects.update_feedback_types( id=project_id, body=[{ "type": "action", "class": "multi_select", "values": [ {"value": "copied"}, {"value": "saved"} ], }] )
-
Register your model config
humanloop.model_configurations.register( project="{{your-organization}}-sdk-tutorial", model="gpt-3.5-turbo", prompt_template="Write a snappy introduction about {{topic}}:", temperature=0.8, )
You now have a project in Humanloop that contains your model config with feedback types set up.
You can view your project and invite team members by going to the Project page.
With the project now set up, you can start to log generations from your models by following the guide to logging generations using the SDK.
Updated 4 months ago