Skip to content

Commit e513262

Browse files
committed
Release 0.0.3
1 parent 1e8e922 commit e513262

File tree

4 files changed

+13
-120
lines changed

4 files changed

+13
-120
lines changed

.mock/fern.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"organization" : "humanloop",
3-
"version" : "0.23.0"
3+
"version" : "0.31.0-rc5"
44
}

README.md

Lines changed: 10 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,151 +1,44 @@
11
# Humanloop Python Library
22

33
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://github.com/fern-api/fern)
4+
[![pypi](https://img.shields.io/pypi/v/humanloop)](https://pypi.python.org/pypi/humanloop)
45

5-
The Humanloop Python Library provides convenient access to the Humanloop API from
6-
applications written in Python.
7-
8-
The library includes type definitions for all
9-
request and response fields, and offers both synchronous and asynchronous clients powered by httpx.
6+
The Humanloop Python library provides convenient access to the Humanloop API from Python.
107

118
## Installation
129

13-
Add this dependency to your project's build file:
14-
15-
```bash
10+
```sh
1611
pip install humanloop
17-
# or
18-
poetry add humanloop
1912
```
2013

2114
## Usage
2215

23-
Simply import `Humanloop` and start making calls to our API.
16+
Instantiate and use the client with the following:
2417

2518
```python
26-
from humanloop import ChatMessage
27-
from humanloop.client import Humanloop
28-
29-
client = Humanloop(
30-
api_key="YOUR_API_KEY", # Defaults to HUMANLOOP_API_KEY
31-
)
32-
33-
client.prompts.call(
34-
prompt_id="prompt_id",
35-
messages=[
36-
ChatMessage(
37-
content="What is the day today?",
38-
role="user",
39-
)
40-
],
41-
)
42-
```
43-
44-
### Typing
45-
46-
To construct payloads you can either use the dedicated types like `ChatMessage` or construct directly from a dictionary like so:
47-
48-
```python
49-
from humanloop import ChatMessage
50-
from humanloop.client import Humanloop
51-
52-
client.prompts.call(
53-
prompt_id="prompt_id",
54-
messages=[
55-
{
56-
content="Tell me a funny joke",
57-
role="user",
58-
}
59-
],
60-
)
61-
```
62-
63-
### Streaming
64-
65-
The SDK supports streaming endpoints. To take advantage of this feature for `prompts.call`, simply
66-
pass in `stream=True` in the request. The response will be a generator that you can loop over.
67-
68-
```Python
69-
from humanloop import ChatMessage
7019
from humanloop.client import Humanloop
7120

7221
client = Humanloop(
7322
api_key="YOUR_API_KEY",
7423
)
75-
76-
stream = client.prompts.call(
77-
prompt_id="prompt_id",
78-
stream=True,
79-
messages=[
80-
ChatMessage(
81-
content="Tell me a funny joke",
82-
role="user",
83-
)
84-
],
24+
client.prompts.create(
25+
model="model",
8526
)
86-
87-
for message in stream:
88-
print(message)
89-
```
90-
91-
### Pagination
92-
93-
Paginated requests will return a `SyncPager` or `AsyncPager`, which can be used as generators for the underlying object. For example, `evaluations.list` will return a generator over `EvaluationResponse` and handle the pagination behind the scenes:
94-
95-
```python
96-
import humanloop.client
97-
98-
client = HumanloopClient(
99-
api_key="YOUR_API_KEY",
100-
)
101-
102-
for evaluation in client.evaluations.list(file_id="id"):
103-
print(evaluation)
104-
```
105-
106-
you could also iterate page-by-page:
107-
108-
```python
109-
for page in client.evaluations.list(file_id="id").iter_pages():
110-
print(page.items)
111-
```
112-
113-
or manually:
114-
115-
```python
116-
pager = client.evaluations.list(project_id="id")
117-
# First page
118-
print(pager.items)
119-
# Second page
120-
pager = pager.next_page()
121-
print(pager.items)
12227
```
12328

12429
## Async Client
12530

126-
The SDK also exports an async client so that you can make non-blocking
127-
calls to our API.
31+
The SDK also exports an `async` client so that you can make non-blocking calls to our API.
12832

12933
```python
130-
import asyncio
131-
from humanloop import ChatMessage
13234
from humanloop.client import AsyncHumanloop
13335

13436
client = AsyncHumanloop(
13537
api_key="YOUR_API_KEY",
13638
)
137-
138-
async def main() -> None:
139-
await client.prompts.call(
140-
prompt_id="prompt_id",
141-
messages=[
142-
ChatMessage(
143-
content="What is the day today?",
144-
role="user",
145-
)
146-
],
147-
)
148-
asyncio.run(main())
39+
await client.prompts.create(
40+
model="model",
41+
)
14942
```
15043

15144
## Exception Handling

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "humanloop"
3-
version = "0.0.2"
3+
version = "0.0.3"
44
description = ""
55
readme = "README.md"
66
authors = []

src/humanloop/core/client_wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get_headers(self) -> typing.Dict[str, str]:
1717
headers: typing.Dict[str, str] = {
1818
"X-Fern-Language": "Python",
1919
"X-Fern-SDK-Name": "humanloop",
20-
"X-Fern-SDK-Version": "0.0.2",
20+
"X-Fern-SDK-Version": "0.0.3",
2121
}
2222
headers["X-API-KEY"] = self.api_key
2323
return headers

0 commit comments

Comments
 (0)