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
6 changes: 3 additions & 3 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"cliVersion": "5.79.0",
"cliVersion": "5.80.2",
"generatorName": "fernapi/fern-python-sdk",
"generatorVersion": "5.21.0",
"generatorVersion": "5.22.1",
"generatorConfig": {
"package_name": "truefoundry_gateway_sdk",
"use_request_defaults": "all",
Expand All @@ -22,7 +22,7 @@
"numpydoc": ">=1.7.0,<2.0.0"
}
},
"originGitCommit": "04ccea4a38938574a81790d93103a82db37968f9",
"originGitCommit": "8632e29353b0fea99dd9c6c309e38edd73fab4e1",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "0.0.0",
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Repository = 'https://github.com/truefoundry/truefoundry-gateway-python-sdk'
python = ">=3.10"
aiohttp = { version = ">=3.14.1,<4", optional = true, python = ">=3.10"}
httpx = ">=0.21.2"
httpx-aiohttp = { version = "0.1.8", optional = true, python = ">=3.10"}
httpx-aiohttp = { version = "^0.1.8", optional = true, python = ">=3.10"}
pydantic = ">= 1.9.2"
pydantic-core = ">=2.18.2,<3.0.0"
typing_extensions = ">= 4.0.0"
Expand Down
11 changes: 7 additions & 4 deletions src/truefoundry_gateway_sdk/agents/agent_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

from .session_mixin import AsyncSessionMixin, SessionMixin

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)

if typing.TYPE_CHECKING:
from ..client import AsyncTrueFoundryGateway, TrueFoundryGateway
from ..core.pagination import AsyncPager, SyncPager
Expand Down Expand Up @@ -110,8 +113,8 @@ def updated_at(self) -> str:
def prepare_turn(
self,
*,
input: typing.Optional[typing.Sequence[TurnInputItem]] = None,
previous_turn_id: typing.Optional[PreviousTurnIdInput] = None,
input: typing.Optional[typing.Sequence[TurnInputItem]] = OMIT,
previous_turn_id: typing.Optional[PreviousTurnIdInput] = OMIT,
) -> PreparedTurn:
"""
Stage a turn locally; call ``execute()`` to start ``create_turn``.
Expand Down Expand Up @@ -319,8 +322,8 @@ def updated_at(self) -> str:
def prepare_turn(
self,
*,
input: typing.Optional[typing.Sequence[TurnInputItem]] = None,
previous_turn_id: typing.Optional[PreviousTurnIdInput] = None,
input: typing.Optional[typing.Sequence[TurnInputItem]] = OMIT,
previous_turn_id: typing.Optional[PreviousTurnIdInput] = OMIT,
) -> AsyncPreparedTurn:
"""
Stage a turn locally; call ``execute()`` to start ``create_turn``.
Expand Down
27 changes: 19 additions & 8 deletions src/truefoundry_gateway_sdk/agents/prepared_turn.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from .turn import AsyncTurn, Turn
from .turn_stream_data import TurnStreamData

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)

if typing.TYPE_CHECKING:
from ..client import AsyncTrueFoundryGateway, TrueFoundryGateway
from ..core.pagination import AsyncPager, SyncPager
Expand Down Expand Up @@ -37,7 +40,10 @@ def __init__(
session: typing.Union["AgentSession", "AgentDraftSession"],
client: TrueFoundryGateway,
) -> None:
self._input = list(input) if input is not None else None
# Keep the raw value (which may be the OMIT sentinel) to forward to create_turn
# unchanged; self._input is the list-or-None form used for local state/exposure.
self._input_param = input
self._input = list(input) if input is not None and input is not OMIT else None
self._previous_turn_id = previous_turn_id
self._session: typing.Union["AgentSession", "AgentDraftSession"] = session
self._session_id: str = session.id
Expand Down Expand Up @@ -193,7 +199,7 @@ def execute(
def stream(
self,
*,
after_sequence_number: typing.Optional[int] = None,
after_sequence_number: typing.Optional[int] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> typing.Iterator[TurnStreamData]:
"""
Expand All @@ -202,7 +208,8 @@ def stream(
Parameters
----------
after_sequence_number : typing.Optional[int]
Sequence number to resume SSE subscription after.
Sequence number to resume SSE subscription after. Omit to resume via the
Last-Event-Id header instead.
request_options : typing.Optional[RequestOptions]
Overrides client timeout, retries, headers, and stream reconnect.

Expand Down Expand Up @@ -320,7 +327,7 @@ def _consume_stream(self, request_options: typing.Optional[RequestOptions]) -> t
"""Consume the create_turn SSE, adopting the inner Turn from the first turn.created."""
for event in self._client.agents.sessions.create_turn(
self._session_id,
input=self._input,
input=self._input_param,
previous_turn_id=self._previous_turn_id,
request_options=request_options,
):
Expand Down Expand Up @@ -389,7 +396,10 @@ def __init__(
session: typing.Union["AsyncAgentSession", "AsyncAgentDraftSession"],
client: AsyncTrueFoundryGateway,
) -> None:
self._input = list(input) if input is not None else None
# Keep the raw value (which may be the OMIT sentinel) to forward to create_turn
# unchanged; self._input is the list-or-None form used for local state/exposure.
self._input_param = input
self._input = list(input) if input is not None and input is not OMIT else None
self._previous_turn_id = previous_turn_id
self._session: typing.Union["AsyncAgentSession", "AsyncAgentDraftSession"] = session
self._session_id: str = session.id
Expand Down Expand Up @@ -545,7 +555,7 @@ def execute(
async def stream(
self,
*,
after_sequence_number: typing.Optional[int] = None,
after_sequence_number: typing.Optional[int] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> typing.AsyncIterator[TurnStreamData]:
"""
Expand All @@ -554,7 +564,8 @@ async def stream(
Parameters
----------
after_sequence_number : typing.Optional[int]
Sequence number to resume SSE subscription after.
Sequence number to resume SSE subscription after. Omit to resume via the
Last-Event-Id header instead.
request_options : typing.Optional[RequestOptions]
Overrides client timeout, retries, headers, and stream reconnect.

Expand Down Expand Up @@ -677,7 +688,7 @@ async def _consume_stream(
) -> typing.AsyncIterator[TurnStreamData]:
async for event in self._client.agents.sessions.create_turn(
self._session_id,
input=self._input,
input=self._input_param,
previous_turn_id=self._previous_turn_id,
request_options=request_options,
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import typing

from ...private.agents.private.draft_sessions.client import OMIT
from ..session_mixin import AsyncSessionMixin, SessionMixin

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)

if typing.TYPE_CHECKING:
from ...client import AsyncTrueFoundryGateway, TrueFoundryGateway
from ...core.pagination import AsyncPager, SyncPager
Expand Down Expand Up @@ -153,8 +155,8 @@ def update(
def prepare_turn(
self,
*,
input: typing.Optional[typing.Sequence[TurnInputItem]] = None,
previous_turn_id: typing.Optional[PreviousTurnIdInput] = None,
input: typing.Optional[typing.Sequence[TurnInputItem]] = OMIT,
previous_turn_id: typing.Optional[PreviousTurnIdInput] = OMIT,
) -> PreparedTurn:
"""
Stage a turn locally; call ``execute()`` to start ``create_turn``.
Expand Down Expand Up @@ -402,8 +404,8 @@ async def update(
def prepare_turn(
self,
*,
input: typing.Optional[typing.Sequence[TurnInputItem]] = None,
previous_turn_id: typing.Optional[PreviousTurnIdInput] = None,
input: typing.Optional[typing.Sequence[TurnInputItem]] = OMIT,
previous_turn_id: typing.Optional[PreviousTurnIdInput] = OMIT,
) -> AsyncPreparedTurn:
"""
Stage a turn locally; call ``execute()`` to start ``create_turn``.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import typing

from ...core.pagination import AsyncPager, SyncPager
from ...private.agents.private.draft_sessions.client import OMIT
from ..agent_session import AgentSession, AsyncAgentSession
from .agent_draft_session import AgentDraftSession, AsyncAgentDraftSession

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)

if typing.TYPE_CHECKING:
import httpx
from ...client import AsyncTrueFoundryGateway, TrueFoundryGateway
Expand Down
11 changes: 7 additions & 4 deletions src/truefoundry_gateway_sdk/agents/session_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from .prepared_turn import AsyncPreparedTurn, PreparedTurn
from .turn import AsyncTurn, Turn

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)

if typing.TYPE_CHECKING:
from ..client import AsyncTrueFoundryGateway, TrueFoundryGateway
from ..core.request_options import RequestOptions
Expand Down Expand Up @@ -89,8 +92,8 @@ def prepare_turn(
self,
owner: SyncSessionOwner,
*,
input: typing.Optional[typing.Sequence[TurnInputItem]] = None,
previous_turn_id: typing.Optional[PreviousTurnIdInput] = None,
input: typing.Optional[typing.Sequence[TurnInputItem]] = OMIT,
previous_turn_id: typing.Optional[PreviousTurnIdInput] = OMIT,
) -> PreparedTurn:
"""
Stage a turn locally; call ``execute()`` to start ``create_turn``.
Expand Down Expand Up @@ -241,8 +244,8 @@ def prepare_turn(
self,
owner: AsyncSessionOwner,
*,
input: typing.Optional[typing.Sequence[TurnInputItem]] = None,
previous_turn_id: typing.Optional[PreviousTurnIdInput] = None,
input: typing.Optional[typing.Sequence[TurnInputItem]] = OMIT,
previous_turn_id: typing.Optional[PreviousTurnIdInput] = OMIT,
) -> AsyncPreparedTurn:
"""
Stage a turn locally; call ``execute()`` to start ``create_turn``.
Expand Down
13 changes: 9 additions & 4 deletions src/truefoundry_gateway_sdk/agents/turn.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from ..types.turn_state_error import TurnStateError
from .turn_stream_data import TurnStreamData

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)

if typing.TYPE_CHECKING:
from ..client import AsyncTrueFoundryGateway, TrueFoundryGateway
from ..core.pagination import AsyncPager, SyncPager
Expand Down Expand Up @@ -194,7 +197,7 @@ def wait_for_completion(
def stream(
self,
*,
after_sequence_number: typing.Optional[int] = None,
after_sequence_number: typing.Optional[int] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> typing.Iterator[TurnStreamData]:
"""
Expand All @@ -203,7 +206,8 @@ def stream(
Parameters
----------
after_sequence_number : typing.Optional[int]
Sequence number to resume SSE subscription after.
Sequence number to resume SSE subscription after. Omit to resume via the
Last-Event-Id header instead.
request_options : typing.Optional[RequestOptions]
Overrides client timeout, retries, headers, and stream reconnect.

Expand Down Expand Up @@ -440,7 +444,7 @@ async def wait_for_completion(
async def stream(
self,
*,
after_sequence_number: typing.Optional[int] = None,
after_sequence_number: typing.Optional[int] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> typing.AsyncIterator[TurnStreamData]:
"""
Expand All @@ -449,7 +453,8 @@ async def stream(
Parameters
----------
after_sequence_number : typing.Optional[int]
Sequence number to resume SSE subscription after.
Sequence number to resume SSE subscription after. Omit to resume via the
Last-Event-Id header instead.
request_options : typing.Optional[RequestOptions]
Overrides client timeout, retries, headers, and stream reconnect.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def create_turn(
object_=input, annotation=typing.Sequence[TurnInputItem], direction="write"
),
"previous_turn_id": convert_and_respect_annotation_metadata(
object_=previous_turn_id, annotation=typing.Optional[PreviousTurnIdInput], direction="write"
object_=previous_turn_id, annotation=PreviousTurnIdInput, direction="write"
),
},
headers={
Expand Down Expand Up @@ -1699,7 +1699,7 @@ async def create_turn(
object_=input, annotation=typing.Sequence[TurnInputItem], direction="write"
),
"previous_turn_id": convert_and_respect_annotation_metadata(
object_=previous_turn_id, annotation=typing.Optional[PreviousTurnIdInput], direction="write"
object_=previous_turn_id, annotation=PreviousTurnIdInput, direction="write"
),
},
headers={
Expand Down
4 changes: 0 additions & 4 deletions src/truefoundry_gateway_sdk/types/created_by_subject_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class CreatedBySubjectType(enum.StrEnum):
TEAM = "team"
SERVICEACCOUNT = "serviceaccount"
VIRTUALACCOUNT = "virtualaccount"
EXTERNAL_IDENTITY = "external-identity"
AGENT_IDENTITY = "agent-identity"
ROLE = "role"
_UNKNOWN = "__CREATEDBYSUBJECTTYPE_UNKNOWN__"
Expand All @@ -36,7 +35,6 @@ def visit(
team: typing.Callable[[], T_Result],
serviceaccount: typing.Callable[[], T_Result],
virtualaccount: typing.Callable[[], T_Result],
external_identity: typing.Callable[[], T_Result],
agent_identity: typing.Callable[[], T_Result],
role: typing.Callable[[], T_Result],
_unknown_member: typing.Callable[[str], T_Result],
Expand All @@ -49,8 +47,6 @@ def visit(
return serviceaccount()
if self is CreatedBySubjectType.VIRTUALACCOUNT:
return virtualaccount()
if self is CreatedBySubjectType.EXTERNAL_IDENTITY:
return external_identity()
if self is CreatedBySubjectType.AGENT_IDENTITY:
return agent_identity()
if self is CreatedBySubjectType.ROLE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

import typing

PreviousTurnIdInput = typing.Union[typing.Literal["auto"], str]
PreviousTurnIdInput = typing.Union[typing.Literal["auto"], typing.Literal["none"], str]
Loading