File tree Expand file tree Collapse file tree 4 files changed +35
-3
lines changed
src/main/java/co/yml/ychat/jvm
ychat/src/commonTest/kotlin/infrastructure Expand file tree Collapse file tree 4 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -56,4 +56,19 @@ This endpoint generates images based on the provided prompt.
5656
5757##### Example:
5858
59- `GET http://localhost:8080/api/ychat/generations?prompt="ocean"
59+ `GET http://localhost:8080/api/ychat/generations?prompt="ocean "
60+
61+ ### Edits Endpoint
62+
63+ This endpoint edits the prompt based on the provided instruction.
64+
65+ ##### Endpoint: http://localhost:[port_number ] /api/ychat/edits
66+
67+ ##### Parameters:
68+
69+ - ` input ` : The input text to use as a starting point for the edit.
70+ - ` instruction ` : The instruction that tells the model how to edit the prompt.
71+
72+ ##### Example:
73+
74+ `GET http://localhost:8080/api/ychat/edits?input=What day of the wek is it?&instruction=Fix the spelling mistakes
Original file line number Diff line number Diff line change @@ -40,6 +40,15 @@ public ResponseEntity<String> imageGenerations(
4040 return ResponseEntity .ok (result );
4141 }
4242
43+ @ GetMapping ("edits" )
44+ public ResponseEntity <String > edits (
45+ @ RequestParam (value = "input" ) String input ,
46+ @ RequestParam (value = "instruction" ) String instruction
47+ ) throws Exception {
48+ String result = YChatService .getEditsAnswer (input , instruction );
49+ return ResponseEntity .ok (result );
50+ }
51+
4352 private static class Defaults {
4453 static final String COMPLETION_INPUT = "Say this is a test." ;
4554 static final String CHAT_COMPLETION_INPUT = "Tell me one strength exercise" ;
Original file line number Diff line number Diff line change @@ -42,6 +42,14 @@ public String getImageGenerationsAnswer(String prompt) throws Exception {
4242 return future .get ().get (0 );
4343 }
4444
45+ public String getEditsAnswer (String input , String instruction ) throws Exception {
46+ final CompletableFuture <List <String >> future = new CompletableFuture <>();
47+ ychat .edits ()
48+ .setInput (input )
49+ .execute (instruction , new CompletionCallbackResult <>(future ));
50+ return future .get ().get (0 );
51+ }
52+
4553 private static class CompletionCallbackResult <T > implements YChat .Callback <T > {
4654
4755 private final CompletableFuture <T > future ;
Original file line number Diff line number Diff line change @@ -18,6 +18,6 @@ object MockStorage {
1818 " {\" created\" :1678805561,\" data\" :[{\" url\" :\" $text \" }]}"
1919
2020 fun editsSuccessResult (text : String ) = " {\" object\" :\" edit\" ,\" created\" :1679072839," +
21- " \" choices\" :[{\" text\" :\" $text \" ,\" index\" :0}]," +
22- " \" usage\" :{\" prompt_tokens\" :25,\" completion_tokens\" :28,\" total_tokens\" :53}}"
21+ " \" choices\" :[{\" text\" :\" $text \" ,\" index\" :0}]," +
22+ " \" usage\" :{\" prompt_tokens\" :25,\" completion_tokens\" :28,\" total_tokens\" :53}}"
2323}
You can’t perform that action at this time.
0 commit comments