This pull request includes changes to the AIChatProtocolClient class in the sdk/js/packages/client/src/client.ts file, which improve error handling and add support for localhost connections. The changes also introduce new types and modify existing ones in the sdk/js/packages/client/src/model/model.ts and spec/models.tsp files, and update the exported types in the sdk/js/packages/client/src/index.ts and sdk/js/packages/client/src/model/index.ts files. Finally, the pull request modifies the return types of operations in the spec/operations.tsp file.
Improvements to error handling and localhost support:
sdk/js/packages/client/src/client.ts: Added the AIChatErrorResponse import, and new functions isErrorResponse, isLocalhost, getStreamContent, and handleFailedRequest for improved error handling. Also updated the AIChatProtocolClient constructor to allow insecure connections when the endpoint is localhost, and updated the getCompletion and getStreamedCompletion methods to use the new error handling functions. [1][2][3][4][5]
spec/operations.tsp: Modified the return types of getCompletion and getStreamedCompletion operations to be a union of the original return type and AIChatErrorResponse.
This pull request includes changes to the
AIChatProtocolClient
class in thesdk/js/packages/client/src/client.ts
file, which improve error handling and add support for localhost connections. The changes also introduce new types and modify existing ones in thesdk/js/packages/client/src/model/model.ts
andspec/models.tsp
files, and update the exported types in thesdk/js/packages/client/src/index.ts
andsdk/js/packages/client/src/model/index.ts
files. Finally, the pull request modifies the return types of operations in thespec/operations.tsp
file.Improvements to error handling and localhost support:
sdk/js/packages/client/src/client.ts
: Added theAIChatErrorResponse
import, and new functionsisErrorResponse
,isLocalhost
,getStreamContent
, andhandleFailedRequest
for improved error handling. Also updated theAIChatProtocolClient
constructor to allow insecure connections when the endpoint is localhost, and updated thegetCompletion
andgetStreamedCompletion
methods to use the new error handling functions. [1] [2] [3] [4] [5]Changes to types:
sdk/js/packages/client/src/model/model.ts
: AddedAIChatError
andAIChatErrorResponse
interfaces.spec/models.tsp
: AddedAIChatError
andAIChatErrorResponse
models.Updates to exported types:
sdk/js/packages/client/src/index.ts
: AddedAIChatError
andAIChatErrorResponse
to the exported types.sdk/js/packages/client/src/model/index.ts
: AddedAIChatErrorResponse
andAIChatError
to the exported types.Changes to operation return types:
spec/operations.tsp
: Modified the return types ofgetCompletion
andgetStreamedCompletion
operations to be a union of the original return type andAIChatErrorResponse
.