MCPcopy
hub / github.com/openai/openai-python / _info_to_options

Method _info_to_options

src/openai/_base_client.py:202–230  ·  src/openai/_base_client.py::BasePage._info_to_options
(self, info: PageInfo)

Source from the content-addressed store, hash-verified

200 return httpx.QueryParams(cast(Any, self._options.params)).merge(url.params)
201
202 def _info_to_options(self, info: PageInfo) -> FinalRequestOptions:
203 options = model_copy(self._options)
204 options._strip_raw_response_header()
205
206 if not isinstance(info.params, NotGiven):
207 options.params = {**options.params, **info.params}
208 return options
209
210 if not isinstance(info.url, NotGiven):
211 params = self._params_from_url(info.url)
212 url = info.url.copy_with(params=params)
213 options.params = dict(url.params)
214 options.url = str(url)
215 return options
216
217 if not isinstance(info.json, NotGiven):
218 if not is_mapping(info.json):
219 raise TypeError(class="st">"Pagination is only supported with mappings")
220
221 if not options.json_data:
222 options.json_data = {**info.json}
223 else:
224 if not is_mapping(options.json_data):
225 raise TypeError(class="st">"Pagination is only supported with mappings")
226
227 options.json_data = {**options.json_data, **info.json}
228 return options
229
230 raise ValueError(class="st">"Unexpected PageInfo state")
231
232
233class BaseSyncPage(BasePage[_T], Generic[_T]):

Callers 2

get_next_pageMethod · 0.80
get_next_pageMethod · 0.80

Calls 4

_params_from_urlMethod · 0.95
model_copyFunction · 0.85
is_mappingFunction · 0.85

Tested by

no test coverage detected