1010import static org .hamcrest .Matchers .containsString ;
1111import static org .hamcrest .Matchers .equalTo ;
1212import static org .hamcrest .Matchers .is ;
13+ import static org .hamcrest .Matchers .notNullValue ;
1314
1415import com .eclipsesource .json .Json ;
15- import com .eclipsesource .json .JsonObject ;
1616import java .text .ParseException ;
1717import java .util .ArrayList ;
1818import java .util .Arrays ;
@@ -111,8 +111,8 @@ public void askAIMultipleItems() throws InterruptedException {
111111 public void askAITextGenItemWithDialogueHistory () throws ParseException , InterruptedException {
112112 BoxAPIConnection api = jwtApiForServiceAccount ();
113113 String fileName = "[askAITextGenItemWithDialogueHistory] Test File.txt" ;
114- Date date1 = BoxDateFormat .parse ("2013-05-16T15:27:57-07:00 " );
115- Date date2 = BoxDateFormat .parse ("2013-05-16T15:26:57-07:00 " );
114+ Date date1 = BoxDateFormat .parse ("2021-01-01T00:00:00Z " );
115+ Date date2 = BoxDateFormat .parse ("2021-02-01T00:00:00Z " );
116116
117117 BoxFile uploadedFile = uploadFileToUniqueFolder (api , fileName , "Test file" );
118118 try {
@@ -148,28 +148,25 @@ public void askAITextGenItemWithDialogueHistory() throws ParseException, Interru
148148 @ Test
149149 public void getAIAgentDefaultConfiguration () {
150150 BoxAPIConnection api = jwtApiForServiceAccount ();
151- BoxAIAgent agent = BoxAI .getAiAgentDefaultConfig (api , BoxAIAgent .Mode .ASK ,
152- "en" , "openai__gpt_3_5_turbo" );
151+ BoxAIAgent agent = BoxAI .getAiAgentDefaultConfig (api , BoxAIAgent .Mode .ASK );
153152 BoxAIAgentAsk askAgent = (BoxAIAgentAsk ) agent ;
154153
155154 assertThat (askAgent .getType (), is (equalTo (BoxAIAgentAsk .TYPE )));
156- assertThat (askAgent .getBasicText ().getModel (), is (equalTo ( "openai__gpt_3_5_turbo" )));
155+ assertThat (askAgent .getBasicText ().getModel (), is (notNullValue ( )));
157156
158- BoxAIAgent agent2 = BoxAI .getAiAgentDefaultConfig (api , BoxAIAgent .Mode .TEXT_GEN ,
159- "en" , "openai__gpt_3_5_turbo" );
157+ BoxAIAgent agent2 = BoxAI .getAiAgentDefaultConfig (api , BoxAIAgent .Mode .TEXT_GEN );
160158 BoxAIAgentTextGen textGenAgent = (BoxAIAgentTextGen ) agent2 ;
161159
162160 assertThat (textGenAgent .getType (), is (equalTo (BoxAIAgentTextGen .TYPE )));
163- assertThat (textGenAgent .getBasicGen ().getModel (), is (equalTo ( "openai__gpt_3_5_turbo" )));
161+ assertThat (textGenAgent .getBasicGen ().getModel (), is (notNullValue ( )));
164162 }
165163
166164 @ Test
167165 public void askAISingleItemWithAgent () throws InterruptedException {
168166 BoxAPIConnection api = jwtApiForServiceAccount ();
169167 String fileName = "[askAISingleItem] Test File.txt" ;
170168 BoxFile uploadedFile = uploadFileToUniqueFolder (api , fileName , "Test file" );
171- BoxAIAgent agent = BoxAI .getAiAgentDefaultConfig (api , BoxAIAgent .Mode .ASK ,
172- "en" , "openai__gpt_3_5_turbo_16k" );
169+ BoxAIAgent agent = BoxAI .getAiAgentDefaultConfig (api , BoxAIAgent .Mode .ASK );
173170 BoxAIAgentAsk askAgent = (BoxAIAgentAsk ) agent ;
174171
175172 try {
@@ -199,8 +196,10 @@ public void askAISingleItemWithAgent() throws InterruptedException {
199196 @ Test
200197 public void aiExtract () throws InterruptedException {
201198 BoxAPIConnection api = jwtApiForServiceAccount ();
202- BoxAIAgent agent = BoxAI .getAiAgentDefaultConfig (api , BoxAIAgent .Mode .EXTRACT , "en-US" , null );
199+ BoxAIAgent agent = BoxAI .getAiAgentDefaultConfig (api , BoxAIAgent .Mode .EXTRACT );
203200 BoxAIAgentExtract agentExtract = (BoxAIAgentExtract ) agent ;
201+ // AI team is going to move away from supporting overriding embeddings model
202+ agentExtract .getLongText ().setEmbeddings (null );
204203
205204 BoxFile uploadedFile = uploadFileToUniqueFolder (api , "[aiExtract] Test File.txt" ,
206205 "My name is John Doe. I live in San Francisco. I was born in 1990. I work at Box." );
@@ -224,8 +223,10 @@ public void aiExtract() throws InterruptedException {
224223 @ Test
225224 public void aiExtractStructuredWithFields () throws InterruptedException {
226225 BoxAPIConnection api = jwtApiForServiceAccount ();
227- BoxAIAgent agent = BoxAI .getAiAgentDefaultConfig (api , BoxAIAgent .Mode .EXTRACT_STRUCTURED , "en-US" , null );
226+ BoxAIAgent agent = BoxAI .getAiAgentDefaultConfig (api , BoxAIAgent .Mode .EXTRACT_STRUCTURED );
228227 BoxAIAgentExtractStructured agentExtractStructured = (BoxAIAgentExtractStructured ) agent ;
228+ // AI team is going to move away from supporting overriding embeddings model
229+ agentExtractStructured .getLongText ().setEmbeddings (null );
229230
230231 BoxFile uploadedFile = uploadFileToUniqueFolder (api , "[aiExtractStructuredWithFields] Test File.txt" ,
231232 "My name is John Doe. I was born in 4th July 1990. I am 34 years old. My hobby is guitar." );
@@ -259,12 +260,16 @@ public void aiExtractStructuredWithFields() throws InterruptedException {
259260 "What is your hobby?" )
260261 ),
261262 agentExtractStructured );
262- JsonObject sourceJson = response .getSourceJson ();
263- assertThat (sourceJson .get ("firstName" ).asString (), is (equalTo ("John" )));
264- assertThat (sourceJson .get ("lastName" ).asString (), is (equalTo ("Doe" )));
265- assertThat (sourceJson .get ("dateOfBirth" ).asString (), is (equalTo ("1990-07-04" )));
266- assertThat (sourceJson .get ("age" ).asInt (), is (equalTo (34 )));
267- assertThat (sourceJson .get ("hobby" ).asArray ().get (0 ).asString (), is (equalTo ("guitar" )));
263+ assertThat (response .getSourceJson ().get ("answer" ), is (equalTo (response .getAnswer ())));
264+
265+ assertThat (response .getAnswer ().get ("firstName" ).asString (), is (equalTo ("John" )));
266+ assertThat (response .getAnswer ().get ("lastName" ).asString (), is (equalTo ("Doe" )));
267+ assertThat (response .getAnswer ().get ("dateOfBirth" ).asString (), is (equalTo ("1990-07-04" )));
268+ assertThat (response .getAnswer ().get ("age" ).asInt (), is (equalTo (34 )));
269+ assertThat (response .getAnswer ().get ("hobby" ).asArray ().get (0 ).asString (), is (equalTo ("guitar" )));
270+
271+ assertThat (response .getCompletionReason (), equalTo ("done" ));
272+ assertThat (response .getCreatedAt (), is (notNullValue ()));
268273 }, 2 , 2000 );
269274 } finally {
270275 deleteFile (uploadedFile );
@@ -274,8 +279,10 @@ public void aiExtractStructuredWithFields() throws InterruptedException {
274279 @ Test
275280 public void aiExtractStructuredWithMetadataTemplate () throws InterruptedException {
276281 BoxAPIConnection api = jwtApiForServiceAccount ();
277- BoxAIAgent agent = BoxAI .getAiAgentDefaultConfig (api , BoxAIAgent .Mode .EXTRACT_STRUCTURED , "en-US" , null );
282+ BoxAIAgent agent = BoxAI .getAiAgentDefaultConfig (api , BoxAIAgent .Mode .EXTRACT_STRUCTURED );
278283 BoxAIAgentExtractStructured agentExtractStructured = (BoxAIAgentExtractStructured ) agent ;
284+ // AI team is going to move away from supporting overriding embeddings model
285+ agentExtractStructured .getLongText ().setEmbeddings (null );
279286
280287 BoxFile uploadedFile = uploadFileToUniqueFolder (api , "[aiExtractStructuredWithMetadataTemplate] Test File.txt" ,
281288 "My name is John Doe. I was born in 4th July 1990. I am 34 years old. My hobby is guitar." );
@@ -312,12 +319,15 @@ public void aiExtractStructuredWithMetadataTemplate() throws InterruptedExceptio
312319 Collections .singletonList (new BoxAIItem (uploadedFile .getID (), BoxAIItem .Type .FILE )),
313320 new BoxAIExtractMetadataTemplate (templateKey , "enterprise" ),
314321 agentExtractStructured );
315- JsonObject sourceJson = response .getSourceJson ();
316- assertThat (sourceJson .get ("firstName" ).asString (), is (equalTo ("John" )));
317- assertThat (sourceJson .get ("lastName" ).asString (), is (equalTo ("Doe" )));
318- assertThat (sourceJson .get ("dateOfBirth" ).asString (), is (equalTo ("1990-07-04T00:00:00Z" )));
319- assertThat (sourceJson .get ("age" ).asInt (), is (equalTo (34 )));
320- assertThat (sourceJson .get ("hobby" ).asArray ().get (0 ).asString (), is (equalTo ("guitar" )));
322+ assertThat (response .getSourceJson ().get ("answer" ), is (equalTo (response .getAnswer ())));
323+
324+ assertThat (response .getAnswer ().get ("firstName" ).asString (), is (equalTo ("John" )));
325+ assertThat (response .getAnswer ().get ("lastName" ).asString (), is (equalTo ("Doe" )));
326+ assertThat (response .getAnswer ().get ("dateOfBirth" ).asString (), is (equalTo ("1990-07-04T00:00:00Z" )));
327+ assertThat (response .getAnswer ().get ("age" ).asInt (), is (equalTo (34 )));
328+ assertThat (response .getAnswer ().get ("hobby" ).asArray ().get (0 ).asString (), is (equalTo ("guitar" )));
329+ assertThat (response .getCompletionReason (), equalTo ("done" ));
330+ assertThat (response .getCreatedAt (), is (notNullValue ()));
321331 }, 2 , 2000 );
322332 } finally {
323333 deleteFile (uploadedFile );
0 commit comments