diff --git a/pyproject.toml b/pyproject.toml index 595bcc1..368bea9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "credal" [tool.poetry] name = "credal" -version = "0.0.23" +version = "0.0.24" description = "" readme = "README.md" authors = [] diff --git a/reference.md b/reference.md index 17e4f0d..a1f5bd2 100644 --- a/reference.md +++ b/reference.md @@ -1,147 +1,4 @@ # Reference -## Actions -
client.actions.invoke_action(...) -
-
- -#### 📝 Description - -
-
- -
-
- -Invoke an action, asking for human confirmation if necessary -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -import uuid - -from credal import CredalApi -from credal.actions import HumanConfirmationChannel_SlackThread - -client = CredalApi( - api_key="YOUR_API_KEY", -) -client.actions.invoke_action( - action_id=uuid.UUID( - "2b5cf2b8-3df3-11ef-9a96-332d4470d189", - ), - action_inputs={ - "textToAppend": "If you need more help, please contact your direct manager." - }, - user_email="ben@credal.ai", - require_human_confirmation=True, - human_confirmation_channel=HumanConfirmationChannel_SlackThread( - channel_id="ABC123", - thread_timestamp="123456789", - ), - justification="The user directly asked to update the Relocations Confluence document with this text.", - audit_log_id=uuid.UUID( - "3df3f2b8-3df3-11ef-9a96-332d447011ef", - ), -) - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**action_id:** `uuid.UUID` - -
-
- -
-
- -**user_email:** `str` — The user who we should take the action on behalf of - - -
-
- -
-
- -**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` — The justification for requesting this action. This is likely generated by the LLM that requested the action. - - -
-
- -
-
- -**audit_log_id:** `uuid.UUID` — Audit log for the message that called for this action - - -
-
- -
-
- -**action_inputs:** `typing.Optional[typing.Any]` — The inputs needed to execute the action - - -
-
- -
-
- -**human_confirmation_channel:** `typing.Optional[HumanConfirmationChannel]` — Where we should ask for human confirmation if necessary - - -
-
- -
-
- -**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - -
-
-
-
- - -
-
-
- ## Copilots
client.copilots.create_copilot(...)
diff --git a/src/credal/__init__.py b/src/credal/__init__.py index 965acd1..8bc95ee 100644 --- a/src/credal/__init__.py +++ b/src/credal/__init__.py @@ -1,17 +1,6 @@ # This file was auto-generated by Fern from our API Definition. -from . import actions, common, copilots, document_catalog, document_collections, permissions_service, search, users -from .actions import ( - ActionStatus, - Conversation, - DirectMessage, - HumanConfirmationChannel, - HumanConfirmationChannel_Conversation, - HumanConfirmationChannel_DirectMessage, - HumanConfirmationChannel_SlackThread, - InvokeActionResponse, - SlackThread, -) +from . import common, copilots, document_catalog, document_collections, permissions_service, search, users from .client import AsyncCredalApi, CredalApi from .common import ( Collaborator, @@ -108,7 +97,6 @@ __all__ = [ "Action", - "ActionStatus", "AiEndpointConfiguration", "AsyncCredalApi", "AuthorizedResource", @@ -120,7 +108,6 @@ "Collaborator", "CollectionFilteredData", "Configuration", - "Conversation", "CreateCollectionResponse", "CreateConversationResponse", "CreateCopilotResponse", @@ -131,7 +118,6 @@ "DatetimeFieldSchema", "DeleteCollectionResponse", "DeleteCopilotResponse", - "DirectMessage", "DocumentCollectionSearchOptions", "DocumentCollectionSearchResult", "DocumentMetadataPatch", @@ -146,14 +132,9 @@ "Filter_String", "FinalChunk", "Group", - "HumanConfirmationChannel", - "HumanConfirmationChannel_Conversation", - "HumanConfirmationChannel_DirectMessage", - "HumanConfirmationChannel_SlackThread", "InitialChunk", "InputVariable", "InsertedAuditLog", - "InvokeActionResponse", "MessageBlocked", "MessageFeedback", "MessageReply", @@ -182,7 +163,6 @@ "SendMessageResponse_AiResponseResult", "SendMessageResponse_BlockedResult", "SingleFieldFilter", - "SlackThread", "StreamingChunk", "StreamingChunk_Blocked", "StreamingChunk_DataChunk", @@ -198,7 +178,6 @@ "UserMetadataPatch", "WebSearchResult", "__version__", - "actions", "common", "copilots", "document_catalog", diff --git a/src/credal/actions/__init__.py b/src/credal/actions/__init__.py deleted file mode 100644 index 955caa3..0000000 --- a/src/credal/actions/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from .types import ( - ActionStatus, - Conversation, - DirectMessage, - HumanConfirmationChannel, - HumanConfirmationChannel_Conversation, - HumanConfirmationChannel_DirectMessage, - HumanConfirmationChannel_SlackThread, - InvokeActionResponse, - SlackThread, -) - -__all__ = [ - "ActionStatus", - "Conversation", - "DirectMessage", - "HumanConfirmationChannel", - "HumanConfirmationChannel_Conversation", - "HumanConfirmationChannel_DirectMessage", - "HumanConfirmationChannel_SlackThread", - "InvokeActionResponse", - "SlackThread", -] diff --git a/src/credal/actions/client.py b/src/credal/actions/client.py deleted file mode 100644 index c55128e..0000000 --- a/src/credal/actions/client.py +++ /dev/null @@ -1,253 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing -from ..core.client_wrapper import SyncClientWrapper -import uuid -from .types.human_confirmation_channel import HumanConfirmationChannel -from ..core.request_options import RequestOptions -from .types.invoke_action_response import InvokeActionResponse -from ..core.serialization import convert_and_respect_annotation_metadata -from ..core.pydantic_utilities import parse_obj_as -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper - -# this is used as the default value for optional parameters -OMIT = typing.cast(typing.Any, ...) - - -class ActionsClient: - def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper - - def invoke_action( - self, - *, - action_id: uuid.UUID, - user_email: str, - require_human_confirmation: bool, - justification: str, - audit_log_id: uuid.UUID, - action_inputs: typing.Optional[typing.Any] = OMIT, - human_confirmation_channel: typing.Optional[HumanConfirmationChannel] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> InvokeActionResponse: - """ - Invoke an action, asking for human confirmation if necessary - - Parameters - ---------- - action_id : uuid.UUID - - user_email : str - The user who we should take the action on behalf of - - - 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 - The justification for requesting this action. This is likely generated by the LLM that requested the action. - - - audit_log_id : uuid.UUID - Audit log for the message that called for this action - - - action_inputs : typing.Optional[typing.Any] - The inputs needed to execute the action - - - human_confirmation_channel : typing.Optional[HumanConfirmationChannel] - Where we should ask for human confirmation if necessary - - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - InvokeActionResponse - - Examples - -------- - import uuid - - from credal import CredalApi - from credal.actions import HumanConfirmationChannel_SlackThread - - client = CredalApi( - api_key="YOUR_API_KEY", - ) - client.actions.invoke_action( - action_id=uuid.UUID( - "2b5cf2b8-3df3-11ef-9a96-332d4470d189", - ), - action_inputs={ - "textToAppend": "If you need more help, please contact your direct manager." - }, - user_email="ben@credal.ai", - require_human_confirmation=True, - human_confirmation_channel=HumanConfirmationChannel_SlackThread( - channel_id="ABC123", - thread_timestamp="123456789", - ), - justification="The user directly asked to update the Relocations Confluence document with this text.", - audit_log_id=uuid.UUID( - "3df3f2b8-3df3-11ef-9a96-332d447011ef", - ), - ) - """ - _response = self._client_wrapper.httpx_client.request( - "v0/actions/invokeAction", - method="POST", - json={ - "actionId": action_id, - "actionInputs": action_inputs, - "userEmail": user_email, - "requireHumanConfirmation": require_human_confirmation, - "humanConfirmationChannel": convert_and_respect_annotation_metadata( - object_=human_confirmation_channel, annotation=HumanConfirmationChannel, direction="write" - ), - "justification": justification, - "auditLogId": audit_log_id, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - InvokeActionResponse, - parse_obj_as( - type_=InvokeActionResponse, # type: ignore - object_=_response.json(), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - -class AsyncActionsClient: - def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - - async def invoke_action( - self, - *, - action_id: uuid.UUID, - user_email: str, - require_human_confirmation: bool, - justification: str, - audit_log_id: uuid.UUID, - action_inputs: typing.Optional[typing.Any] = OMIT, - human_confirmation_channel: typing.Optional[HumanConfirmationChannel] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> InvokeActionResponse: - """ - Invoke an action, asking for human confirmation if necessary - - Parameters - ---------- - action_id : uuid.UUID - - user_email : str - The user who we should take the action on behalf of - - - 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 - The justification for requesting this action. This is likely generated by the LLM that requested the action. - - - audit_log_id : uuid.UUID - Audit log for the message that called for this action - - - action_inputs : typing.Optional[typing.Any] - The inputs needed to execute the action - - - human_confirmation_channel : typing.Optional[HumanConfirmationChannel] - Where we should ask for human confirmation if necessary - - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - InvokeActionResponse - - Examples - -------- - import asyncio - import uuid - - from credal import AsyncCredalApi - from credal.actions import HumanConfirmationChannel_SlackThread - - client = AsyncCredalApi( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.actions.invoke_action( - action_id=uuid.UUID( - "2b5cf2b8-3df3-11ef-9a96-332d4470d189", - ), - action_inputs={ - "textToAppend": "If you need more help, please contact your direct manager." - }, - user_email="ben@credal.ai", - require_human_confirmation=True, - human_confirmation_channel=HumanConfirmationChannel_SlackThread( - channel_id="ABC123", - thread_timestamp="123456789", - ), - justification="The user directly asked to update the Relocations Confluence document with this text.", - audit_log_id=uuid.UUID( - "3df3f2b8-3df3-11ef-9a96-332d447011ef", - ), - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v0/actions/invokeAction", - method="POST", - json={ - "actionId": action_id, - "actionInputs": action_inputs, - "userEmail": user_email, - "requireHumanConfirmation": require_human_confirmation, - "humanConfirmationChannel": convert_and_respect_annotation_metadata( - object_=human_confirmation_channel, annotation=HumanConfirmationChannel, direction="write" - ), - "justification": justification, - "auditLogId": audit_log_id, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - InvokeActionResponse, - parse_obj_as( - type_=InvokeActionResponse, # type: ignore - object_=_response.json(), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/credal/actions/types/__init__.py b/src/credal/actions/types/__init__.py deleted file mode 100644 index 6a41f07..0000000 --- a/src/credal/actions/types/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from .action_status import ActionStatus -from .conversation import Conversation -from .direct_message import DirectMessage -from .human_confirmation_channel import ( - HumanConfirmationChannel, - HumanConfirmationChannel_Conversation, - HumanConfirmationChannel_DirectMessage, - HumanConfirmationChannel_SlackThread, -) -from .invoke_action_response import InvokeActionResponse -from .slack_thread import SlackThread - -__all__ = [ - "ActionStatus", - "Conversation", - "DirectMessage", - "HumanConfirmationChannel", - "HumanConfirmationChannel_Conversation", - "HumanConfirmationChannel_DirectMessage", - "HumanConfirmationChannel_SlackThread", - "InvokeActionResponse", - "SlackThread", -] diff --git a/src/credal/actions/types/action_status.py b/src/credal/actions/types/action_status.py deleted file mode 100644 index 1d99764..0000000 --- a/src/credal/actions/types/action_status.py +++ /dev/null @@ -1,16 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -ActionStatus = typing.Union[ - typing.Literal[ - "PENDING_APPROVAL", - "APPROVED_IN_PROGRESS", - "NO_APPROVAL_NEEDED_IN_PROGRESS", - "APPROVED_SUCCEEDED", - "APPROVED_FAILED", - "NO_APPROVAL_NEEDED_SUCCEEDED", - "NO_APPROVAL_NEEDED_FAILED", - ], - typing.Any, -] diff --git a/src/credal/actions/types/conversation.py b/src/credal/actions/types/conversation.py deleted file mode 100644 index 7c1b1ff..0000000 --- a/src/credal/actions/types/conversation.py +++ /dev/null @@ -1,22 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from ...core.pydantic_utilities import UniversalBaseModel -import typing_extensions -import uuid -from ...core.serialization import FieldMetadata -from ...core.pydantic_utilities import IS_PYDANTIC_V2 -import typing -import pydantic - - -class Conversation(UniversalBaseModel): - conversation_id: typing_extensions.Annotated[uuid.UUID, FieldMetadata(alias="conversationId")] - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/credal/actions/types/direct_message.py b/src/credal/actions/types/direct_message.py deleted file mode 100644 index f989f0e..0000000 --- a/src/credal/actions/types/direct_message.py +++ /dev/null @@ -1,21 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from ...core.pydantic_utilities import UniversalBaseModel -import typing_extensions -from ...core.serialization import FieldMetadata -from ...core.pydantic_utilities import IS_PYDANTIC_V2 -import typing -import pydantic - - -class DirectMessage(UniversalBaseModel): - channel_id: typing_extensions.Annotated[str, FieldMetadata(alias="channelId")] - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/credal/actions/types/human_confirmation_channel.py b/src/credal/actions/types/human_confirmation_channel.py deleted file mode 100644 index 5013ca3..0000000 --- a/src/credal/actions/types/human_confirmation_channel.py +++ /dev/null @@ -1,58 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from __future__ import annotations -from ...core.pydantic_utilities import UniversalBaseModel -import typing -import typing_extensions -from ...core.serialization import FieldMetadata -from ...core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic -import uuid - - -class HumanConfirmationChannel_DirectMessage(UniversalBaseModel): - type: typing.Literal["directMessage"] = "directMessage" - channel_id: typing_extensions.Annotated[str, FieldMetadata(alias="channelId")] - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow - - -class HumanConfirmationChannel_SlackThread(UniversalBaseModel): - type: typing.Literal["slackThread"] = "slackThread" - channel_id: typing_extensions.Annotated[str, FieldMetadata(alias="channelId")] - thread_timestamp: typing_extensions.Annotated[str, FieldMetadata(alias="threadTimestamp")] - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow - - -class HumanConfirmationChannel_Conversation(UniversalBaseModel): - type: typing.Literal["conversation"] = "conversation" - conversation_id: typing_extensions.Annotated[uuid.UUID, FieldMetadata(alias="conversationId")] - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow - - -HumanConfirmationChannel = typing.Union[ - HumanConfirmationChannel_DirectMessage, HumanConfirmationChannel_SlackThread, HumanConfirmationChannel_Conversation -] diff --git a/src/credal/actions/types/invoke_action_response.py b/src/credal/actions/types/invoke_action_response.py deleted file mode 100644 index 5a04d34..0000000 --- a/src/credal/actions/types/invoke_action_response.py +++ /dev/null @@ -1,24 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from ...core.pydantic_utilities import UniversalBaseModel -import typing_extensions -import uuid -from ...core.serialization import FieldMetadata -from .action_status import ActionStatus -from ...core.pydantic_utilities import IS_PYDANTIC_V2 -import typing -import pydantic - - -class InvokeActionResponse(UniversalBaseModel): - action_invocation_id: typing_extensions.Annotated[uuid.UUID, FieldMetadata(alias="actionInvocationId")] - action_invocation_status: typing_extensions.Annotated[ActionStatus, FieldMetadata(alias="actionInvocationStatus")] - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/credal/actions/types/slack_thread.py b/src/credal/actions/types/slack_thread.py deleted file mode 100644 index d4262d8..0000000 --- a/src/credal/actions/types/slack_thread.py +++ /dev/null @@ -1,22 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from ...core.pydantic_utilities import UniversalBaseModel -import typing_extensions -from ...core.serialization import FieldMetadata -from ...core.pydantic_utilities import IS_PYDANTIC_V2 -import typing -import pydantic - - -class SlackThread(UniversalBaseModel): - channel_id: typing_extensions.Annotated[str, FieldMetadata(alias="channelId")] - thread_timestamp: typing_extensions.Annotated[str, FieldMetadata(alias="threadTimestamp")] - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/credal/client.py b/src/credal/client.py index 0b31cd1..42bf4f3 100644 --- a/src/credal/client.py +++ b/src/credal/client.py @@ -6,7 +6,6 @@ import httpx from .core.api_error import ApiError from .core.client_wrapper import SyncClientWrapper -from .actions.client import ActionsClient from .copilots.client import CopilotsClient from .document_catalog.client import DocumentCatalogClient from .document_collections.client import DocumentCollectionsClient @@ -14,7 +13,6 @@ from .search.client import SearchClient from .users.client import UsersClient from .core.client_wrapper import AsyncClientWrapper -from .actions.client import AsyncActionsClient from .copilots.client import AsyncCopilotsClient from .document_catalog.client import AsyncDocumentCatalogClient from .document_collections.client import AsyncDocumentCollectionsClient @@ -85,7 +83,6 @@ def __init__( else httpx.Client(timeout=_defaulted_timeout), timeout=_defaulted_timeout, ) - self.actions = ActionsClient(client_wrapper=self._client_wrapper) self.copilots = CopilotsClient(client_wrapper=self._client_wrapper) self.document_catalog = DocumentCatalogClient(client_wrapper=self._client_wrapper) self.document_collections = DocumentCollectionsClient(client_wrapper=self._client_wrapper) @@ -156,7 +153,6 @@ def __init__( else httpx.AsyncClient(timeout=_defaulted_timeout), timeout=_defaulted_timeout, ) - self.actions = AsyncActionsClient(client_wrapper=self._client_wrapper) self.copilots = AsyncCopilotsClient(client_wrapper=self._client_wrapper) self.document_catalog = AsyncDocumentCatalogClient(client_wrapper=self._client_wrapper) self.document_collections = AsyncDocumentCollectionsClient(client_wrapper=self._client_wrapper) diff --git a/src/credal/core/client_wrapper.py b/src/credal/core/client_wrapper.py index 6b0da2c..2b4bd91 100644 --- a/src/credal/core/client_wrapper.py +++ b/src/credal/core/client_wrapper.py @@ -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.23", + "X-Fern-SDK-Version": "0.0.24", } headers["Authorization"] = f"Bearer {self._get_api_key()}" return headers