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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "credal"

[tool.poetry]
name = "credal"
version = "0.0.22"
version = "0.0.23"
description = ""
readme = "README.md"
authors = []
Expand Down
4 changes: 2 additions & 2 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ client.actions.invoke_action(
<dl>
<dd>

**human_confirmation_channel:** `HumanConfirmationChannel` — Where we should ask for human confirmation if necessary
**require_human_confirmation:** `bool` — If true, then before executing the action we will ask for a human confirmation in Slack. If false, we may still ask for human confirmation if it's required by your organization admin.


</dd>
Expand Down Expand Up @@ -121,7 +121,7 @@ client.actions.invoke_action(
<dl>
<dd>

**require_human_confirmation:** `typing.Optional[bool]` — If true, then before executing the action we will ask for a human confirmation in Slack. If false, we may still ask for human confirmation if it's required by your organization admin.
**human_confirmation_channel:** `typing.Optional[HumanConfirmationChannel]` — Where we should ask for human confirmation if necessary


</dd>
Expand Down
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
httpx>=0.21.2
httpx-sse==0.4.0
pydantic>= 1.9.2
pydantic-core==^2.18.2
typing_extensions>= 4.0.0
24 changes: 12 additions & 12 deletions src/credal/actions/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def invoke_action(
*,
action_id: uuid.UUID,
user_email: str,
human_confirmation_channel: HumanConfirmationChannel,
require_human_confirmation: bool,
justification: str,
audit_log_id: uuid.UUID,
action_inputs: typing.Optional[typing.Any] = OMIT,
require_human_confirmation: typing.Optional[bool] = OMIT,
human_confirmation_channel: typing.Optional[HumanConfirmationChannel] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> InvokeActionResponse:
"""
Expand All @@ -43,8 +43,8 @@ def invoke_action(
The user who we should take the action on behalf of


human_confirmation_channel : HumanConfirmationChannel
Where we should ask for human confirmation if necessary
require_human_confirmation : bool
If true, then before executing the action we will ask for a human confirmation in Slack. If false, we may still ask for human confirmation if it's required by your organization admin.


justification : str
Expand All @@ -59,8 +59,8 @@ def invoke_action(
The inputs needed to execute the action


require_human_confirmation : typing.Optional[bool]
If true, then before executing the action we will ask for a human confirmation in Slack. If false, we may still ask for human confirmation if it's required by your organization admin.
human_confirmation_channel : typing.Optional[HumanConfirmationChannel]
Where we should ask for human confirmation if necessary


request_options : typing.Optional[RequestOptions]
Expand Down Expand Up @@ -140,11 +140,11 @@ async def invoke_action(
*,
action_id: uuid.UUID,
user_email: str,
human_confirmation_channel: HumanConfirmationChannel,
require_human_confirmation: bool,
justification: str,
audit_log_id: uuid.UUID,
action_inputs: typing.Optional[typing.Any] = OMIT,
require_human_confirmation: typing.Optional[bool] = OMIT,
human_confirmation_channel: typing.Optional[HumanConfirmationChannel] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> InvokeActionResponse:
"""
Expand All @@ -158,8 +158,8 @@ async def invoke_action(
The user who we should take the action on behalf of


human_confirmation_channel : HumanConfirmationChannel
Where we should ask for human confirmation if necessary
require_human_confirmation : bool
If true, then before executing the action we will ask for a human confirmation in Slack. If false, we may still ask for human confirmation if it's required by your organization admin.


justification : str
Expand All @@ -174,8 +174,8 @@ async def invoke_action(
The inputs needed to execute the action


require_human_confirmation : typing.Optional[bool]
If true, then before executing the action we will ask for a human confirmation in Slack. If false, we may still ask for human confirmation if it's required by your organization admin.
human_confirmation_channel : typing.Optional[HumanConfirmationChannel]
Where we should ask for human confirmation if necessary


request_options : typing.Optional[RequestOptions]
Expand Down
2 changes: 1 addition & 1 deletion src/credal/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_headers(self) -> typing.Dict[str, str]:
headers: typing.Dict[str, str] = {
"X-Fern-Language": "Python",
"X-Fern-SDK-Name": "credal",
"X-Fern-SDK-Version": "0.0.22",
"X-Fern-SDK-Version": "0.0.23",
}
headers["Authorization"] = f"Bearer {self._get_api_key()}"
return headers
Expand Down
12 changes: 6 additions & 6 deletions src/credal/core/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def _retry_timeout(response: httpx.Response, retries: int) -> float:


def _should_retry(response: httpx.Response) -> bool:
retriable_400s = [429, 408, 409]
return response.status_code >= 500 or response.status_code in retriable_400s
retryable_400s = [429, 408, 409]
return response.status_code >= 500 or response.status_code in retryable_400s


def remove_omit_from_dict(
Expand Down Expand Up @@ -183,7 +183,7 @@ def request(
files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None,
headers: typing.Optional[typing.Dict[str, typing.Any]] = None,
request_options: typing.Optional[RequestOptions] = None,
retries: int = 0,
retries: int = 2,
omit: typing.Optional[typing.Any] = None,
) -> httpx.Response:
base_url = self.get_base_url(base_url)
Expand Down Expand Up @@ -269,7 +269,7 @@ def stream(
files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None,
headers: typing.Optional[typing.Dict[str, typing.Any]] = None,
request_options: typing.Optional[RequestOptions] = None,
retries: int = 0,
retries: int = 2,
omit: typing.Optional[typing.Any] = None,
) -> typing.Iterator[httpx.Response]:
base_url = self.get_base_url(base_url)
Expand Down Expand Up @@ -359,7 +359,7 @@ async def request(
files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None,
headers: typing.Optional[typing.Dict[str, typing.Any]] = None,
request_options: typing.Optional[RequestOptions] = None,
retries: int = 0,
retries: int = 2,
omit: typing.Optional[typing.Any] = None,
) -> httpx.Response:
base_url = self.get_base_url(base_url)
Expand Down Expand Up @@ -445,7 +445,7 @@ async def stream(
files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None,
headers: typing.Optional[typing.Dict[str, typing.Any]] = None,
request_options: typing.Optional[RequestOptions] = None,
retries: int = 0,
retries: int = 2,
omit: typing.Optional[typing.Any] = None,
) -> typing.AsyncIterator[httpx.Response]:
base_url = self.get_base_url(base_url)
Expand Down
4 changes: 2 additions & 2 deletions src/credal/core/pydantic_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def to_jsonable_with_fallback(
class UniversalBaseModel(pydantic.BaseModel):
if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
# Allow fields begining with `model_` to be used in the model
# Allow fields beginning with `model_` to be used in the model
protected_namespaces=(),
) # type: ignore # Pydantic v2

Expand Down Expand Up @@ -128,7 +128,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
Override the default dict method to `exclude_unset` by default. This function patches
`exclude_unset` to work include fields within non-None default values.
"""
# Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2
# Note: the logic here is multiplexed given the levers exposed in Pydantic V1 vs V2
# Pydantic V1's .dict can be extremely slow, so we do not want to call it twice.
#
# We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models
Expand Down
Loading