Skip to content

Commit

Permalink
Upper case caps on final PDF_URL
Browse files Browse the repository at this point in the history
Remove lambda parenthesis
Clarify null is exit in println
  • Loading branch information
adam47deg committed Jul 12, 2023
1 parent 05f2804 commit 0616446
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ public static class AIResponse {
public String source;
}

private static final String pdfUrl = "https://people.cs.ksu.edu/~schmidt/705a/Scala/Programming-in-Scala.pdf";
private static final String PDF_URL = "https://people.cs.ksu.edu/~schmidt/705a/Scala/Programming-in-Scala.pdf";
private static final BufferedReader sysin = new BufferedReader(new InputStreamReader(System.in));

private static CompletableFuture<Void> askQuestion(AIScope scope) {
System.out.println("Enter your question: ");
System.out.println("Enter your question (<return> to exit): ");

String line = readLine();
if (line == null || line.isBlank()) {
return CompletableFuture.completedFuture(null);
} else {
scope.prompt(line, AIResponse.class)
.thenAccept((aiRes) -> System.out.println(aiRes.answer + "\n---\n" +
.thenAccept(aiRes -> System.out.println(aiRes.answer + "\n---\n" +
aiRes.source + "\n---\n"));

return askQuestion(scope);
Expand All @@ -39,7 +39,7 @@ private static CompletableFuture<Void> askQuestion(AIScope scope) {
public static void main(String[] args) throws ExecutionException, InterruptedException {
TextSplitter textSplitter = TokenTextSplitter(ModelType.getDEFAULT_SPLITTER_MODEL(), 100, 50);
try (AIScope scope = new AIScope()) {
scope.contextScope(scope.pdf(pdfUrl, textSplitter).get(), PDFDocument::askQuestion).get();
scope.contextScope(scope.pdf(PDF_URL, textSplitter).get(), PDFDocument::askQuestion).get();
}
}

Expand Down

0 comments on commit 0616446

Please sign in to comment.