mirror of
https://github.com/anomalyco/opencode-sdk-python.git
synced 2026-04-29 05:00:01 +00:00
feat(api): update via SDK Studio
This commit is contained in:
parent
ddb79fc19d
commit
a6cf7c5b2a
109 changed files with 159 additions and 153 deletions
895
src/opencode_ai/resources/session.py
Normal file
895
src/opencode_ai/resources/session.py
Normal file
|
|
@ -0,0 +1,895 @@
|
|||
# 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.message import Message
|
||||
from ..types.session import Session
|
||||
from ..types.message_part_param import MessagePartParam
|
||||
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,
|
||||
*,
|
||||
model_id: str,
|
||||
parts: Iterable[MessagePartParam],
|
||||
provider_id: str,
|
||||
session_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,
|
||||
) -> Message:
|
||||
"""
|
||||
Create and send a new message to 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}/message",
|
||||
body=maybe_transform(
|
||||
{
|
||||
"model_id": model_id,
|
||||
"parts": parts,
|
||||
"provider_id": provider_id,
|
||||
"session_id": session_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=Message,
|
||||
)
|
||||
|
||||
def init(
|
||||
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,
|
||||
) -> 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(
|
||||
{
|
||||
"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,
|
||||
*,
|
||||
model_id: str,
|
||||
parts: Iterable[MessagePartParam],
|
||||
provider_id: str,
|
||||
session_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,
|
||||
) -> Message:
|
||||
"""
|
||||
Create and send a new message to 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}/message",
|
||||
body=await async_maybe_transform(
|
||||
{
|
||||
"model_id": model_id,
|
||||
"parts": parts,
|
||||
"provider_id": provider_id,
|
||||
"session_id": session_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=Message,
|
||||
)
|
||||
|
||||
async def init(
|
||||
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,
|
||||
) -> 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(
|
||||
{
|
||||
"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,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue