MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / chat

Method chat

src/opencode_ai/resources/session.py:157–209  ·  view source on GitHub ↗

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: Ove

(
        self,
        id: str,
        *,
        model_id: str,
        parts: Iterable[session_chat_params.Part],
        provider_id: str,
        message_id: str | NotGiven = NOT_GIVEN,
        mode: str | NotGiven = NOT_GIVEN,
        system: str | NotGiven = NOT_GIVEN,
        tools: Dict[str, bool] | NotGiven = NOT_GIVEN,
        # 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,
    )

Source from the content-addressed store, hash-verified

155 )
156
157 def chat(
158 self,
159 id: str,
160 *,
161 model_id: str,
162 parts: Iterable[session_chat_params.Part],
163 provider_id: str,
164 message_id: str | NotGiven = NOT_GIVEN,
165 mode: str | NotGiven = NOT_GIVEN,
166 system: str | NotGiven = NOT_GIVEN,
167 tools: Dict[str, bool] | NotGiven = NOT_GIVEN,
168 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
169 # The extra values given here take precedence over values defined on the client or passed to this method.
170 extra_headers: Headers | None = None,
171 extra_query: Query | None = None,
172 extra_body: Body | None = None,
173 timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
174 ) -> AssistantMessage:
175 """
176 Create and send a new message to a session
177
178 Args:
179 id: Session ID
180
181 extra_headers: Send extra headers
182
183 extra_query: Add additional query parameters to the request
184
185 extra_body: Add additional JSON properties to the request
186
187 timeout: Override the client-level default timeout for this request, in seconds
188 """
189 if not id:
190 raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
191 return self._post(
192 f"/session/{id}/message",
193 body=maybe_transform(
194 {
195 "model_id": model_id,
196 "parts": parts,
197 "provider_id": provider_id,
198 "message_id": message_id,
199 "mode": mode,
200 "system": system,
201 "tools": tools,
202 },
203 session_chat_params.SessionChatParams,
204 ),
205 options=make_request_options(
206 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
207 ),
208 cast_to=AssistantMessage,
209 )
210
211 def init(
212 self,

Calls 2

maybe_transformFunction · 0.85
make_request_optionsFunction · 0.85