Skip to content

Refactor APIs to return response body instead of ResponseEntity #4747

@quaff

Description

@quaff

It seems that all API call result is used for getBody() only, for example:

ResponseEntity<ChatCompletion> completionEntity = this.retryTemplate
.execute(ctx -> this.openAiApi.chatCompletionEntity(request, getAdditionalHttpHeaders(prompt)));
var chatCompletion = completionEntity.getBody();

I think it's better to return domain object directly instead of spring-web API, make it be parity to method parameters, like ChromaApi does:

public Tenant getTenant(String tenantName) {
try {
return this.restClient.get()
.uri("/api/v2/tenants/{tenant_name}", tenantName)
.headers(this::httpHeaders)
.retrieve()
.toEntity(Tenant.class)
.getBody();
}

CAUTION: It's breaking changes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions