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
81
81
82
82
##### Example:
83
83
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 6
6
import org .springframework .beans .factory .annotation .Autowired ;
7
7
import org .springframework .http .ResponseEntity ;
8
8
import org .springframework .web .bind .annotation .GetMapping ;
9
+ import org .springframework .web .bind .annotation .PathVariable ;
9
10
import org .springframework .web .bind .annotation .RequestMapping ;
10
11
import org .springframework .web .bind .annotation .RequestParam ;
11
12
import org .springframework .web .bind .annotation .RestController ;
@@ -57,6 +58,12 @@ public ResponseEntity<List<AIModel>> models() throws Exception {
57
58
return ResponseEntity .ok (result );
58
59
}
59
60
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
+
60
67
private static class Defaults {
61
68
static final String COMPLETION_INPUT = "Say this is a test." ;
62
69
static final String CHAT_COMPLETION_INPUT = "Tell me one strength exercise" ;
Original file line number Diff line number Diff line change 1
1
package co .yml .ychat .jvm .services ;
2
2
3
+ import co .yml .ychat .YChat ;
3
4
import co .yml .ychat .domain .model .AIModel ;
4
5
import co .yml .ychat .domain .model .ChatMessage ;
5
6
import java .util .List ;
7
+ import java .util .concurrent .CompletableFuture ;
6
8
import org .jetbrains .annotations .NotNull ;
7
9
import org .springframework .beans .factory .annotation .Autowired ;
8
10
import org .springframework .stereotype .Service ;
9
- import java .util .concurrent .CompletableFuture ;
10
- import co .yml .ychat .YChat ;
11
11
12
12
@ Service
13
13
public class YChatService {
@@ -58,6 +58,13 @@ public List<AIModel> getModels() throws Exception {
58
58
return future .get ();
59
59
}
60
60
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
+
61
68
private static class CompletionCallbackResult <T > implements YChat .Callback <T > {
62
69
63
70
private final CompletableFuture <T > future ;
You can’t perform that action at this time.
0 commit comments