MCPcopy
hub / github.com/SciPhi-AI/R2R / _make_request

Method _make_request

py/sdk/sync_client.py:44–68  ·  view source on GitHub ↗
(
        self, method: str, endpoint: str, version: str = "v3", **kwargs
    )

Source from the content-addressed store, hash-verified

42 self.users = UsersSDK(self)
43
44 def _make_request(
45 self, method: str, endpoint: str, version: str = "v3", **kwargs
46 ) -> dict[str, Any] | BytesIO | None:
47 url = self._get_full_url(endpoint, version)
48 request_args = self._prepare_request_args(endpoint, **kwargs)
49
50 try:
51 response = self.client.request(method, url, **request_args)
52 self._handle_response(response)
53
54 if "application/json" in response.headers.get("Content-Type", ""):
55 return response.json() if response.content else None
56 else:
57 return BytesIO(response.content)
58
59 except ConnectError as e:
60 raise R2RClientException(
61 message="Unable to connect to the server. Check your network connection and the server URL."
62 ) from e
63
64 except RequestError as e:
65 raise R2RException(
66 message=f"Request failed: {str(e)}",
67 status_code=500,
68 ) from e
69
70 def _make_streaming_request(
71 self, method: str, endpoint: str, version: str = "v3", **kwargs

Callers 15

searchMethod · 0.45
completionMethod · 0.45
embeddingMethod · 0.45
ragMethod · 0.45
agentMethod · 0.45
createMethod · 0.45
listMethod · 0.45
retrieveMethod · 0.45
updateMethod · 0.45
deleteMethod · 0.45
add_messageMethod · 0.45
update_messageMethod · 0.45

Calls 6

_handle_responseMethod · 0.95
R2RClientExceptionClass · 0.90
R2RExceptionClass · 0.90
_get_full_urlMethod · 0.80
_prepare_request_argsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected