use different prompts for generation and refinements

This commit is contained in:
Krrish Ghimire
2026-07-02 01:57:29 +05:45
parent dd102aa87c
commit 0fea26d653
2 changed files with 6 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ import lombok.Data;
public class LLMOptions { public class LLMOptions {
@Builder.Default @Builder.Default
private double temperature = 0.7; private double temperature = 0.9;
@Builder.Default @Builder.Default
private int maxTokens = 4096; private int maxTokens = 4096;

View File

@@ -39,18 +39,21 @@ public class LLMService {
private final ReferenceService referenceService; private final ReferenceService referenceService;
private final MongoTemplate mongoTemplate; private final MongoTemplate mongoTemplate;
private final String systemPrompt; private final String systemPrompt;
private final String refinerPrompt;
public LLMService(LLMFactory llmFactory, public LLMService(LLMFactory llmFactory,
LLMResponseParser responseParser, LLMResponseParser responseParser,
ReferenceService referenceService, ReferenceService referenceService,
MongoTemplate mongoTemplate, MongoTemplate mongoTemplate,
ResourceLoader resourceLoader, ResourceLoader resourceLoader,
@Value("${indie.llm.system-prompt-path:classpath:prompts/site-generator.txt}") String promptPath) { @Value("${indie.llm.system-prompt-path:classpath:prompts/site-generator.txt}") String promptPath,
@Value("${indie.llm.refiner-prompt-path:classpath:prompts/site-refiner.txt}") String refinerPath) {
this.llmFactory = llmFactory; this.llmFactory = llmFactory;
this.responseParser = responseParser; this.responseParser = responseParser;
this.referenceService = referenceService; this.referenceService = referenceService;
this.mongoTemplate = mongoTemplate; this.mongoTemplate = mongoTemplate;
this.systemPrompt = loadSystemPrompt(resourceLoader, promptPath); this.systemPrompt = loadSystemPrompt(resourceLoader, promptPath);
this.refinerPrompt = loadSystemPrompt(resourceLoader, refinerPath);
} }
public SiteStructure generateSite(UUID userId, UUID siteId, String prompt, List<Reference> references) { public SiteStructure generateSite(UUID userId, UUID siteId, String prompt, List<Reference> references) {
@@ -81,7 +84,7 @@ public class LLMService {
LLMOptions options = LLMOptions.builder() LLMOptions options = LLMOptions.builder()
.temperature(0.5) .temperature(0.5)
.build(); .build();
LLMResult result = callLLM(systemPrompt, combinedPrompt, references, options); LLMResult result = callLLM(refinerPrompt, combinedPrompt, references, options);
log.info("LLM refinement completed: model={}, latency={}ms, tokens={}+{}", log.info("LLM refinement completed: model={}, latency={}ms, tokens={}+{}",
result.getModel(), result.getLatencyMs(), result.getModel(), result.getLatencyMs(),
result.getPromptTokens(), result.getCompletionTokens()); result.getPromptTokens(), result.getCompletionTokens());