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 api.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Methods:

- <code title="post /agents">client.agents.<a href="./src/contextual/resources/agents/agents.py">create</a>(\*\*<a href="src/contextual/types/agent_create_params.py">params</a>) -> <a href="./src/contextual/types/create_agent_output.py">CreateAgentOutput</a></code>
- <code title="put /agents/{agent_id}">client.agents.<a href="./src/contextual/resources/agents/agents.py">update</a>(agent_id, \*\*<a href="src/contextual/types/agent_update_params.py">params</a>) -> <a href="./src/contextual/types/agent_update_response.py">object</a></code>
- <code title="get /agents">client.agents.<a href="./src/contextual/resources/agents/agents.py">list</a>(\*\*<a href="src/contextual/types/agent_list_params.py">params</a>) -> <a href="./src/contextual/types/agent.py">SyncAgentsPage[Agent]</a></code>
- <code title="get /agents">client.agents.<a href="./src/contextual/resources/agents/agents.py">list</a>(\*\*<a href="src/contextual/types/agent_list_params.py">params</a>) -> <a href="./src/contextual/types/agent.py">SyncPage[Agent]</a></code>
- <code title="delete /agents/{agent_id}">client.agents.<a href="./src/contextual/resources/agents/agents.py">delete</a>(agent_id) -> <a href="./src/contextual/types/agent_delete_response.py">object</a></code>
- <code title="get /agents/{agent_id}/metadata">client.agents.<a href="./src/contextual/resources/agents/agents.py">metadata</a>(agent_id) -> <a href="./src/contextual/types/agent_metadata.py">AgentMetadata</a></code>

Expand Down
8 changes: 4 additions & 4 deletions src/contextual/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"AsyncDatastoresPage",
"SyncDocumentsPage",
"AsyncDocumentsPage",
"SyncAgentsPage",
"AsyncAgentsPage",
"SyncPage",
"AsyncPage",
]

_T = TypeVar("_T")
Expand Down Expand Up @@ -97,7 +97,7 @@ def next_page_info(self) -> Optional[PageInfo]:
return PageInfo(params={"cursor": next_cursor})


class SyncAgentsPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
class SyncPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
agents: List[_T]
next_cursor: Optional[str] = None

Expand All @@ -117,7 +117,7 @@ def next_page_info(self) -> Optional[PageInfo]:
return PageInfo(params={"cursor": next_cursor})


class AsyncAgentsPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
class AsyncPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
agents: List[_T]
next_cursor: Optional[str] = None

Expand Down
10 changes: 5 additions & 5 deletions src/contextual/resources/agents/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
from ...pagination import SyncAgentsPage, AsyncAgentsPage
from ...pagination import SyncPage, AsyncPage
from ...types.agent import Agent
from ..._base_client import AsyncPaginator, make_request_options
from .datasets.datasets import (
Expand Down Expand Up @@ -242,7 +242,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SyncAgentsPage[Agent]:
) -> SyncPage[Agent]:
"""
Retrieve a list of all `Agents`.

Expand All @@ -262,7 +262,7 @@ def list(
"""
return self._get_api_list(
"/agents",
page=SyncAgentsPage[Agent],
page=SyncPage[Agent],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down Expand Up @@ -536,7 +536,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsyncPaginator[Agent, AsyncAgentsPage[Agent]]:
) -> AsyncPaginator[Agent, AsyncPage[Agent]]:
"""
Retrieve a list of all `Agents`.

Expand All @@ -556,7 +556,7 @@ def list(
"""
return self._get_api_list(
"/agents",
page=AsyncAgentsPage[Agent],
page=AsyncPage[Agent],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down
18 changes: 9 additions & 9 deletions tests/api_resources/test_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
AgentMetadata,
CreateAgentOutput,
)
from contextual.pagination import SyncAgentsPage, AsyncAgentsPage
from contextual.pagination import SyncPage, AsyncPage

base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")

Expand Down Expand Up @@ -116,15 +116,15 @@ def test_path_params_update(self, client: ContextualAI) -> None:
@parametrize
def test_method_list(self, client: ContextualAI) -> None:
agent = client.agents.list()
assert_matches_type(SyncAgentsPage[Agent], agent, path=["response"])
assert_matches_type(SyncPage[Agent], agent, path=["response"])

@parametrize
def test_method_list_with_all_params(self, client: ContextualAI) -> None:
agent = client.agents.list(
cursor="cursor",
limit=1,
)
assert_matches_type(SyncAgentsPage[Agent], agent, path=["response"])
assert_matches_type(SyncPage[Agent], agent, path=["response"])

@parametrize
def test_raw_response_list(self, client: ContextualAI) -> None:
Expand All @@ -133,7 +133,7 @@ def test_raw_response_list(self, client: ContextualAI) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
agent = response.parse()
assert_matches_type(SyncAgentsPage[Agent], agent, path=["response"])
assert_matches_type(SyncPage[Agent], agent, path=["response"])

@parametrize
def test_streaming_response_list(self, client: ContextualAI) -> None:
Expand All @@ -142,7 +142,7 @@ def test_streaming_response_list(self, client: ContextualAI) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

agent = response.parse()
assert_matches_type(SyncAgentsPage[Agent], agent, path=["response"])
assert_matches_type(SyncPage[Agent], agent, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down Expand Up @@ -320,15 +320,15 @@ async def test_path_params_update(self, async_client: AsyncContextualAI) -> None
@parametrize
async def test_method_list(self, async_client: AsyncContextualAI) -> None:
agent = await async_client.agents.list()
assert_matches_type(AsyncAgentsPage[Agent], agent, path=["response"])
assert_matches_type(AsyncPage[Agent], agent, path=["response"])

@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncContextualAI) -> None:
agent = await async_client.agents.list(
cursor="cursor",
limit=1,
)
assert_matches_type(AsyncAgentsPage[Agent], agent, path=["response"])
assert_matches_type(AsyncPage[Agent], agent, path=["response"])

@parametrize
async def test_raw_response_list(self, async_client: AsyncContextualAI) -> None:
Expand All @@ -337,7 +337,7 @@ async def test_raw_response_list(self, async_client: AsyncContextualAI) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
agent = await response.parse()
assert_matches_type(AsyncAgentsPage[Agent], agent, path=["response"])
assert_matches_type(AsyncPage[Agent], agent, path=["response"])

@parametrize
async def test_streaming_response_list(self, async_client: AsyncContextualAI) -> None:
Expand All @@ -346,7 +346,7 @@ async def test_streaming_response_list(self, async_client: AsyncContextualAI) ->
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

agent = await response.parse()
assert_matches_type(AsyncAgentsPage[Agent], agent, path=["response"])
assert_matches_type(AsyncPage[Agent], agent, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down