Skip to content

Commit 7fe741c

Browse files
committed
Release 0.8.16
1 parent 4308743 commit 7fe741c

File tree

296 files changed

+1803
-1080
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

296 files changed

+1803
-1080
lines changed

README.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ await client.prompts.log({
4444
person: "Trump",
4545
},
4646
createdAt: "2024-07-19T00:29:35.178992",
47+
error: undefined,
4748
providerLatency: 6.5931549072265625,
4849
outputMessage: {
4950
content:
@@ -90,15 +91,51 @@ try {
9091
}
9192
```
9293

94+
## Pagination
95+
96+
List endpoints are paginated. The SDK provides an iterator so that you can simply loop over the items:
97+
98+
```typescript
99+
import { HumanloopClient } from "humanloop";
100+
101+
const client = new HumanloopClient({ apiKey: "YOUR_API_KEY" });
102+
const response = await client.prompts.list({
103+
size: 1,
104+
});
105+
for await (const item of response) {
106+
console.log(item);
107+
}
108+
109+
// Or you can manually iterate page-by-page
110+
const page = await client.prompts.list({
111+
size: 1,
112+
});
113+
while (page.hasNextPage()) {
114+
page = page.getNextPage();
115+
}
116+
```
117+
93118
## Advanced
94119

120+
### Additional Headers
121+
122+
If you would like to send additional headers as part of the request, use the `headers` request option.
123+
124+
```typescript
125+
const response = await client.prompts.log(..., {
126+
headers: {
127+
'X-Custom-Header': 'custom value'
128+
}
129+
});
130+
```
131+
95132
### Retries
96133

97134
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
98-
as the request is deemed retriable and the number of retry attempts has not grown larger than the configured
135+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
99136
retry limit (default: 2).
100137

101-
A request is deemed retriable when any of the following HTTP status codes is returned:
138+
A request is deemed retryable when any of the following HTTP status codes is returned:
102139

103140
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
104141
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)

jest.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('jest').Config} */
2+
export default {
3+
preset: "ts-jest",
4+
testEnvironment: "node",
5+
moduleNameMapper: {
6+
"(.+)\.js$": "$1",
7+
},
8+
};

package.json

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"url-join": "4.0.1",
1616
"form-data": "^4.0.0",
1717
"formdata-node": "^6.0.3",
18-
"node-fetch": "2.7.0",
19-
"qs": "6.11.2",
18+
"node-fetch": "^2.7.0",
19+
"qs": "^6.13.1",
2020
"readable-stream": "^4.5.2",
2121
"form-data-encoder": "^4.0.2",
2222
"@opentelemetry/api": "1.9.0",
@@ -35,19 +35,18 @@
3535
},
3636
"devDependencies": {
3737
"@types/url-join": "4.0.1",
38-
"@types/qs": "6.9.8",
39-
"@types/node-fetch": "2.6.9",
40-
"@types/readable-stream": "^4.0.15",
41-
"fetch-mock-jest": "^1.5.1",
42-
"webpack": "^5.94.0",
43-
"ts-loader": "^9.3.1",
44-
"jest": "29.7.0",
45-
"@types/jest": "29.5.5",
46-
"ts-jest": "29.1.1",
47-
"jest-environment-jsdom": "29.7.0",
48-
"@types/node": "17.0.33",
38+
"@types/qs": "^6.9.17",
39+
"@types/node-fetch": "^2.6.12",
40+
"@types/readable-stream": "^4.0.18",
41+
"webpack": "^5.97.1",
42+
"ts-loader": "^9.5.1",
43+
"jest": "^29.7.0",
44+
"@types/jest": "^29.5.14",
45+
"ts-jest": "^29.1.1",
46+
"jest-environment-jsdom": "^29.7.0",
47+
"@types/node": "^18.19.70",
4948
"prettier": "^3.4.2",
50-
"typescript": "4.6.4",
49+
"typescript": "~5.7.2",
5150
"openai": "^4.74.0",
5251
"@anthropic-ai/sdk": "^0.32.1",
5352
"cohere-ai": "^7.15.0",

reference.md

Lines changed: 111 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ await client.prompts.log({
5959
person: "Trump",
6060
},
6161
createdAt: "2024-07-19T00:29:35.178992",
62+
error: undefined,
6263
providerLatency: 6.5931549072265625,
6364
outputMessage: {
6465
content:
@@ -225,7 +226,10 @@ in the case where you are storing or deriving your Prompt details in code.
225226
<dd>
226227

227228
```typescript
228-
await client.prompts.callStream({});
229+
const response = await client.prompts.callStream({});
230+
for await (const item of response) {
231+
console.log(item);
232+
}
229233
```
230234

231235
</dd>
@@ -396,9 +400,20 @@ Get a list of all Prompts.
396400
<dd>
397401

398402
```typescript
399-
await client.prompts.list({
403+
const response = await client.prompts.list({
400404
size: 1,
401405
});
406+
for await (const item of response) {
407+
console.log(item);
408+
}
409+
410+
// Or you can manually iterate page-by-page
411+
const page = await client.prompts.list({
412+
size: 1,
413+
});
414+
while (page.hasNextPage()) {
415+
page = page.getNextPage();
416+
}
402417
```
403418

404419
</dd>
@@ -1539,9 +1554,20 @@ Get a list of all Tools.
15391554
<dd>
15401555

15411556
```typescript
1542-
await client.tools.list({
1557+
const response = await client.tools.list({
15431558
size: 1,
15441559
});
1560+
for await (const item of response) {
1561+
console.log(item);
1562+
}
1563+
1564+
// Or you can manually iterate page-by-page
1565+
const page = await client.tools.list({
1566+
size: 1,
1567+
});
1568+
while (page.hasNextPage()) {
1569+
page = page.getNextPage();
1570+
}
15451571
```
15461572

15471573
</dd>
@@ -2432,9 +2458,20 @@ List all Datasets.
24322458
<dd>
24332459

24342460
```typescript
2435-
await client.datasets.list({
2461+
const response = await client.datasets.list({
2462+
size: 1,
2463+
});
2464+
for await (const item of response) {
2465+
console.log(item);
2466+
}
2467+
2468+
// Or you can manually iterate page-by-page
2469+
const page = await client.datasets.list({
24362470
size: 1,
24372471
});
2472+
while (page.hasNextPage()) {
2473+
page = page.getNextPage();
2474+
}
24382475
```
24392476

24402477
</dd>
@@ -2814,9 +2851,20 @@ List all Datapoints for the Dataset with the given ID.
28142851
<dd>
28152852

28162853
```typescript
2817-
await client.datasets.listDatapoints("ds_b0baF1ca7652", {
2854+
const response = await client.datasets.listDatapoints("ds_b0baF1ca7652", {
28182855
size: 1,
28192856
});
2857+
for await (const item of response) {
2858+
console.log(item);
2859+
}
2860+
2861+
// Or you can manually iterate page-by-page
2862+
const page = await client.datasets.listDatapoints("ds_b0baF1ca7652", {
2863+
size: 1,
2864+
});
2865+
while (page.hasNextPage()) {
2866+
page = page.getNextPage();
2867+
}
28202868
```
28212869

28222870
</dd>
@@ -3490,9 +3538,20 @@ Get a list of all Evaluators.
34903538
<dd>
34913539

34923540
```typescript
3493-
await client.evaluators.list({
3541+
const response = await client.evaluators.list({
34943542
size: 1,
34953543
});
3544+
for await (const item of response) {
3545+
console.log(item);
3546+
}
3547+
3548+
// Or you can manually iterate page-by-page
3549+
const page = await client.evaluators.list({
3550+
size: 1,
3551+
});
3552+
while (page.hasNextPage()) {
3553+
page = page.getNextPage();
3554+
}
34963555
```
34973556

34983557
</dd>
@@ -4354,7 +4413,7 @@ Log to a Flow.
43544413
You can use query parameters `version_id`, or `environment`, to target
43554414
an existing version of the Flow. Otherwise, the default deployed version will be chosen.
43564415

4357-
If you create the Flow Log with a `trace_status` of `incomplete`, you should later update it to `complete`
4416+
If you create the Flow Log with a `log_status` of `incomplete`, you should later update it to `complete`
43584417
in order to trigger Evaluators.
43594418

43604419
</dd>
@@ -4372,7 +4431,6 @@ in order to trigger Evaluators.
43724431

43734432
```typescript
43744433
await client.flows.log({
4375-
logId: "medqa_experiment_0001",
43764434
id: "fl_6o701g4jmcanPVHxdqD0O",
43774435
flow: {
43784436
attributes: {
@@ -4393,7 +4451,7 @@ await client.flows.log({
43934451
"Patient with a history of diabetes and hypertension presents with chest pain and shortness of breath.",
43944452
},
43954453
output: "The patient is likely experiencing a myocardial infarction. Immediate medical attention is required.",
4396-
traceStatus: "incomplete",
4454+
logStatus: "incomplete",
43974455
startTime: "2024-07-08T22:40:35",
43984456
endTime: "2024-07-08T22:40:39",
43994457
});
@@ -4470,7 +4528,8 @@ await client.flows.updateLog("medqa_experiment_0001", {
44704528
"Patient with a history of diabetes and normal tension presents with chest pain and shortness of breath.",
44714529
},
44724530
output: "The patient is likely experiencing a myocardial infarction. Immediate medical attention is required.",
4473-
traceStatus: "complete",
4531+
logStatus: "complete",
4532+
error: undefined,
44744533
});
44754534
```
44764535

@@ -4495,7 +4554,7 @@ await client.flows.updateLog("medqa_experiment_0001", {
44954554
<dl>
44964555
<dd>
44974556

4498-
**request:** `Humanloop.UpdateTraceRequest`
4557+
**request:** `Humanloop.UpdateFlowLogRequest`
44994558

45004559
</dd>
45014560
</dl>
@@ -4752,9 +4811,20 @@ Get a list of Flows.
47524811
<dd>
47534812

47544813
```typescript
4755-
await client.flows.list({
4814+
const response = await client.flows.list({
4815+
size: 1,
4816+
});
4817+
for await (const item of response) {
4818+
console.log(item);
4819+
}
4820+
4821+
// Or you can manually iterate page-by-page
4822+
const page = await client.flows.list({
47564823
size: 1,
47574824
});
4825+
while (page.hasNextPage()) {
4826+
page = page.getNextPage();
4827+
}
47584828
```
47594829

47604830
</dd>
@@ -5880,10 +5950,22 @@ Retrieve a list of Evaluations for the specified File.
58805950
<dd>
58815951

58825952
```typescript
5883-
await client.evaluations.list({
5953+
const response = await client.evaluations.list({
58845954
fileId: "pr_30gco7dx6JDq4200GVOHa",
58855955
size: 1,
58865956
});
5957+
for await (const item of response) {
5958+
console.log(item);
5959+
}
5960+
5961+
// Or you can manually iterate page-by-page
5962+
const page = await client.evaluations.list({
5963+
fileId: "pr_30gco7dx6JDq4200GVOHa",
5964+
size: 1,
5965+
});
5966+
while (page.hasNextPage()) {
5967+
page = page.getNextPage();
5968+
}
58875969
```
58885970

58895971
</dd>
@@ -6904,10 +6986,22 @@ List all Logs for the given filter criteria.
69046986
<dd>
69056987

69066988
```typescript
6907-
await client.logs.list({
6989+
const response = await client.logs.list({
6990+
fileId: "file_123abc",
6991+
size: 1,
6992+
});
6993+
for await (const item of response) {
6994+
console.log(item);
6995+
}
6996+
6997+
// Or you can manually iterate page-by-page
6998+
const page = await client.logs.list({
69086999
fileId: "file_123abc",
69097000
size: 1,
69107001
});
7002+
while (page.hasNextPage()) {
7003+
page = page.getNextPage();
7004+
}
69117005
```
69127006

69137007
</dd>
@@ -6970,7 +7064,9 @@ Delete Logs with the given IDs.
69707064
<dd>
69717065

69727066
```typescript
6973-
await client.logs.delete();
7067+
await client.logs.delete({
7068+
id: "prv_Wu6zx1lAWJRqOyL8nWuZk",
7069+
});
69747070
```
69757071

69767072
</dd>

0 commit comments

Comments
 (0)