-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use typed methods and typed API Responses to catch all the APIs retur…
…ning invalid response types
- Loading branch information
Showing
11 changed files
with
159 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using AiServer.ServiceModel; | ||
|
||
namespace AiServer.ServiceInterface; | ||
|
||
public static class DtoExtensions | ||
{ | ||
public static TextGenerationResponse ToTextGenerationResponse(this GenerationResponse response) => response.TextOutputs?.Count > 0 ? new() { | ||
Results = response.TextOutputs, | ||
ResponseStatus = response.ResponseStatus | ||
} : throw new Exception("Failed to generate any text outputs"); | ||
|
||
public static ArtifactGenerationResponse ToArtifactGenerationResponse(this GenerationResponse response) => response.Outputs?.Count > 0 ? new() { | ||
Results = response.Outputs, | ||
ResponseStatus = response.ResponseStatus | ||
} : throw new Exception("Failed to generate any outputs"); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.