File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed
src/main/java/co/yml/ychat/jvm Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -81,4 +81,14 @@ This endpoint retrieve a list of currently available artificial intelligence mod
8181
8282##### Example:
8383
84- ` GET http://localhost:8080/api/ychat/models `
84+ ` GET http://localhost:8080/api/ychat/models `
85+
86+ ### Model Endpoint
87+
88+ This endpoint retrieve the artificial intelligence model based on the given ID.
89+
90+ ##### Endpoint: http://localhost:[port_number ] /api/ychat/models/{modelID}
91+
92+ ##### Example:
93+
94+ ` GET http://localhost:8080/api/ychat/models/babbage `
Original file line number Diff line number Diff line change 66import org .springframework .beans .factory .annotation .Autowired ;
77import org .springframework .http .ResponseEntity ;
88import org .springframework .web .bind .annotation .GetMapping ;
9+ import org .springframework .web .bind .annotation .PathVariable ;
910import org .springframework .web .bind .annotation .RequestMapping ;
1011import org .springframework .web .bind .annotation .RequestParam ;
1112import org .springframework .web .bind .annotation .RestController ;
@@ -57,6 +58,12 @@ public ResponseEntity<List<AIModel>> models() throws Exception {
5758 return ResponseEntity .ok (result );
5859 }
5960
61+ @ GetMapping ("models/{id}" )
62+ public ResponseEntity <AIModel > model (@ PathVariable String id ) throws Exception {
63+ AIModel result = YChatService .getModel (id );
64+ return ResponseEntity .ok (result );
65+ }
66+
6067 private static class Defaults {
6168 static final String COMPLETION_INPUT = "Say this is a test." ;
6269 static final String CHAT_COMPLETION_INPUT = "Tell me one strength exercise" ;
Original file line number Diff line number Diff line change 11package co .yml .ychat .jvm .services ;
22
3+ import co .yml .ychat .YChat ;
34import co .yml .ychat .domain .model .AIModel ;
45import co .yml .ychat .domain .model .ChatMessage ;
56import java .util .List ;
7+ import java .util .concurrent .CompletableFuture ;
68import org .jetbrains .annotations .NotNull ;
79import org .springframework .beans .factory .annotation .Autowired ;
810import org .springframework .stereotype .Service ;
9- import java .util .concurrent .CompletableFuture ;
10- import co .yml .ychat .YChat ;
1111
1212@ Service
1313public class YChatService {
@@ -58,6 +58,13 @@ public List<AIModel> getModels() throws Exception {
5858 return future .get ();
5959 }
6060
61+ public AIModel getModel (String id ) throws Exception {
62+ final CompletableFuture <AIModel > future = new CompletableFuture <>();
63+ ychat .retrieveModel ()
64+ .execute (id , new CompletionCallbackResult <>(future ));
65+ return future .get ();
66+ }
67+
6168 private static class CompletionCallbackResult <T > implements YChat .Callback <T > {
6269
6370 private final CompletableFuture <T > future ;
You can’t perform that action at this time.
0 commit comments