Skip to content

Commit 1173eb9

Browse files
committed
feat: use full context window
1 parent 733726c commit 1173eb9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313
package ch.xxx.aidoclibchat.usecase.service;
1414

15+
import java.time.Instant;
1516
import java.util.List;
1617
import java.util.Map;
1718
import java.util.Optional;
@@ -36,6 +37,7 @@ public class CodeGenerationService {
3637
You are an assistant to generate spring tests for the class under test.
3738
Analyse the classes provided and generate tests for all methods. Base your tests on the test example.
3839
Generate and implement the test methods. Generate and implement complete tests methods.
40+
3941
4042
Generate tests for this class:
4143
{classToTest}
@@ -52,6 +54,7 @@ public CodeGenerationService(GithubClient githubClient, ChatClient chatClient) {
5254
}
5355

5456
public String generateTest(String url, Optional<String> testUrlOpt) {
57+
var start = Instant.now();
5558
var githubSource = this.createTestSources(url, true);
5659
var githubTestSource = testUrlOpt.map(testUrl -> this.createTestSources(testUrl, false))
5760
.orElse(new GithubSource(null, null, List.of(), List.of()));
@@ -72,9 +75,11 @@ public String generateTest(String url, Optional<String> testUrlOpt) {
7275
Map.of("classToTest", classToTest, "contextClasses", contextClasses, "testExample", testExample)).createMessage().getContent());
7376
var response = chatClient.call(new PromptTemplate(this.ollamaPrompt,
7477
Map.of("classToTest", classToTest, "contextClasses", contextClasses, "testExample", testExample)).create());
78+
LOGGER.info(response.getResult().getOutput().getContent());
7579
LOGGER.info("Prompt tokens: " + response.getMetadata().getUsage().getPromptTokens());
7680
LOGGER.info("Generation tokens: " + response.getMetadata().getUsage().getGenerationTokens());
7781
LOGGER.info("Total tokens: " + response.getMetadata().getUsage().getTotalTokens());
82+
LOGGER.info("Time in seconds: {}", (Instant.now().toEpochMilli() - start.toEpochMilli()) / 1000);
7883
return response.getResult().getOutput().getContent();
7984
}
8085

backend/src/main/resources/application-ollama.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ spring.liquibase.change-log=classpath:/dbchangelog/db.changelog-master-ollama.xm
2727

2828
# generate code
2929
spring.ai.ollama.chat.model=granite-code:20b
30-
#spring.ai.ollama.chat.options.num-thread=8
31-
#spring.ai.ollama.chat.options.keep_alive=1s
30+
spring.ai.ollama.chat.options.num-thread=8
31+
spring.ai.ollama.chat.options.keep_alive=1s
32+
spring.ai.ollama.chat.options.num-ctx=8192

0 commit comments

Comments
 (0)