1515import org .tinystruct .handler .Reforward ;
1616import org .tinystruct .http .*;
1717import org .tinystruct .system .ApplicationManager ;
18+ import org .tinystruct .system .annotation .Action ;
1819import org .tinystruct .system .template .variable .Variable ;
1920import org .tinystruct .system .util .Matrix ;
2021import org .tinystruct .transfer .DistributedMessageQueue ;
@@ -44,23 +45,10 @@ public class smalltalk extends DistributedMessageQueue implements SessionListene
4445 public void init () {
4546 super .init ();
4647
47- this .setAction ("talk" , "index" );
48- this .setAction ("talk/join" , "join" );
49- this .setAction ("talk/start" , "start" );
50- this .setAction ("talk/save" , "save" );
51- this .setAction ("talk/update" , "update" );
52- this .setAction ("talk/upload" , "upload" );
53- this .setAction ("talk/command" , "command" );
54- this .setAction ("talk/topic" , "topic" );
55- this .setAction ("talk/matrix" , "matrix" );
56- this .setAction ("files" , "download" );
57- this .setAction ("chat" , "chat" );
58- this .commandLines .get ("chat" ).setDescription ("Chat with ChatGPT in command-line." );
59-
6048 this .setVariable ("message" , "" );
6149 this .setVariable ("topic" , "" );
6250
63- // set env with LANG=en_US.UTF-8
51+ // Set env with LANG=en_US.UTF-8
6452 System .setProperty ("LANG" , "en_US.UTF-8" );
6553
6654 SessionManager .getInstance ().addListener (this );
@@ -76,6 +64,7 @@ public void init() {
7664 }
7765 }
7866
67+ @ Action ("talk" )
7968 public smalltalk index () {
8069 final Request request = (Request ) this .context .getAttribute (HTTP_REQUEST );
8170 final Response response = (Response ) this .context .getAttribute (HTTP_RESPONSE );
@@ -122,10 +111,12 @@ public smalltalk index() {
122111 return this ;
123112 }
124113
114+ @ Action ("talk/update" )
125115 public String update (String sessionId ) throws ApplicationException {
126116 return this .take (sessionId );
127117 }
128118
119+ @ Action ("talk/matrix" )
129120 public String matrix (String meetingCode ) throws ApplicationException {
130121 final Request request = (Request ) this .context .getAttribute (HTTP_REQUEST );
131122 final Response response = (Response ) this .context .getAttribute (HTTP_RESPONSE );
@@ -140,6 +131,7 @@ public String matrix(String meetingCode) throws ApplicationException {
140131 return "" ;
141132 }
142133
134+ @ Action ("talk/join" )
143135 public Object join (String meetingCode ) throws ApplicationException {
144136 if (groups .containsKey (meetingCode )) {
145137 final Request request = (Request ) this .context .getAttribute (HTTP_REQUEST );
@@ -156,6 +148,7 @@ public Object join(String meetingCode) throws ApplicationException {
156148 }
157149 }
158150
151+ @ Action ("talk/start" )
159152 public Object start (String name ) throws ApplicationException {
160153 final Request request = (Request ) this .context .getAttribute (HTTP_REQUEST );
161154 final Response response = (Response ) this .context .getAttribute (HTTP_RESPONSE );
@@ -173,6 +166,7 @@ public Object start(String name) throws ApplicationException {
173166 return name ;
174167 }
175168
169+ @ Action ("talk/command" )
176170 public String command () {
177171 final Request request = (Request ) this .context .getAttribute (HTTP_REQUEST );
178172 final Object meetingCode = request .getSession ().getAttribute ("meeting_code" );
@@ -195,6 +189,7 @@ public String command() {
195189 return "{ \" error\" : \" expired\" }" ;
196190 }
197191
192+ @ Action ("talk/save" )
198193 public String save () {
199194 final Request request = (Request ) this .context .getAttribute (HTTP_REQUEST );
200195 final Object meetingCode = request .getSession ().getAttribute ("meeting_code" );
@@ -264,6 +259,7 @@ public void run() {
264259 return "{ \" error\" : \" expired\" }" ;
265260 }
266261
262+ @ Action ("chat" )
267263 public void chat () {
268264 this .cli_mode = true ;
269265 if (this .config .get ("openai.api_key" ) == null || this .config .get ("openai.api_key" ).isEmpty ()) {
@@ -755,6 +751,7 @@ public String update(String meetingCode, String sessionId) throws ApplicationExc
755751 return "{}" ;
756752 }
757753
754+ @ Action ("talk/upload" )
758755 public String upload () throws ApplicationException {
759756 final Request request = (Request ) this .context .getAttribute (HTTP_REQUEST );
760757 final Object meetingCode = request .getSession ().getAttribute ("meeting_code" );
@@ -845,10 +842,12 @@ public byte[] download(String fileName, boolean encoded) throws ApplicationExcep
845842 return arr ;
846843 }
847844
845+ @ Action ("files" )
848846 public byte [] download (String fileName ) throws ApplicationException {
849847 return this .download (fileName , true );
850848 }
851849
850+ @ Action ("talk/topic" )
852851 public boolean topic () {
853852 final Request request = (Request ) this .context .getAttribute (HTTP_REQUEST );
854853 final Object meeting_code = request .getSession ().getAttribute ("meeting_code" );
0 commit comments