Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions guardrails/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def __init__(self, base_url: Optional[str] = None, api_key: Optional[str] = None
api_key if api_key is not None else os.environ.get("GUARDRAILS_API_KEY", "")
)
self._client = AuthenticatedClient(
_base_url=self.base_url,
_follow_redirects=True,
base_url=self.base_url, # type: ignore
follow_redirects=True, # type: ignore
token=self.api_key,
_timeout=Timeout(300),
timeout=Timeout(300), # type: ignore
)

def upsert_guard(self, guard: Guard):
Expand Down
44 changes: 24 additions & 20 deletions guardrails/guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -1430,27 +1430,23 @@ def _call_server(
if isinstance(h.validated_output, AnyObject)
else h.validated_output
),
reasks=(
reasks=list(
[
(
FieldReAsk(
incorrect_value=r.to_dict().get(
"incorrect_value"
),
path=r.to_dict().get("path"),
fail_results=[
FailResult(
error_message=r.to_dict().get(
"error_message"
),
fix_value=r.to_dict().get(
"fix_value"
),
)
],
)
for r in h.reasks # type: ignore
FieldReAsk(
incorrect_value=r.to_dict().get(
"incorrect_value"
),
path=r.to_dict().get("path"),
fail_results=[
FailResult(
error_message=r.to_dict().get(
"error_message"
),
fix_value=r.to_dict().get("fix_value"),
)
],
)
for r in h.reasks # type: ignore
]
if h.reasks != UNSET
else []
Expand All @@ -1463,6 +1459,14 @@ def _call_server(
if self.history.length == 0:
self.history.push(call_log)

return ValidationOutcome[OT].from_guard_history(call_log)
# Our interfaces are too different for this to work right now.
# Once we move towards shared interfaces for both the open source
# and the api we can re-enable this.
# return ValidationOutcome[OT].from_guard_history(call_log)
return ValidationOutcome[OT](
raw_llm_output=validation_output.raw_llm_response, # type: ignore
validated_output=cast(OT, validation_output.validated_output),
validation_passed=validation_output.result,
)
else:
raise ValueError("Guard does not have an api client!")
12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ opentelemetry-exporter-otlp-proto-http = "1.20.0"
langchain-core = "^0.1.18"
coloredlogs = "^15.0.1"
requests = "^2.31.0"
guardrails-api-client = "^0.1.0"
guardrails-api-client = "^0.1.1"
jwt = "^1.3.1"


Expand Down