Skip to content

Commit ca17d4b

Browse files
committed
fix: function interface
1 parent 5aab871 commit ca17d4b

File tree

7 files changed

+10
-8
lines changed

7 files changed

+10
-8
lines changed

backend/src/main/java/ch/xxx/aidoclibchat/adapter/client/OpenLibraryRestClient.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.slf4j.Logger;
2323
import org.slf4j.LoggerFactory;
24+
import org.springframework.beans.factory.annotation.Value;
2425
import org.springframework.stereotype.Component;
2526
import org.springframework.web.client.RestClient;
2627

@@ -31,6 +32,8 @@ public class OpenLibraryRestClient implements OpenLibraryClient {
3132
private static final Logger LOGGER = LoggerFactory.getLogger(OpenLibraryRestClient.class);
3233
private final String baseUrl = "https://openlibrary.org/search.json";
3334
private final RestClient restClient;
35+
@Value("${openlibrary.result-size:10}")
36+
private int resultLimit;
3437

3538
public OpenLibraryRestClient(RestClient restClient) {
3639
this.restClient = restClient;
@@ -44,7 +47,7 @@ public Response apply(Request request) {
4447
var paramsStr = List.of(authorOpt, titleOpt, subjectOpt).stream()
4548
.filter(Optional::isPresent).map(Optional::get).collect(Collectors.joining("&"));
4649
var urlStr =
47-
String.format("%s?%s&limit=10", this.baseUrl, paramsStr);
50+
String.format("%s?%s&limit=%d", this.baseUrl, paramsStr, this.resultLimit);
4851
LOGGER.info(urlStr);
4952
var response = this.restClient.get().uri(urlStr).retrieve().body(Response.class);
5053
return response;

backend/src/main/java/ch/xxx/aidoclibchat/adapter/controller/FunctionController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public FunctionController(FunctionService functionService) {
3939

4040
@PostMapping(path="/books", produces = MediaType.APPLICATION_JSON_VALUE)
4141
public FunctionResult postQuestion(@RequestBody FunctionSearch functionSearch) {
42-
return new FunctionResult(this.functionService.functionCall(functionSearch.question(), functionSearch.resultAmount()));
42+
return new FunctionResult(this.functionService.functionCall(functionSearch.question()));
4343
}
4444

4545
}

backend/src/main/java/ch/xxx/aidoclibchat/domain/model/dto/FunctionSearch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
*/
1313
package ch.xxx.aidoclibchat.domain.model.dto;
1414

15-
public record FunctionSearch(String question, Long resultAmount) { }
15+
public record FunctionSearch(String question) { }

backend/src/main/java/ch/xxx/aidoclibchat/usecase/service/FunctionService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public FunctionService(Builder builder) {
3939
this.chatClient = builder.build();
4040
}
4141

42-
public String functionCall(String question, Long resultsAmount) {
42+
public String functionCall(String question) {
4343
if (!this.activeProfile.contains("ollama")) {
4444
return "";
4545
}

backend/src/main/resources/application.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ management.endpoint.health.show-details=always
3939

4040
embedding-token-limit=2000
4141
document-token-limit=2000
42-
image.result-size=20
42+
image.result-size=20
43+
openlibrary.result-size=10

frontend/src/angular/src/app/function-search/function-search.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ export class FunctionSearchComponent {
9898
);
9999
this.functionSearchService
100100
.postLibraryFunction({
101-
question: this.searchValueControl.value,
102-
resultAmount: 10,
101+
question: this.searchValueControl.value
103102
} as FunctionSearch)
104103
.pipe(
105104
tap(() => this.repeatSub?.unsubscribe()),

frontend/src/angular/src/app/model/functions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*/
1313
export interface FunctionSearch {
1414
question: string;
15-
resultAmount: number;
1615
}
1716

1817
export interface Book {

0 commit comments

Comments
 (0)