From 77ec3ed1242142d084cd029a2c1848ae84d58460 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 20:17:02 +0000 Subject: [PATCH] Release v0.2.8 --- pyproject.toml | 2 +- src/superagent/__init__.py | 5 +- src/superagent/client.py | 3 - src/superagent/core/client_wrapper.py | 2 +- src/superagent/resources/__init__.py | 14 +- src/superagent/resources/agent/client.py | 10 ++ .../resources/telemetry/__init__.py | 2 - src/superagent/resources/telemetry/client.py | 123 ------------------ src/superagent/types/__init__.py | 2 - src/superagent/types/agent_run_list.py | 29 ----- src/superagent/types/agent_type.py | 8 +- src/superagent/types/llm_provider.py | 8 ++ src/superagent/types/tool_type.py | 4 + 13 files changed, 34 insertions(+), 178 deletions(-) delete mode 100644 src/superagent/resources/telemetry/__init__.py delete mode 100644 src/superagent/resources/telemetry/client.py delete mode 100644 src/superagent/types/agent_run_list.py diff --git a/pyproject.toml b/pyproject.toml index d1ed923..03c06f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "superagent-py" -version = "v0.2.7" +version = "v0.2.8" description = "" readme = "README.md" authors = [] diff --git a/src/superagent/__init__.py b/src/superagent/__init__.py index 1a69782..55ab28b 100644 --- a/src/superagent/__init__.py +++ b/src/superagent/__init__.py @@ -3,7 +3,6 @@ from .types import ( AgentDatasosurceList, AgentList, - AgentRunList, AgentToolList, AgentType, AppModelsRequestApiUser, @@ -60,13 +59,12 @@ WorkflowStepList, ) from .errors import UnprocessableEntityError -from .resources import agent, api_user, datasource, llm, telemetry, tool, vector_database, workflow, workflow_config +from .resources import agent, api_user, datasource, llm, tool, vector_database, workflow, workflow_config from .environment import SuperagentEnvironment __all__ = [ "AgentDatasosurceList", "AgentList", - "AgentRunList", "AgentToolList", "AgentType", "AppModelsRequestApiUser", @@ -127,7 +125,6 @@ "api_user", "datasource", "llm", - "telemetry", "tool", "vector_database", "workflow", diff --git a/src/superagent/client.py b/src/superagent/client.py index 73ef399..9073faf 100644 --- a/src/superagent/client.py +++ b/src/superagent/client.py @@ -10,7 +10,6 @@ from .resources.api_user.client import ApiUserClient, AsyncApiUserClient from .resources.datasource.client import AsyncDatasourceClient, DatasourceClient from .resources.llm.client import AsyncLlmClient, LlmClient -from .resources.telemetry.client import AsyncTelemetryClient, TelemetryClient from .resources.tool.client import AsyncToolClient, ToolClient from .resources.vector_database.client import AsyncVectorDatabaseClient, VectorDatabaseClient from .resources.workflow.client import AsyncWorkflowClient, WorkflowClient @@ -40,7 +39,6 @@ def __init__( self.workflow = WorkflowClient(client_wrapper=self._client_wrapper) self.workflow_config = WorkflowConfigClient(client_wrapper=self._client_wrapper) self.vector_database = VectorDatabaseClient(client_wrapper=self._client_wrapper) - self.telemetry = TelemetryClient(client_wrapper=self._client_wrapper) class AsyncSuperagent: @@ -66,7 +64,6 @@ def __init__( self.workflow = AsyncWorkflowClient(client_wrapper=self._client_wrapper) self.workflow_config = AsyncWorkflowConfigClient(client_wrapper=self._client_wrapper) self.vector_database = AsyncVectorDatabaseClient(client_wrapper=self._client_wrapper) - self.telemetry = AsyncTelemetryClient(client_wrapper=self._client_wrapper) def _get_base_url(*, base_url: typing.Optional[str] = None, environment: SuperagentEnvironment) -> str: diff --git a/src/superagent/core/client_wrapper.py b/src/superagent/core/client_wrapper.py index 8d3ea03..e79bfb7 100644 --- a/src/superagent/core/client_wrapper.py +++ b/src/superagent/core/client_wrapper.py @@ -14,7 +14,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "superagent-py", - "X-Fern-SDK-Version": "v0.2.7", + "X-Fern-SDK-Version": "v0.2.8", } token = self._get_token() if token is not None: diff --git a/src/superagent/resources/__init__.py b/src/superagent/resources/__init__.py index 727b7e6..5adce89 100644 --- a/src/superagent/resources/__init__.py +++ b/src/superagent/resources/__init__.py @@ -1,15 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -from . import agent, api_user, datasource, llm, telemetry, tool, vector_database, workflow, workflow_config +from . import agent, api_user, datasource, llm, tool, vector_database, workflow, workflow_config -__all__ = [ - "agent", - "api_user", - "datasource", - "llm", - "telemetry", - "tool", - "vector_database", - "workflow", - "workflow_config", -] +__all__ = ["agent", "api_user", "datasource", "llm", "tool", "vector_database", "workflow", "workflow_config"] diff --git a/src/superagent/resources/agent/client.py b/src/superagent/resources/agent/client.py index 8c95bd4..8838ec6 100644 --- a/src/superagent/resources/agent/client.py +++ b/src/superagent/resources/agent/client.py @@ -72,6 +72,7 @@ def create( avatar: typing.Optional[str] = OMIT, type: typing.Optional[AgentType] = OMIT, parameters: typing.Optional[OpenAiAssistantParameters] = OMIT, + metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, ) -> AppModelsResponseAgent: """ Create a new agent @@ -96,6 +97,8 @@ def create( - type: typing.Optional[AgentType]. - parameters: typing.Optional[OpenAiAssistantParameters]. + + - metadata: typing.Optional[typing.Dict[str, typing.Any]]. """ _request: typing.Dict[str, typing.Any] = {"name": name} if is_active is not OMIT: @@ -116,6 +119,8 @@ def create( _request["type"] = type.value if parameters is not OMIT: _request["parameters"] = parameters + if metadata is not OMIT: + _request["metadata"] = metadata _response = self._client_wrapper.httpx_client.request( "POST", urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/agents"), @@ -550,6 +555,7 @@ async def create( avatar: typing.Optional[str] = OMIT, type: typing.Optional[AgentType] = OMIT, parameters: typing.Optional[OpenAiAssistantParameters] = OMIT, + metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, ) -> AppModelsResponseAgent: """ Create a new agent @@ -574,6 +580,8 @@ async def create( - type: typing.Optional[AgentType]. - parameters: typing.Optional[OpenAiAssistantParameters]. + + - metadata: typing.Optional[typing.Dict[str, typing.Any]]. """ _request: typing.Dict[str, typing.Any] = {"name": name} if is_active is not OMIT: @@ -594,6 +602,8 @@ async def create( _request["type"] = type.value if parameters is not OMIT: _request["parameters"] = parameters + if metadata is not OMIT: + _request["metadata"] = metadata _response = await self._client_wrapper.httpx_client.request( "POST", urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/agents"), diff --git a/src/superagent/resources/telemetry/__init__.py b/src/superagent/resources/telemetry/__init__.py deleted file mode 100644 index f3ea265..0000000 --- a/src/superagent/resources/telemetry/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - diff --git a/src/superagent/resources/telemetry/client.py b/src/superagent/resources/telemetry/client.py deleted file mode 100644 index 1934f14..0000000 --- a/src/superagent/resources/telemetry/client.py +++ /dev/null @@ -1,123 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing -import urllib.parse -from json.decoder import JSONDecodeError - -from ...core.api_error import ApiError -from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ...core.remove_none_from_dict import remove_none_from_dict -from ...errors.unprocessable_entity_error import UnprocessableEntityError -from ...types.agent_run_list import AgentRunList -from ...types.http_validation_error import HttpValidationError - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class TelemetryClient: - def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper - - def list_runs( - self, - *, - agent_id: typing.Optional[str] = None, - from_page: typing.Optional[int] = None, - to_page: typing.Optional[int] = None, - limit: typing.Optional[int] = None, - workflow_id: typing.Optional[str] = None, - ) -> AgentRunList: - """ - List runs - - Parameters: - - agent_id: typing.Optional[str]. - - - from_page: typing.Optional[int]. - - - to_page: typing.Optional[int]. - - - limit: typing.Optional[int]. - - - workflow_id: typing.Optional[str]. - """ - _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/runs"), - params=remove_none_from_dict( - { - "agent_id": agent_id, - "from_page": from_page, - "to_page": to_page, - "limit": limit, - "workflow_id": workflow_id, - } - ), - headers=self._client_wrapper.get_headers(), - timeout=60, - ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(AgentRunList, _response.json()) # type: ignore - if _response.status_code == 422: - raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore - try: - _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 AsyncTelemetryClient: - def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - - async def list_runs( - self, - *, - agent_id: typing.Optional[str] = None, - from_page: typing.Optional[int] = None, - to_page: typing.Optional[int] = None, - limit: typing.Optional[int] = None, - workflow_id: typing.Optional[str] = None, - ) -> AgentRunList: - """ - List runs - - Parameters: - - agent_id: typing.Optional[str]. - - - from_page: typing.Optional[int]. - - - to_page: typing.Optional[int]. - - - limit: typing.Optional[int]. - - - workflow_id: typing.Optional[str]. - """ - _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/runs"), - params=remove_none_from_dict( - { - "agent_id": agent_id, - "from_page": from_page, - "to_page": to_page, - "limit": limit, - "workflow_id": workflow_id, - } - ), - headers=self._client_wrapper.get_headers(), - timeout=60, - ) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(AgentRunList, _response.json()) # type: ignore - if _response.status_code == 422: - raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore - try: - _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/superagent/types/__init__.py b/src/superagent/types/__init__.py index c9b0ef1..4e73284 100644 --- a/src/superagent/types/__init__.py +++ b/src/superagent/types/__init__.py @@ -2,7 +2,6 @@ from .agent_datasosurce_list import AgentDatasosurceList from .agent_list import AgentList -from .agent_run_list import AgentRunList from .agent_tool_list import AgentToolList from .agent_type import AgentType from .app_models_request_api_user import AppModelsRequestApiUser @@ -63,7 +62,6 @@ __all__ = [ "AgentDatasosurceList", "AgentList", - "AgentRunList", "AgentToolList", "AgentType", "AppModelsRequestApiUser", diff --git a/src/superagent/types/agent_run_list.py b/src/superagent/types/agent_run_list.py deleted file mode 100644 index df77c35..0000000 --- a/src/superagent/types/agent_run_list.py +++ /dev/null @@ -1,29 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ..core.datetime_utils import serialize_datetime - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class AgentRunList(pydantic.BaseModel): - success: bool - data: typing.Optional[typing.List[typing.Dict[str, typing.Any]]] - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/superagent/types/agent_type.py b/src/superagent/types/agent_type.py index 2e22a29..74249fc 100644 --- a/src/superagent/types/agent_type.py +++ b/src/superagent/types/agent_type.py @@ -13,11 +13,17 @@ class AgentType(str, enum.Enum): SUPERAGENT = "SUPERAGENT" OPENAI_ASSISTANT = "OPENAI_ASSISTANT" + LLM = "LLM" def visit( - self, superagent: typing.Callable[[], T_Result], openai_assistant: typing.Callable[[], T_Result] + self, + superagent: typing.Callable[[], T_Result], + openai_assistant: typing.Callable[[], T_Result], + llm: typing.Callable[[], T_Result], ) -> T_Result: if self is AgentType.SUPERAGENT: return superagent() if self is AgentType.OPENAI_ASSISTANT: return openai_assistant() + if self is AgentType.LLM: + return llm() diff --git a/src/superagent/types/llm_provider.py b/src/superagent/types/llm_provider.py index b1e7c6c..74d839a 100644 --- a/src/superagent/types/llm_provider.py +++ b/src/superagent/types/llm_provider.py @@ -14,12 +14,16 @@ class LlmProvider(str, enum.Enum): OPENAI = "OPENAI" AZURE_OPENAI = "AZURE_OPENAI" HUGGINGFACE = "HUGGINGFACE" + PERPLEXITY = "PERPLEXITY" + TOGETHER_AI = "TOGETHER_AI" def visit( self, openai: typing.Callable[[], T_Result], azure_openai: typing.Callable[[], T_Result], huggingface: typing.Callable[[], T_Result], + perplexity: typing.Callable[[], T_Result], + together_ai: typing.Callable[[], T_Result], ) -> T_Result: if self is LlmProvider.OPENAI: return openai() @@ -27,3 +31,7 @@ def visit( return azure_openai() if self is LlmProvider.HUGGINGFACE: return huggingface() + if self is LlmProvider.PERPLEXITY: + return perplexity() + if self is LlmProvider.TOGETHER_AI: + return together_ai() diff --git a/src/superagent/types/tool_type.py b/src/superagent/types/tool_type.py index 80acb78..9795bc0 100644 --- a/src/superagent/types/tool_type.py +++ b/src/superagent/types/tool_type.py @@ -29,6 +29,7 @@ class ToolType(str, enum.Enum): HAND_OFF = "HAND_OFF" FUNCTION = "FUNCTION" HTTP = "HTTP" + SUPERRAG = "SUPERRAG" def visit( self, @@ -50,6 +51,7 @@ def visit( hand_off: typing.Callable[[], T_Result], function: typing.Callable[[], T_Result], http: typing.Callable[[], T_Result], + superrag: typing.Callable[[], T_Result], ) -> T_Result: if self is ToolType.ALGOLIA: return algolia() @@ -87,3 +89,5 @@ def visit( return function() if self is ToolType.HTTP: return http() + if self is ToolType.SUPERRAG: + return superrag()