Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
tssweeney committed Jan 3, 2025
1 parent c6d8cde commit a26b84d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/docs/guides/evaluation/guardrails_and_monitors.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Guardrails are a way to prevent the LLM from generating harmful or inappropriate

```python
res, call = op.call(user_input)
scorer_res = await call.apply_scorer(guardrail)
scorer_res = call.apply_scorer(guardrail)
if scorer_res.score < 0.5:
# Do something
else:
Expand Down
6 changes: 5 additions & 1 deletion tests/trace/test_call_apply_scorer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
def test_scorer_op_no_context():


def test_scorer_op_no_context(client):


raise NotImplementedError()


Expand Down
8 changes: 7 additions & 1 deletion weave/trace/weave_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import asyncio
import dataclasses
import datetime
import inspect
Expand Down Expand Up @@ -462,7 +463,7 @@ def set_display_name(self, name: str | None) -> None:
def remove_display_name(self) -> None:
self.set_display_name(None)

async def apply_scorer(
async def _apply_scorer_async(
self, scorer_op: Op | Scorer, additional_context: dict | None = None
) -> ApplyScorerResult:
"""
Expand Down Expand Up @@ -515,6 +516,11 @@ async def apply_scorer(
score_call=score_call,
)

def apply_scorer(
self, scorer_op: Op | Scorer, additional_context: dict | None = None
) -> ApplyScorerResult:
return asyncio.run(self._apply_scorer_async(scorer_op, additional_context))


def make_client_call(
entity: str, project: str, server_call: CallSchema, server: TraceServerInterface
Expand Down

0 comments on commit a26b84d

Please sign in to comment.