-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-docs-scala
- Loading branch information
Showing
5 changed files
with
79 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ plugins { | |
} | ||
|
||
dependencies { | ||
implementation(projects.xefCore) | ||
implementation(projects.xefJava) | ||
} | ||
|
||
|
45 changes: 45 additions & 0 deletions
45
examples/java/src/main/java/com/xebia/functional/xef/java/auto/Books.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.xebia.functional.xef.java.auto; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
public class Books { | ||
|
||
private final AIScope scope; | ||
|
||
public Books(AIScope scope) { | ||
this.scope = scope; | ||
} | ||
|
||
public static class Book { | ||
@NotNull public String title; | ||
@NotNull public String author; | ||
@NotNull public int year; | ||
@NotNull public String genre; | ||
|
||
@Override | ||
public String toString() { | ||
return "Book{" + | ||
"title='" + title + '\'' + | ||
", author='" + author + '\'' + | ||
", year=" + year + | ||
", genre='" + genre + '\'' + | ||
'}'; | ||
} | ||
} | ||
|
||
public CompletableFuture<Books.Book> bookSelection(String topic) { | ||
return scope.prompt("Give me a selection of books about " + topic, Books.Book.class); | ||
} | ||
|
||
public static void main(String[] args) throws ExecutionException, InterruptedException { | ||
try (AIScope scope = new AIScope()) { | ||
Books books = new Books(scope); | ||
books.bookSelection("artificial intelligence") | ||
.thenAccept(System.out::println) | ||
.get(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters