diff --git a/guardrails/api_client.py b/guardrails/api_client.py index 8b7376e89..bf8b7323b 100644 --- a/guardrails/api_client.py +++ b/guardrails/api_client.py @@ -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): diff --git a/guardrails/guard.py b/guardrails/guard.py index 0f65407fc..7148d4f53 100644 --- a/guardrails/guard.py +++ b/guardrails/guard.py @@ -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 [] @@ -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!") diff --git a/poetry.lock b/poetry.lock index e47608f14..5d9c06983 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "aiohttp" @@ -1804,13 +1804,13 @@ protobuf = ["grpcio-tools (>=1.62.1)"] [[package]] name = "guardrails-api-client" -version = "0.1.0" +version = "0.1.1" description = "A client library for accessing Guardrails API" optional = false -python-versions = ">=3.8, <4" +python-versions = "<4,>=3.8" files = [ - {file = "guardrails-api-client-0.1.0.tar.gz", hash = "sha256:89276b4c4f1d7bca280c04a18f9eafaaafa3fea73da90ce2061790ebbb2af475"}, - {file = "guardrails_api_client-0.1.0-py3-none-any.whl", hash = "sha256:ec5f5abbd0adc72203ac1601e6aee562db2de65bd5ec509b45c26fd0eed7c733"}, + {file = "guardrails-api-client-0.1.1.tar.gz", hash = "sha256:d707661b0e63269c9ab257c4ba6eed20af18a734607cab8bb3bee0d2883bc50f"}, + {file = "guardrails_api_client-0.1.1-py3-none-any.whl", hash = "sha256:99baf4a11fcc61b420197c019fa24a479a44afb44b858e43d874cc95926295fd"}, ] [package.dependencies] @@ -8150,4 +8150,4 @@ vectordb = ["faiss-cpu", "numpy"] [metadata] lock-version = "2.0" python-versions = "^3.8.1" -content-hash = "0a872ca2ce54a5f8f7636cb1be1dd01fab9ad2ac29b6b6c6563a7bd382c3ffa4" +content-hash = "4073f58d4362af9147bc404b760d25659dfaf5a223566a926edf0f26e6a072cc" diff --git a/pyproject.toml b/pyproject.toml index 0699197ef..026af0af3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"