Skip to content

Commit bc92da3

Browse files
authored
Merge pull request #697 from guardrails-ai/e2e-demo-fixes
E2E Testing Fixes
2 parents 3cecf51 + 55d0eed commit bc92da3

File tree

4 files changed

+34
-30
lines changed

4 files changed

+34
-30
lines changed

guardrails/api_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ def __init__(self, base_url: Optional[str] = None, api_key: Optional[str] = None
2323
api_key if api_key is not None else os.environ.get("GUARDRAILS_API_KEY", "")
2424
)
2525
self._client = AuthenticatedClient(
26-
_base_url=self.base_url,
27-
_follow_redirects=True,
26+
base_url=self.base_url, # type: ignore
27+
follow_redirects=True, # type: ignore
2828
token=self.api_key,
29-
_timeout=Timeout(300),
29+
timeout=Timeout(300), # type: ignore
3030
)
3131

3232
def upsert_guard(self, guard: Guard):

guardrails/guard.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,27 +1430,23 @@ def _call_server(
14301430
if isinstance(h.validated_output, AnyObject)
14311431
else h.validated_output
14321432
),
1433-
reasks=(
1433+
reasks=list(
14341434
[
1435-
(
1436-
FieldReAsk(
1437-
incorrect_value=r.to_dict().get(
1438-
"incorrect_value"
1439-
),
1440-
path=r.to_dict().get("path"),
1441-
fail_results=[
1442-
FailResult(
1443-
error_message=r.to_dict().get(
1444-
"error_message"
1445-
),
1446-
fix_value=r.to_dict().get(
1447-
"fix_value"
1448-
),
1449-
)
1450-
],
1451-
)
1452-
for r in h.reasks # type: ignore
1435+
FieldReAsk(
1436+
incorrect_value=r.to_dict().get(
1437+
"incorrect_value"
1438+
),
1439+
path=r.to_dict().get("path"),
1440+
fail_results=[
1441+
FailResult(
1442+
error_message=r.to_dict().get(
1443+
"error_message"
1444+
),
1445+
fix_value=r.to_dict().get("fix_value"),
1446+
)
1447+
],
14531448
)
1449+
for r in h.reasks # type: ignore
14541450
]
14551451
if h.reasks != UNSET
14561452
else []
@@ -1463,6 +1459,14 @@ def _call_server(
14631459
if self.history.length == 0:
14641460
self.history.push(call_log)
14651461

1466-
return ValidationOutcome[OT].from_guard_history(call_log)
1462+
# Our interfaces are too different for this to work right now.
1463+
# Once we move towards shared interfaces for both the open source
1464+
# and the api we can re-enable this.
1465+
# return ValidationOutcome[OT].from_guard_history(call_log)
1466+
return ValidationOutcome[OT](
1467+
raw_llm_output=validation_output.raw_llm_response, # type: ignore
1468+
validated_output=cast(OT, validation_output.validated_output),
1469+
validation_passed=validation_output.result,
1470+
)
14671471
else:
14681472
raise ValueError("Guard does not have an api client!")

poetry.lock

Lines changed: 6 additions & 6 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
@@ -55,7 +55,7 @@ opentelemetry-exporter-otlp-proto-http = "1.20.0"
5555
langchain-core = "^0.1.18"
5656
coloredlogs = "^15.0.1"
5757
requests = "^2.31.0"
58-
guardrails-api-client = "^0.1.0"
58+
guardrails-api-client = "^0.1.1"
5959
jwt = "^1.3.1"
6060

6161

0 commit comments

Comments
 (0)