@@ -269,7 +269,7 @@ from friendli import SyncFriendli
269269with SyncFriendli(
270270 token = os.getenv(" FRIENDLI_TOKEN" , " " ),
271271) as friendli:
272- res = friendli.dedicated .chat.complete(
272+ res = friendli.container .chat.complete(
273273 messages = [
274274 {
275275 " content" : " You are a helpful assistant." ,
@@ -427,7 +427,7 @@ with SyncFriendli(
427427operations. These operations will expose the stream as [ Generator] [ generator ] that
428428can be consumed using a simple ` for ` loop. The loop will
429429terminate when the server no longer has any events to send and closes the
430- underlying connection.
430+ underlying connection.
431431
432432The stream is also a [ Context Manager] [ context-manager ] and can be used with the ` with ` statement and will close the
433433underlying connection when the context is exited.
@@ -513,7 +513,7 @@ from friendli.utils import BackoffStrategy, RetryConfig
513513with SyncFriendli(
514514 token = os.getenv(" FRIENDLI_TOKEN" , " " ),
515515) as friendli:
516- res = friendli.dedicated .chat.complete(
516+ res = friendli.container .chat.complete(
517517 messages = [
518518 {
519519 " content" : " You are a helpful assistant." ,
@@ -545,7 +545,7 @@ with SyncFriendli(
545545 retry_config = RetryConfig(" backoff" , BackoffStrategy(1 , 50 , 1.1 , 100 ), False ),
546546 token = os.getenv(" FRIENDLI_TOKEN" , " " ),
547547) as friendli:
548- res = friendli.dedicated .chat.complete(
548+ res = friendli.container .chat.complete(
549549 messages = [
550550 {
551551 " content" : " You are a helpful assistant." ,
@@ -569,29 +569,22 @@ with SyncFriendli(
569569<!-- Start Error Handling [errors] -->
570570## Error Handling
571571
572- Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.
573-
574- By default, an API error will raise a models.SDKError exception, which has the following properties:
572+ [ ` FriendliCoreError ` ] ( ./src/friendli/models/friendlicoreerror.py ) is the base class for all HTTP error responses. It has the following properties:
575573
576- | Property | Type | Description |
577- | -----------------| ------------------| -----------------------|
578- | ` .status_code ` | * int* | The HTTP status code |
579- | ` .message ` | * str* | The error message |
580- | ` .raw_response ` | * httpx.Response* | The raw HTTP response |
581- | ` .body ` | * str* | The response content |
582-
583- When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective * Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the ` delete ` method may raise the following exceptions:
584-
585- | Error Type | Status Code | Content Type |
586- | -------------------------- | ----------- | ---------------- |
587- | models.HTTPValidationError | 422 | application/json |
588- | models.SDKError | 4XX, 5XX | \* /\* |
574+ | Property | Type | Description |
575+ | ------------------ | ---------------- | --------------------------------------------------------------------------------------- |
576+ | ` err.message ` | ` str ` | Error message |
577+ | ` err.status_code ` | ` int ` | HTTP response status code eg ` 404 ` |
578+ | ` err.headers ` | ` httpx.Headers ` | HTTP response headers |
579+ | ` err.body ` | ` str ` | HTTP body. Can be empty string if no body is returned. |
580+ | ` err.raw_response ` | ` httpx.Response ` | Raw HTTP response |
581+ | ` err.data ` | | Optional. Some errors may contain structured data. [ See Error Classes] ( #error-classes ) . |
589582
590583### Example
591-
592584``` python
593585import os
594586
587+ import friendli
595588from friendli import SyncFriendli, models
596589
597590with SyncFriendli(
@@ -604,13 +597,40 @@ with SyncFriendli(
604597 # Handle response
605598 print (res)
606599
607- except models.HTTPValidationError as e:
608- # handle e.data: models.HTTPValidationErrorData
609- raise (e)
610- except models.SDKError as e:
611- # handle exception
612- raise (e)
600+ except models.FriendliCoreError as e:
601+ # The base class for HTTP error responses
602+ print (e.message)
603+ print (e.status_code)
604+ print (e.body)
605+ print (e.headers)
606+ print (e.raw_response)
607+
608+ # Depending on the method different errors may be thrown
609+ if isinstance (e, models.HTTPValidationError):
610+ print (e.data.detail) # Optional[List[friendli.ValidationError]]
613611```
612+
613+ ### Error Classes
614+ ** Primary error:**
615+ * [ ` FriendliCoreError ` ] ( ./src/friendli/models/friendlicoreerror.py ) : The base class for HTTP error responses.
616+
617+ <details ><summary >Less common errors (6)</summary >
618+
619+ <br />
620+
621+ ** Network errors:**
622+ * [ ` httpx.RequestError ` ] ( https://www.python-httpx.org/exceptions/#httpx.RequestError ) : Base class for request errors.
623+ * [ ` httpx.ConnectError ` ] ( https://www.python-httpx.org/exceptions/#httpx.ConnectError ) : HTTP client was unable to make a request to a server.
624+ * [ ` httpx.TimeoutException ` ] ( https://www.python-httpx.org/exceptions/#httpx.TimeoutException ) : HTTP request timed out.
625+
626+
627+ ** Inherit from [ ` FriendliCoreError ` ] ( ./src/friendli/models/friendlicoreerror.py ) ** :
628+ * [ ` HTTPValidationError ` ] ( ./src/friendli/models/httpvalidationerror.py ) : Validation Error. Status code ` 422 ` . Applicable to 21 of 57 methods.*
629+ * [ ` ResponseValidationError ` ] ( ./src/friendli/models/responsevalidationerror.py ) : Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the ` cause ` attribute.
630+
631+ </details >
632+
633+ \* Check [ the method documentation] ( #available-resources-and-operations ) to see if the error is applicable.
614634<!-- End Error Handling [errors] -->
615635
616636<!-- Start Server Selection [server] -->
0 commit comments