Skip to content

Commit 905e12e

Browse files
author
Andrei Bratu
committed
Merge branch 'master' into decorators-fixes-latest
2 parents 89d52d0 + 7fe741c commit 905e12e

301 files changed

Lines changed: 2185 additions & 1196 deletions

File tree

Some content is hidden

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

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,51 @@ try {
9191
}
9292
```
9393

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+
94118
## Advanced
95119

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+
96132
### Retries
97133

98134
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
99-
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
100136
retry limit (default: 2).
101137

102-
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:
103139

104140
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
105141
- [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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
"test": "jest"
1313
},
1414
"dependencies": {
15+
"url-join": "4.0.1",
16+
"form-data": "^4.0.0",
17+
"formdata-node": "^6.0.3",
18+
"node-fetch": "^2.7.0",
19+
"qs": "^6.13.1",
20+
"readable-stream": "^4.5.2",
21+
"form-data-encoder": "^4.0.2",
1522
"@opentelemetry/api": "1.9.0",
1623
"@opentelemetry/auto-instrumentations-node": "0.53.0",
1724
"@opentelemetry/sdk-metrics": "1.28.0",
@@ -34,6 +41,20 @@
3441
"url-join": "4.0.1"
3542
},
3643
"devDependencies": {
44+
"@types/url-join": "4.0.1",
45+
"@types/qs": "^6.9.17",
46+
"@types/node-fetch": "^2.6.12",
47+
"@types/readable-stream": "^4.0.18",
48+
"webpack": "^5.97.1",
49+
"ts-loader": "^9.5.1",
50+
"jest": "^29.7.0",
51+
"@types/jest": "^29.5.14",
52+
"ts-jest": "^29.1.1",
53+
"jest-environment-jsdom": "^29.7.0",
54+
"@types/node": "^18.19.70",
55+
"prettier": "^3.4.2",
56+
"typescript": "~5.7.2",
57+
"openai": "^4.74.0",
3758
"@anthropic-ai/sdk": "^0.32.1",
3859
"@babel/core": "^7.26.0",
3960
"@babel/plugin-transform-modules-commonjs": "^7.26.3",

0 commit comments

Comments
 (0)