Skip to content

Commit 9649c93

Browse files
Prompt utils (#21)
add prompt utils
1 parent 0ca96f9 commit 9649c93

File tree

11 files changed

+234
-72
lines changed

11 files changed

+234
-72
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ client.prompts.log(
4141
messages=[{"role": "user", "content": "What really happened at Roswell?"}],
4242
inputs={"person": "Trump"},
4343
created_at=datetime.datetime.fromisoformat(
44-
"2024-07-19 00:29:35.178000+00:00",
44+
"2024-07-18 23:29:35.178000+00:00",
4545
),
4646
provider_latency=6.5931549072265625,
4747
output_message={
@@ -88,7 +88,7 @@ async def main() -> None:
8888
],
8989
inputs={"person": "Trump"},
9090
created_at=datetime.datetime.fromisoformat(
91-
"2024-07-19 00:29:35.178000+00:00",
91+
"2024-07-18 23:29:35.178000+00:00",
9292
),
9393
provider_latency=6.5931549072265625,
9494
output_message={

mypy.ini

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[mypy]
2-
exclude = ^src/humanloop/eval_utils\.py$
2+
exclude = (?x)(
3+
^src/humanloop/eval_utils\.py$
4+
| ^src/humanloop/prompt_utils\.py$
5+
)

poetry.lock

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

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.8.6b3"
3+
version = "0.8.6"
44
description = ""
55
readme = "README.md"
66
authors = []

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-19 00:29:35.178000+00:00",
59+
"2024-07-18 23:29:35.178000+00:00",
6060
),
6161
provider_latency=6.5931549072265625,
6262
output_message={
@@ -6258,10 +6258,10 @@ client.flows.log(
62586258
output="The patient is likely experiencing a myocardial infarction. Immediate medical attention is required.",
62596259
trace_status="incomplete",
62606260
start_time=datetime.datetime.fromisoformat(
6261-
"2024-07-08 22:40:35+00:00",
6261+
"2024-07-08 21:40:35+00:00",
62626262
),
62636263
end_time=datetime.datetime.fromisoformat(
6264-
"2024-07-08 22:40:39+00:00",
6264+
"2024-07-08 21:40:39+00:00",
62656265
),
62666266
)
62676267

src/humanloop/client.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
from .base_client import BaseHumanloop, AsyncBaseHumanloop
77
from .environment import HumanloopEnvironment
88
from .eval_utils import _run_eval, Dataset, File, Evaluator, EvaluatorCheck
9-
from .base_client import EvaluationsClient
9+
from .prompts.client import PromptsClient
10+
from .evaluations.client import EvaluationsClient
11+
from .prompt_utils import populate_template
1012

11-
class ExtendedEvalsClient(EvaluationsClient):
1213

14+
class ExtendedEvalsClient(EvaluationsClient):
1315
client: BaseHumanloop
1416

1517
def run(
@@ -21,8 +23,8 @@ def run(
2123
# logs: typing.Sequence[dict] | None = None,
2224
workers: int = 4,
2325
) -> List[EvaluatorCheck]:
24-
"""
25-
Evaluate your function for a given `Dataset` and set of `Evaluators`.
26+
"""Evaluate your function for a given `Dataset` and set of `Evaluators`.
27+
2628
:param file: the Humanloop file being evaluated, including a function to run over the dataset.
2729
:param name: the name of the Evaluation to run. If it does not exist, a new Evaluation will be created under your File.
2830
:param dataset: the dataset to map your function over to produce the outputs required by the Evaluation.
@@ -43,6 +45,10 @@ def run(
4345
)
4446

4547

48+
class ExtendedPromptsClient(PromptsClient):
49+
populate_template = staticmethod(populate_template)
50+
51+
4652
class Humanloop(BaseHumanloop):
4753
"""
4854
See docstring of BaseHumanloop.
@@ -75,6 +81,7 @@ def __init__(
7581
eval_client = ExtendedEvalsClient(client_wrapper=self._client_wrapper)
7682
eval_client.client = self
7783
self.evaluations = eval_client
84+
self.prompts = ExtendedPromptsClient(client_wrapper=self._client_wrapper)
7885

7986

8087
class AsyncHumanloop(AsyncBaseHumanloop):
@@ -84,4 +91,4 @@ class AsyncHumanloop(AsyncBaseHumanloop):
8491
TODO: Add custom evaluation utilities for async case.
8592
"""
8693

87-
pass
94+
pass

src/humanloop/core/client_wrapper.py

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

0 commit comments

Comments
 (0)