Skip to content

Commit

Permalink
enhance code
Browse files Browse the repository at this point in the history
  • Loading branch information
HamaWhiteGG committed Oct 4, 2023
1 parent bc5e5cd commit 4aec20c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ private static BasePromptTemplate getPrompt(String documentContents, List<Attrib
Map.of("i", examples.size() + 1, "content", documentContents, "attributes", attributeStr));

var outputParser = StructuredQueryOutputParser.fromComponents(allowedComparators, allowedOperators);
return new FewShotPromptTemplate(examples, EXAMPLE_PROMPT, prefix, suffix, List.of("query"), outputParser);
return new FewShotPromptTemplate(examples, EXAMPLE_PROMPT, prefix, suffix, List.of("query"), "\n\n",
outputParser);
}

private static Map<String, Object> createTemplateArguments(List<Comparator> allowedComparators,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,26 @@ public class FewShotPromptTemplate extends StringPromptTemplate {
/**
* String separator used to join the prefix, the examples, and suffix.
*/
private String exampleSeparator = "\n\n";
private String exampleSeparator;

public FewShotPromptTemplate(List<Map<String, Object>> examples, PromptTemplate examplePrompt, String prefix,
String suffix, List<String> inputVariables, BaseOutputParser<?> outputParser) {
String suffix, List<String> inputVariables) {
this(examples, examplePrompt, prefix, suffix, inputVariables, "\n\n");
}

public FewShotPromptTemplate(List<Map<String, Object>> examples, PromptTemplate examplePrompt, String prefix,
String suffix, List<String> inputVariables, String exampleSeparator) {
this(examples, examplePrompt, prefix, suffix, inputVariables, exampleSeparator, null);
}

public FewShotPromptTemplate(List<Map<String, Object>> examples, PromptTemplate examplePrompt, String prefix,
String suffix, List<String> inputVariables, String exampleSeparator, BaseOutputParser<?> outputParser) {
super(inputVariables, outputParser);
this.examples = examples;
this.examplePrompt = examplePrompt;
this.prefix = prefix;
this.suffix = suffix;
this.exampleSeparator = exampleSeparator;
}

public List<Map<String, Object>> getExamples() {
Expand Down

0 comments on commit 4aec20c

Please sign in to comment.