mirror of
https://github.com/anomalyco/opencode-sdk-python.git
synced 2026-04-28 12:39:54 +00:00
906 lines
32 KiB
Python
906 lines
32 KiB
Python
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Iterable
|
|
|
|
import httpx
|
|
|
|
from ..types import session_chat_params, session_init_params, session_summarize_params
|
|
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
|
from .._utils import maybe_transform, async_maybe_transform
|
|
from .._compat import cached_property
|
|
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
from .._response import (
|
|
to_raw_response_wrapper,
|
|
to_streamed_response_wrapper,
|
|
async_to_raw_response_wrapper,
|
|
async_to_streamed_response_wrapper,
|
|
)
|
|
from .._base_client import make_request_options
|
|
from ..types.session import Session
|
|
from ..types.assistant_message import AssistantMessage
|
|
from ..types.session_init_response import SessionInitResponse
|
|
from ..types.session_list_response import SessionListResponse
|
|
from ..types.session_abort_response import SessionAbortResponse
|
|
from ..types.session_delete_response import SessionDeleteResponse
|
|
from ..types.session_messages_response import SessionMessagesResponse
|
|
from ..types.session_summarize_response import SessionSummarizeResponse
|
|
|
|
__all__ = ["SessionResource", "AsyncSessionResource"]
|
|
|
|
|
|
class SessionResource(SyncAPIResource):
|
|
@cached_property
|
|
def with_raw_response(self) -> SessionResourceWithRawResponse:
|
|
"""
|
|
This property can be used as a prefix for any HTTP method call to return
|
|
the raw response object instead of the parsed content.
|
|
|
|
For more information, see https://www.github.com/sst/opencode-sdk-python#accessing-raw-response-data-eg-headers
|
|
"""
|
|
return SessionResourceWithRawResponse(self)
|
|
|
|
@cached_property
|
|
def with_streaming_response(self) -> SessionResourceWithStreamingResponse:
|
|
"""
|
|
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
|
|
For more information, see https://www.github.com/sst/opencode-sdk-python#with_streaming_response
|
|
"""
|
|
return SessionResourceWithStreamingResponse(self)
|
|
|
|
def create(
|
|
self,
|
|
*,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> Session:
|
|
"""Create a new session"""
|
|
return self._post(
|
|
"/session",
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=Session,
|
|
)
|
|
|
|
def list(
|
|
self,
|
|
*,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> SessionListResponse:
|
|
"""List all sessions"""
|
|
return self._get(
|
|
"/session",
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=SessionListResponse,
|
|
)
|
|
|
|
def delete(
|
|
self,
|
|
id: str,
|
|
*,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> SessionDeleteResponse:
|
|
"""
|
|
Delete a session and all its data
|
|
|
|
Args:
|
|
extra_headers: Send extra headers
|
|
|
|
extra_query: Add additional query parameters to the request
|
|
|
|
extra_body: Add additional JSON properties to the request
|
|
|
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
"""
|
|
if not id:
|
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
return self._delete(
|
|
f"/session/{id}",
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=SessionDeleteResponse,
|
|
)
|
|
|
|
def abort(
|
|
self,
|
|
id: str,
|
|
*,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> SessionAbortResponse:
|
|
"""
|
|
Abort a session
|
|
|
|
Args:
|
|
extra_headers: Send extra headers
|
|
|
|
extra_query: Add additional query parameters to the request
|
|
|
|
extra_body: Add additional JSON properties to the request
|
|
|
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
"""
|
|
if not id:
|
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
return self._post(
|
|
f"/session/{id}/abort",
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=SessionAbortResponse,
|
|
)
|
|
|
|
def chat(
|
|
self,
|
|
id: str,
|
|
*,
|
|
message_id: str,
|
|
mode: str,
|
|
model_id: str,
|
|
parts: Iterable[session_chat_params.Part],
|
|
provider_id: str,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> AssistantMessage:
|
|
"""
|
|
Create and send a new message to a session
|
|
|
|
Args:
|
|
id: Session ID
|
|
|
|
extra_headers: Send extra headers
|
|
|
|
extra_query: Add additional query parameters to the request
|
|
|
|
extra_body: Add additional JSON properties to the request
|
|
|
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
"""
|
|
if not id:
|
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
return self._post(
|
|
f"/session/{id}/message",
|
|
body=maybe_transform(
|
|
{
|
|
"message_id": message_id,
|
|
"mode": mode,
|
|
"model_id": model_id,
|
|
"parts": parts,
|
|
"provider_id": provider_id,
|
|
},
|
|
session_chat_params.SessionChatParams,
|
|
),
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=AssistantMessage,
|
|
)
|
|
|
|
def init(
|
|
self,
|
|
id: str,
|
|
*,
|
|
message_id: str,
|
|
model_id: str,
|
|
provider_id: str,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> SessionInitResponse:
|
|
"""
|
|
Analyze the app and create an AGENTS.md file
|
|
|
|
Args:
|
|
id: Session ID
|
|
|
|
extra_headers: Send extra headers
|
|
|
|
extra_query: Add additional query parameters to the request
|
|
|
|
extra_body: Add additional JSON properties to the request
|
|
|
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
"""
|
|
if not id:
|
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
return self._post(
|
|
f"/session/{id}/init",
|
|
body=maybe_transform(
|
|
{
|
|
"message_id": message_id,
|
|
"model_id": model_id,
|
|
"provider_id": provider_id,
|
|
},
|
|
session_init_params.SessionInitParams,
|
|
),
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=SessionInitResponse,
|
|
)
|
|
|
|
def messages(
|
|
self,
|
|
id: str,
|
|
*,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> SessionMessagesResponse:
|
|
"""
|
|
List messages for a session
|
|
|
|
Args:
|
|
id: Session ID
|
|
|
|
extra_headers: Send extra headers
|
|
|
|
extra_query: Add additional query parameters to the request
|
|
|
|
extra_body: Add additional JSON properties to the request
|
|
|
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
"""
|
|
if not id:
|
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
return self._get(
|
|
f"/session/{id}/message",
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=SessionMessagesResponse,
|
|
)
|
|
|
|
def share(
|
|
self,
|
|
id: str,
|
|
*,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> Session:
|
|
"""
|
|
Share a session
|
|
|
|
Args:
|
|
extra_headers: Send extra headers
|
|
|
|
extra_query: Add additional query parameters to the request
|
|
|
|
extra_body: Add additional JSON properties to the request
|
|
|
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
"""
|
|
if not id:
|
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
return self._post(
|
|
f"/session/{id}/share",
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=Session,
|
|
)
|
|
|
|
def summarize(
|
|
self,
|
|
id: str,
|
|
*,
|
|
model_id: str,
|
|
provider_id: str,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> SessionSummarizeResponse:
|
|
"""
|
|
Summarize the session
|
|
|
|
Args:
|
|
id: Session ID
|
|
|
|
extra_headers: Send extra headers
|
|
|
|
extra_query: Add additional query parameters to the request
|
|
|
|
extra_body: Add additional JSON properties to the request
|
|
|
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
"""
|
|
if not id:
|
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
return self._post(
|
|
f"/session/{id}/summarize",
|
|
body=maybe_transform(
|
|
{
|
|
"model_id": model_id,
|
|
"provider_id": provider_id,
|
|
},
|
|
session_summarize_params.SessionSummarizeParams,
|
|
),
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=SessionSummarizeResponse,
|
|
)
|
|
|
|
def unshare(
|
|
self,
|
|
id: str,
|
|
*,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> Session:
|
|
"""
|
|
Unshare the session
|
|
|
|
Args:
|
|
extra_headers: Send extra headers
|
|
|
|
extra_query: Add additional query parameters to the request
|
|
|
|
extra_body: Add additional JSON properties to the request
|
|
|
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
"""
|
|
if not id:
|
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
return self._delete(
|
|
f"/session/{id}/share",
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=Session,
|
|
)
|
|
|
|
|
|
class AsyncSessionResource(AsyncAPIResource):
|
|
@cached_property
|
|
def with_raw_response(self) -> AsyncSessionResourceWithRawResponse:
|
|
"""
|
|
This property can be used as a prefix for any HTTP method call to return
|
|
the raw response object instead of the parsed content.
|
|
|
|
For more information, see https://www.github.com/sst/opencode-sdk-python#accessing-raw-response-data-eg-headers
|
|
"""
|
|
return AsyncSessionResourceWithRawResponse(self)
|
|
|
|
@cached_property
|
|
def with_streaming_response(self) -> AsyncSessionResourceWithStreamingResponse:
|
|
"""
|
|
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
|
|
For more information, see https://www.github.com/sst/opencode-sdk-python#with_streaming_response
|
|
"""
|
|
return AsyncSessionResourceWithStreamingResponse(self)
|
|
|
|
async def create(
|
|
self,
|
|
*,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> Session:
|
|
"""Create a new session"""
|
|
return await self._post(
|
|
"/session",
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=Session,
|
|
)
|
|
|
|
async def list(
|
|
self,
|
|
*,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> SessionListResponse:
|
|
"""List all sessions"""
|
|
return await self._get(
|
|
"/session",
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=SessionListResponse,
|
|
)
|
|
|
|
async def delete(
|
|
self,
|
|
id: str,
|
|
*,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> SessionDeleteResponse:
|
|
"""
|
|
Delete a session and all its data
|
|
|
|
Args:
|
|
extra_headers: Send extra headers
|
|
|
|
extra_query: Add additional query parameters to the request
|
|
|
|
extra_body: Add additional JSON properties to the request
|
|
|
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
"""
|
|
if not id:
|
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
return await self._delete(
|
|
f"/session/{id}",
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=SessionDeleteResponse,
|
|
)
|
|
|
|
async def abort(
|
|
self,
|
|
id: str,
|
|
*,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> SessionAbortResponse:
|
|
"""
|
|
Abort a session
|
|
|
|
Args:
|
|
extra_headers: Send extra headers
|
|
|
|
extra_query: Add additional query parameters to the request
|
|
|
|
extra_body: Add additional JSON properties to the request
|
|
|
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
"""
|
|
if not id:
|
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
return await self._post(
|
|
f"/session/{id}/abort",
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=SessionAbortResponse,
|
|
)
|
|
|
|
async def chat(
|
|
self,
|
|
id: str,
|
|
*,
|
|
message_id: str,
|
|
mode: str,
|
|
model_id: str,
|
|
parts: Iterable[session_chat_params.Part],
|
|
provider_id: str,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> AssistantMessage:
|
|
"""
|
|
Create and send a new message to a session
|
|
|
|
Args:
|
|
id: Session ID
|
|
|
|
extra_headers: Send extra headers
|
|
|
|
extra_query: Add additional query parameters to the request
|
|
|
|
extra_body: Add additional JSON properties to the request
|
|
|
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
"""
|
|
if not id:
|
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
return await self._post(
|
|
f"/session/{id}/message",
|
|
body=await async_maybe_transform(
|
|
{
|
|
"message_id": message_id,
|
|
"mode": mode,
|
|
"model_id": model_id,
|
|
"parts": parts,
|
|
"provider_id": provider_id,
|
|
},
|
|
session_chat_params.SessionChatParams,
|
|
),
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=AssistantMessage,
|
|
)
|
|
|
|
async def init(
|
|
self,
|
|
id: str,
|
|
*,
|
|
message_id: str,
|
|
model_id: str,
|
|
provider_id: str,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> SessionInitResponse:
|
|
"""
|
|
Analyze the app and create an AGENTS.md file
|
|
|
|
Args:
|
|
id: Session ID
|
|
|
|
extra_headers: Send extra headers
|
|
|
|
extra_query: Add additional query parameters to the request
|
|
|
|
extra_body: Add additional JSON properties to the request
|
|
|
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
"""
|
|
if not id:
|
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
return await self._post(
|
|
f"/session/{id}/init",
|
|
body=await async_maybe_transform(
|
|
{
|
|
"message_id": message_id,
|
|
"model_id": model_id,
|
|
"provider_id": provider_id,
|
|
},
|
|
session_init_params.SessionInitParams,
|
|
),
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=SessionInitResponse,
|
|
)
|
|
|
|
async def messages(
|
|
self,
|
|
id: str,
|
|
*,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> SessionMessagesResponse:
|
|
"""
|
|
List messages for a session
|
|
|
|
Args:
|
|
id: Session ID
|
|
|
|
extra_headers: Send extra headers
|
|
|
|
extra_query: Add additional query parameters to the request
|
|
|
|
extra_body: Add additional JSON properties to the request
|
|
|
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
"""
|
|
if not id:
|
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
return await self._get(
|
|
f"/session/{id}/message",
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=SessionMessagesResponse,
|
|
)
|
|
|
|
async def share(
|
|
self,
|
|
id: str,
|
|
*,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> Session:
|
|
"""
|
|
Share a session
|
|
|
|
Args:
|
|
extra_headers: Send extra headers
|
|
|
|
extra_query: Add additional query parameters to the request
|
|
|
|
extra_body: Add additional JSON properties to the request
|
|
|
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
"""
|
|
if not id:
|
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
return await self._post(
|
|
f"/session/{id}/share",
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=Session,
|
|
)
|
|
|
|
async def summarize(
|
|
self,
|
|
id: str,
|
|
*,
|
|
model_id: str,
|
|
provider_id: str,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> SessionSummarizeResponse:
|
|
"""
|
|
Summarize the session
|
|
|
|
Args:
|
|
id: Session ID
|
|
|
|
extra_headers: Send extra headers
|
|
|
|
extra_query: Add additional query parameters to the request
|
|
|
|
extra_body: Add additional JSON properties to the request
|
|
|
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
"""
|
|
if not id:
|
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
return await self._post(
|
|
f"/session/{id}/summarize",
|
|
body=await async_maybe_transform(
|
|
{
|
|
"model_id": model_id,
|
|
"provider_id": provider_id,
|
|
},
|
|
session_summarize_params.SessionSummarizeParams,
|
|
),
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=SessionSummarizeResponse,
|
|
)
|
|
|
|
async def unshare(
|
|
self,
|
|
id: str,
|
|
*,
|
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
extra_headers: Headers | None = None,
|
|
extra_query: Query | None = None,
|
|
extra_body: Body | None = None,
|
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
) -> Session:
|
|
"""
|
|
Unshare the session
|
|
|
|
Args:
|
|
extra_headers: Send extra headers
|
|
|
|
extra_query: Add additional query parameters to the request
|
|
|
|
extra_body: Add additional JSON properties to the request
|
|
|
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
"""
|
|
if not id:
|
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
return await self._delete(
|
|
f"/session/{id}/share",
|
|
options=make_request_options(
|
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
),
|
|
cast_to=Session,
|
|
)
|
|
|
|
|
|
class SessionResourceWithRawResponse:
|
|
def __init__(self, session: SessionResource) -> None:
|
|
self._session = session
|
|
|
|
self.create = to_raw_response_wrapper(
|
|
session.create,
|
|
)
|
|
self.list = to_raw_response_wrapper(
|
|
session.list,
|
|
)
|
|
self.delete = to_raw_response_wrapper(
|
|
session.delete,
|
|
)
|
|
self.abort = to_raw_response_wrapper(
|
|
session.abort,
|
|
)
|
|
self.chat = to_raw_response_wrapper(
|
|
session.chat,
|
|
)
|
|
self.init = to_raw_response_wrapper(
|
|
session.init,
|
|
)
|
|
self.messages = to_raw_response_wrapper(
|
|
session.messages,
|
|
)
|
|
self.share = to_raw_response_wrapper(
|
|
session.share,
|
|
)
|
|
self.summarize = to_raw_response_wrapper(
|
|
session.summarize,
|
|
)
|
|
self.unshare = to_raw_response_wrapper(
|
|
session.unshare,
|
|
)
|
|
|
|
|
|
class AsyncSessionResourceWithRawResponse:
|
|
def __init__(self, session: AsyncSessionResource) -> None:
|
|
self._session = session
|
|
|
|
self.create = async_to_raw_response_wrapper(
|
|
session.create,
|
|
)
|
|
self.list = async_to_raw_response_wrapper(
|
|
session.list,
|
|
)
|
|
self.delete = async_to_raw_response_wrapper(
|
|
session.delete,
|
|
)
|
|
self.abort = async_to_raw_response_wrapper(
|
|
session.abort,
|
|
)
|
|
self.chat = async_to_raw_response_wrapper(
|
|
session.chat,
|
|
)
|
|
self.init = async_to_raw_response_wrapper(
|
|
session.init,
|
|
)
|
|
self.messages = async_to_raw_response_wrapper(
|
|
session.messages,
|
|
)
|
|
self.share = async_to_raw_response_wrapper(
|
|
session.share,
|
|
)
|
|
self.summarize = async_to_raw_response_wrapper(
|
|
session.summarize,
|
|
)
|
|
self.unshare = async_to_raw_response_wrapper(
|
|
session.unshare,
|
|
)
|
|
|
|
|
|
class SessionResourceWithStreamingResponse:
|
|
def __init__(self, session: SessionResource) -> None:
|
|
self._session = session
|
|
|
|
self.create = to_streamed_response_wrapper(
|
|
session.create,
|
|
)
|
|
self.list = to_streamed_response_wrapper(
|
|
session.list,
|
|
)
|
|
self.delete = to_streamed_response_wrapper(
|
|
session.delete,
|
|
)
|
|
self.abort = to_streamed_response_wrapper(
|
|
session.abort,
|
|
)
|
|
self.chat = to_streamed_response_wrapper(
|
|
session.chat,
|
|
)
|
|
self.init = to_streamed_response_wrapper(
|
|
session.init,
|
|
)
|
|
self.messages = to_streamed_response_wrapper(
|
|
session.messages,
|
|
)
|
|
self.share = to_streamed_response_wrapper(
|
|
session.share,
|
|
)
|
|
self.summarize = to_streamed_response_wrapper(
|
|
session.summarize,
|
|
)
|
|
self.unshare = to_streamed_response_wrapper(
|
|
session.unshare,
|
|
)
|
|
|
|
|
|
class AsyncSessionResourceWithStreamingResponse:
|
|
def __init__(self, session: AsyncSessionResource) -> None:
|
|
self._session = session
|
|
|
|
self.create = async_to_streamed_response_wrapper(
|
|
session.create,
|
|
)
|
|
self.list = async_to_streamed_response_wrapper(
|
|
session.list,
|
|
)
|
|
self.delete = async_to_streamed_response_wrapper(
|
|
session.delete,
|
|
)
|
|
self.abort = async_to_streamed_response_wrapper(
|
|
session.abort,
|
|
)
|
|
self.chat = async_to_streamed_response_wrapper(
|
|
session.chat,
|
|
)
|
|
self.init = async_to_streamed_response_wrapper(
|
|
session.init,
|
|
)
|
|
self.messages = async_to_streamed_response_wrapper(
|
|
session.messages,
|
|
)
|
|
self.share = async_to_streamed_response_wrapper(
|
|
session.share,
|
|
)
|
|
self.summarize = async_to_streamed_response_wrapper(
|
|
session.summarize,
|
|
)
|
|
self.unshare = async_to_streamed_response_wrapper(
|
|
session.unshare,
|
|
)
|