Skip to content

Commit b873d0a

Browse files
committed
Release 0.8.0b7
1 parent 78afa86 commit b873d0a

File tree

248 files changed

+3047
-1452
lines changed

Some content is hidden

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

248 files changed

+3047
-1452
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ dist/
22
.mypy_cache/
33
__pycache__/
44
poetry.toml
5+
.ruff_cache/

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ A request is deemed retriable when any of the following HTTP status codes is ret
154154
Use the `max_retries` request option to configure this behavior.
155155

156156
```python
157-
client.prompts.log(...,{
158-
max_retries=1
157+
client.prompts.log(..., {
158+
"max_retries": 1
159159
})
160160
```
161161

@@ -167,12 +167,15 @@ The SDK defaults to a 60 second timeout. You can configure this with a timeout o
167167

168168
from humanloop import Humanloop
169169

170-
client = Humanloop(..., { timeout=20.0 }, )
170+
client = Humanloop(
171+
...,
172+
timeout=20.0,
173+
)
171174

172175

173176
# Override timeout for a specific method
174-
client.prompts.log(...,{
175-
timeout_in_seconds=1
177+
client.prompts.log(..., {
178+
"timeout_in_seconds": 1
176179
})
177180
```
178181

@@ -186,7 +189,7 @@ from humanloop import Humanloop
186189

187190
client = Humanloop(
188191
...,
189-
http_client=httpx.Client(
192+
httpx_client=httpx.Client(
190193
proxies="http://my.test.proxy.example.com",
191194
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
192195
),

poetry.lock

Lines changed: 28 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pytest = "^7.4.0"
4343
pytest-asyncio = "^0.23.5"
4444
python-dateutil = "^2.9.0"
4545
types-python-dateutil = "^2.9.0.20240316"
46+
ruff = "^0.5.6"
4647

4748
[tool.pytest.ini_options]
4849
testpaths = [ "tests" ]
@@ -51,6 +52,9 @@ asyncio_mode = "auto"
5152
[tool.mypy]
5253
plugins = ["pydantic.mypy"]
5354

55+
[tool.ruff]
56+
line-length = 120
57+
5458

5559
[build-system]
5660
requires = ["poetry-core"]

reference.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,15 @@ Controls how the model uses tools. The following options are supported:
242242
<dl>
243243
<dd>
244244

245-
**provider_request:** `typing.Optional[typing.Dict[str, typing.Any]]` — Raw request sent to provider.
245+
**provider_request:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — Raw request sent to provider.
246246

247247
</dd>
248248
</dl>
249249

250250
<dl>
251251
<dd>
252252

253-
**provider_response:** `typing.Optional[typing.Dict[str, typing.Any]]` — Raw response received the provider.
253+
**provider_response:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — Raw response received the provider.
254254

255255
</dd>
256256
</dl>
@@ -274,7 +274,7 @@ Controls how the model uses tools. The following options are supported:
274274
<dl>
275275
<dd>
276276

277-
**inputs:** `typing.Optional[typing.Dict[str, typing.Any]]` — The inputs passed to the prompt template.
277+
**inputs:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — The inputs passed to the prompt template.
278278

279279
</dd>
280280
</dl>
@@ -290,7 +290,7 @@ Controls how the model uses tools. The following options are supported:
290290
<dl>
291291
<dd>
292292

293-
**metadata:** `typing.Optional[typing.Dict[str, typing.Any]]` — Any additional metadata to record.
293+
**metadata:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — Any additional metadata to record.
294294

295295
</dd>
296296
</dl>
@@ -492,7 +492,7 @@ Controls how the model uses tools. The following options are supported:
492492
<dl>
493493
<dd>
494494

495-
**inputs:** `typing.Optional[typing.Dict[str, typing.Any]]` — The inputs passed to the prompt template.
495+
**inputs:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — The inputs passed to the prompt template.
496496

497497
</dd>
498498
</dl>
@@ -508,7 +508,7 @@ Controls how the model uses tools. The following options are supported:
508508
<dl>
509509
<dd>
510510

511-
**metadata:** `typing.Optional[typing.Dict[str, typing.Any]]` — Any additional metadata to record.
511+
**metadata:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — Any additional metadata to record.
512512

513513
</dd>
514514
</dl>
@@ -901,7 +901,7 @@ client.prompts.upsert(
901901
<dl>
902902
<dd>
903903

904-
**other:** `typing.Optional[typing.Dict[str, typing.Any]]` — Other parameter values to be passed to the provider call.
904+
**other:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — Other parameter values to be passed to the provider call.
905905

906906
</dd>
907907
</dl>
@@ -1868,15 +1868,15 @@ client.tools.log(
18681868
<dl>
18691869
<dd>
18701870

1871-
**provider_request:** `typing.Optional[typing.Dict[str, typing.Any]]` — Raw request sent to provider.
1871+
**provider_request:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — Raw request sent to provider.
18721872

18731873
</dd>
18741874
</dl>
18751875

18761876
<dl>
18771877
<dd>
18781878

1879-
**provider_response:** `typing.Optional[typing.Dict[str, typing.Any]]` — Raw response received the provider.
1879+
**provider_response:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — Raw response received the provider.
18801880

18811881
</dd>
18821882
</dl>
@@ -1900,7 +1900,7 @@ client.tools.log(
19001900
<dl>
19011901
<dd>
19021902

1903-
**inputs:** `typing.Optional[typing.Dict[str, typing.Any]]` — The inputs passed to the prompt template.
1903+
**inputs:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — The inputs passed to the prompt template.
19041904

19051905
</dd>
19061906
</dl>
@@ -1916,7 +1916,7 @@ client.tools.log(
19161916
<dl>
19171917
<dd>
19181918

1919-
**metadata:** `typing.Optional[typing.Dict[str, typing.Any]]` — Any additional metadata to record.
1919+
**metadata:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — Any additional metadata to record.
19201920

19211921
</dd>
19221922
</dl>
@@ -2197,7 +2197,7 @@ client.tools.upsert(
21972197
<dl>
21982198
<dd>
21992199

2200-
**setup_values:** `typing.Optional[typing.Dict[str, typing.Any]]` — Values needed to setup the Tool, defined in JSON Schema format: https://json-schema.org/
2200+
**setup_values:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — Values needed to setup the Tool, defined in JSON Schema format: https://json-schema.org/
22012201

22022202
</dd>
22032203
</dl>
@@ -5872,15 +5872,15 @@ client.evaluators.log(
58725872
<dl>
58735873
<dd>
58745874

5875-
**provider_request:** `typing.Optional[typing.Dict[str, typing.Any]]` — Raw request sent to provider. Only populated for LLM Evaluator Logs.
5875+
**provider_request:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — Raw request sent to provider. Only populated for LLM Evaluator Logs.
58765876

58775877
</dd>
58785878
</dl>
58795879

58805880
<dl>
58815881
<dd>
58825882

5883-
**provider_response:** `typing.Optional[typing.Dict[str, typing.Any]]` — Raw response received the provider. Only populated for LLM Evaluator Logs.
5883+
**provider_response:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — Raw response received the provider. Only populated for LLM Evaluator Logs.
58845884

58855885
</dd>
58865886
</dl>
@@ -5896,7 +5896,7 @@ client.evaluators.log(
58965896
<dl>
58975897
<dd>
58985898

5899-
**inputs:** `typing.Optional[typing.Dict[str, typing.Any]]` — The inputs passed to the prompt template.
5899+
**inputs:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — The inputs passed to the prompt template.
59005900

59015901
</dd>
59025902
</dl>
@@ -5912,7 +5912,7 @@ client.evaluators.log(
59125912
<dl>
59135913
<dd>
59145914

5915-
**metadata:** `typing.Optional[typing.Dict[str, typing.Any]]` — Any additional metadata to record.
5915+
**metadata:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — Any additional metadata to record.
59165916

59175917
</dd>
59185918
</dl>

src/humanloop/client.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
# This file was auto-generated by Fern from our API Definition.
22

3-
import os
43
import typing
5-
4+
from .environment import HumanloopEnvironment
5+
import os
66
import httpx
7-
87
from .core.api_error import ApiError
9-
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
10-
from .datasets.client import AsyncDatasetsClient, DatasetsClient
11-
from .environment import HumanloopEnvironment
12-
from .evaluations.client import AsyncEvaluationsClient, EvaluationsClient
13-
from .evaluators.client import AsyncEvaluatorsClient, EvaluatorsClient
14-
from .logs.client import AsyncLogsClient, LogsClient
15-
from .prompts.client import AsyncPromptsClient, PromptsClient
16-
from .sessions.client import AsyncSessionsClient, SessionsClient
17-
from .tools.client import AsyncToolsClient, ToolsClient
8+
from .core.client_wrapper import SyncClientWrapper
9+
from .prompts.client import PromptsClient
10+
from .tools.client import ToolsClient
11+
from .datasets.client import DatasetsClient
12+
from .evaluations.client import EvaluationsClient
13+
from .evaluators.client import EvaluatorsClient
14+
from .logs.client import LogsClient
15+
from .sessions.client import SessionsClient
16+
from .core.client_wrapper import AsyncClientWrapper
17+
from .prompts.client import AsyncPromptsClient
18+
from .tools.client import AsyncToolsClient
19+
from .datasets.client import AsyncDatasetsClient
20+
from .evaluations.client import AsyncEvaluationsClient
21+
from .evaluators.client import AsyncEvaluatorsClient
22+
from .logs.client import AsyncLogsClient
23+
from .sessions.client import AsyncSessionsClient
1824

1925

2026
class Humanloop:
@@ -62,7 +68,7 @@ def __init__(
6268
api_key: typing.Optional[str] = os.getenv("HUMANLOOP_API_KEY"),
6369
timeout: typing.Optional[float] = None,
6470
follow_redirects: typing.Optional[bool] = True,
65-
httpx_client: typing.Optional[httpx.Client] = None
71+
httpx_client: typing.Optional[httpx.Client] = None,
6672
):
6773
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
6874
if api_key is None:
@@ -133,7 +139,7 @@ def __init__(
133139
api_key: typing.Optional[str] = os.getenv("HUMANLOOP_API_KEY"),
134140
timeout: typing.Optional[float] = None,
135141
follow_redirects: typing.Optional[bool] = True,
136-
httpx_client: typing.Optional[httpx.AsyncClient] = None
142+
httpx_client: typing.Optional[httpx.AsyncClient] = None,
137143
):
138144
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
139145
if api_key is None:

src/humanloop/core/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
IS_PYDANTIC_V2,
1212
UniversalBaseModel,
1313
UniversalRootModel,
14-
deep_union_pydantic_dicts,
1514
parse_obj_as,
1615
universal_field_validator,
1716
universal_root_validator,
@@ -43,7 +42,6 @@
4342
"construct_type",
4443
"convert_and_respect_annotation_metadata",
4544
"convert_file_dict_to_httpx_tuples",
46-
"deep_union_pydantic_dicts",
4745
"encode_query",
4846
"jsonable_encoder",
4947
"parse_obj_as",

src/humanloop/core/client_wrapper.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# This file was auto-generated by Fern from our API Definition.
22

33
import typing
4-
54
import httpx
6-
7-
from .http_client import AsyncHttpClient, HttpClient
5+
from .http_client import HttpClient
6+
from .http_client import AsyncHttpClient
87

98

109
class BaseClientWrapper:

src/humanloop/core/file.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@
1313
# (filename, file (or bytes), content_type)
1414
typing.Tuple[typing.Optional[str], FileContent, typing.Optional[str]],
1515
# (filename, file (or bytes), content_type, headers)
16-
typing.Tuple[typing.Optional[str], FileContent, typing.Optional[str], typing.Mapping[str, str]],
16+
typing.Tuple[
17+
typing.Optional[str],
18+
FileContent,
19+
typing.Optional[str],
20+
typing.Mapping[str, str],
21+
],
1722
]
1823

1924

2025
def convert_file_dict_to_httpx_tuples(
21-
d: typing.Dict[str, typing.Union[File, typing.List[File]]]
26+
d: typing.Dict[str, typing.Union[File, typing.List[File]]],
2227
) -> typing.List[typing.Tuple[str, File]]:
2328
"""
2429
The format we use is a list of tuples, where the first element is the

src/humanloop/core/http_client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ def _should_retry(response: httpx.Response) -> bool:
9090

9191

9292
def remove_omit_from_dict(
93-
original: typing.Dict[str, typing.Optional[typing.Any]], omit: typing.Optional[typing.Any]
93+
original: typing.Dict[str, typing.Optional[typing.Any]],
94+
omit: typing.Optional[typing.Any],
9495
) -> typing.Dict[str, typing.Any]:
9596
if omit is None:
9697
return original
@@ -142,7 +143,8 @@ def get_request_body(
142143
# If both data and json are None, we send json data in the event extra properties are specified
143144
json_body = maybe_filter_request_body(json, request_options, omit)
144145

145-
return json_body, data_body
146+
# If you have an empty JSON body, you should just send None
147+
return (json_body if json_body != {} else None), data_body if data_body != {} else None
146148

147149

148150
class HttpClient:

0 commit comments

Comments
 (0)