Skip to content

Commit ee9cbcb

Browse files
committed
Release 0.8.22
1 parent 9e7f556 commit ee9cbcb

File tree

19 files changed

+295
-852
lines changed

19 files changed

+295
-852
lines changed

poetry.lock

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

pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[project]
2-
name = "humanloop"
3-
41
[tool.poetry]
52
name = "humanloop"
63
version = "0.8.22"

reference.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ client.prompts.log(
5656
messages=[{"role": "user", "content": "What really happened at Roswell?"}],
5757
inputs={"person": "Trump"},
5858
created_at=datetime.datetime.fromisoformat(
59-
"2024-07-18 23:29:35.178000+00:00",
59+
"2024-07-19 00:29:35.178000+00:00",
6060
),
6161
provider_latency=6.5931549072265625,
6262
output_message={
@@ -6592,10 +6592,10 @@ client.flows.log(
65926592
output="The patient is likely experiencing a myocardial infarction. Immediate medical attention is required.",
65936593
trace_status="incomplete",
65946594
start_time=datetime.datetime.fromisoformat(
6595-
"2024-07-08 21:40:35+00:00",
6595+
"2024-07-08 22:40:35+00:00",
65966596
),
65976597
end_time=datetime.datetime.fromisoformat(
6598-
"2024-07-08 21:40:39+00:00",
6598+
"2024-07-08 22:40:39+00:00",
65996599
),
66006600
)
66016601

src/humanloop/core/file.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,25 @@ def convert_file_dict_to_httpx_tuples(
4343
return httpx_tuples
4444

4545

46-
def with_content_type(*, file: File, content_type: str) -> File:
47-
""" """
46+
def with_content_type(*, file: File, default_content_type: str) -> File:
47+
"""
48+
This function resolves to the file's content type, if provided, and defaults
49+
to the default_content_type value if not.
50+
"""
4851
if isinstance(file, tuple):
4952
if len(file) == 2:
5053
filename, content = cast(Tuple[Optional[str], FileContent], file) # type: ignore
51-
return (filename, content, content_type)
54+
return (filename, content, default_content_type)
5255
elif len(file) == 3:
53-
filename, content, _ = cast(Tuple[Optional[str], FileContent, Optional[str]], file) # type: ignore
54-
return (filename, content, content_type)
56+
filename, content, file_content_type = cast(Tuple[Optional[str], FileContent, Optional[str]], file) # type: ignore
57+
out_content_type = file_content_type or default_content_type
58+
return (filename, content, out_content_type)
5559
elif len(file) == 4:
56-
filename, content, _, headers = cast( # type: ignore
60+
filename, content, file_content_type, headers = cast( # type: ignore
5761
Tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]], file
5862
)
59-
return (filename, content, content_type, headers)
63+
out_content_type = file_content_type or default_content_type
64+
return (filename, content, out_content_type, headers)
6065
else:
6166
raise ValueError(f"Unexpected tuple length: {len(file)}")
62-
return (None, file, content_type)
67+
return (None, file, default_content_type)

src/humanloop/core/http_client.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,11 @@ def request(
227227
json=json_body,
228228
data=data_body,
229229
content=content,
230-
files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files))
231-
if (files is not None and files is not omit)
232-
else None,
230+
files=(
231+
convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit))
232+
if (files is not None and files is not omit)
233+
else None
234+
),
233235
timeout=timeout,
234236
)
235237

@@ -311,9 +313,11 @@ def stream(
311313
json=json_body,
312314
data=data_body,
313315
content=content,
314-
files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files))
315-
if (files is not None and files is not omit)
316-
else None,
316+
files=(
317+
convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit))
318+
if (files is not None and files is not omit)
319+
else None
320+
),
317321
timeout=timeout,
318322
) as stream:
319323
yield stream
@@ -400,7 +404,11 @@ async def request(
400404
json=json_body,
401405
data=data_body,
402406
content=content,
403-
files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None,
407+
files=(
408+
convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit))
409+
if files is not None
410+
else None
411+
),
404412
timeout=timeout,
405413
)
406414

@@ -481,7 +489,11 @@ async def stream(
481489
json=json_body,
482490
data=data_body,
483491
content=content,
484-
files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None,
492+
files=(
493+
convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit))
494+
if files is not None
495+
else None
496+
),
485497
timeout=timeout,
486498
) as stream:
487499
yield stream

src/humanloop/core/request_options.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ class RequestOptions(typing.TypedDict, total=False):
2323
- additional_query_parameters: typing.Dict[str, typing.Any]. A dictionary containing additional parameters to spread into the request's query parameters dict
2424
2525
- additional_body_parameters: typing.Dict[str, typing.Any]. A dictionary containing additional parameters to spread into the request's body parameters dict
26+
27+
- chunk_size: int. The size, in bytes, to process each chunk of data being streamed back within the response. This equates to leveraging `chunk_size` within `requests` or `httpx`, and is only leveraged for file downloads.
2628
"""
2729

2830
timeout_in_seconds: NotRequired[int]
2931
max_retries: NotRequired[int]
3032
additional_headers: NotRequired[typing.Dict[str, typing.Any]]
3133
additional_query_parameters: NotRequired[typing.Dict[str, typing.Any]]
3234
additional_body_parameters: NotRequired[typing.Dict[str, typing.Any]]
35+
chunk_size: NotRequired[int]

src/humanloop/datasets/client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ def upsert(
259259
"attributes": attributes,
260260
"commit_message": commit_message,
261261
},
262+
headers={
263+
"content-type": "application/json",
264+
},
262265
request_options=request_options,
263266
omit=OMIT,
264267
)
@@ -473,6 +476,9 @@ def move(
473476
"path": path,
474477
"name": name,
475478
},
479+
headers={
480+
"content-type": "application/json",
481+
},
476482
request_options=request_options,
477483
omit=OMIT,
478484
)
@@ -1338,6 +1344,9 @@ async def main() -> None:
13381344
"attributes": attributes,
13391345
"commit_message": commit_message,
13401346
},
1347+
headers={
1348+
"content-type": "application/json",
1349+
},
13411350
request_options=request_options,
13421351
omit=OMIT,
13431352
)
@@ -1576,6 +1585,9 @@ async def main() -> None:
15761585
"path": path,
15771586
"name": name,
15781587
},
1588+
headers={
1589+
"content-type": "application/json",
1590+
},
15791591
request_options=request_options,
15801592
omit=OMIT,
15811593
)

src/humanloop/directories/client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ def create(
120120
"parent_id": parent_id,
121121
"path": path,
122122
},
123+
headers={
124+
"content-type": "application/json",
125+
},
123126
request_options=request_options,
124127
omit=OMIT,
125128
)
@@ -311,6 +314,9 @@ def update(
311314
"parent_id": parent_id,
312315
"path": path,
313316
},
317+
headers={
318+
"content-type": "application/json",
319+
},
314320
request_options=request_options,
315321
omit=OMIT,
316322
)
@@ -458,6 +464,9 @@ async def main() -> None:
458464
"parent_id": parent_id,
459465
"path": path,
460466
},
467+
headers={
468+
"content-type": "application/json",
469+
},
461470
request_options=request_options,
462471
omit=OMIT,
463472
)
@@ -673,6 +682,9 @@ async def main() -> None:
673682
"parent_id": parent_id,
674683
"path": path,
675684
},
685+
headers={
686+
"content-type": "application/json",
687+
},
676688
request_options=request_options,
677689
omit=OMIT,
678690
)

0 commit comments

Comments
 (0)