test_that("messages",{ skip_on_cran() Sys.setenv(TEST_EX_COND = "") handle_openai<-openai$new(Sys.getenv("OPENAI_KEY")) if(Sys.getenv("USE_PROXY")=="TRUE"){ handle_openai$set_proxy("10.0.108.36",7890) } thc<-handle_openai$threads$create() expect_contains(names(thc),"id") train_file_path<-system.file("exdata","assfile.txt", package = "openaistream") file_id <- handle_openai$files$upload(path = train_file_path,purpose = "assistants",verbosity = 0) mesc<-handle_openai$messages$create(thc$id,role = "user",content = "hello",attachments=list(list(file_id=file_id$id,tools=list(list(type="file_search")))),verbosity = 0) expect_equal(mesc$object,"thread.message") mesl<-handle_openai$messages$list(thread_id = thc$id,verbosity = 0) expect_contains(mesl$data$id,mesc$id) mesr<-handle_openai$messages$retrieve(thc$id,mesc$id) expect_equal(mesr$object,"thread.message") mesm<-handle_openai$messages$modify(thc$id,mesc$id,metadata=list(test="test")) expect_equal(mesm$metadata$test,"test") mesd<-handle_openai$messages$delete(thc$id,mesc$id) expect_true(mesd$deleted) del_res<-handle_openai$files$delete(file_id$id, verbosity = 0) expect_true(del_res$deleted) thd<-handle_openai$threads$delete(thc$id) expect_true(thd$deleted) # #error test mesc<-handle_openai$messages$create(thc$id,role = "user",content = "hello",file_ids=list(file_id$id),verbosity = 4) expect_true(!mesc$success) mesl<-handle_openai$messages$list(thread_id = thc$id,verbosity = 4) expect_true(!mesl$success) mesr<-handle_openai$messages$retrieve(thc$id,mesc$id) expect_true(!mesr$success) mesm<-handle_openai$messages$modify(thc$id,mesc$id,metadata=list(test="test"),verbosity = 4) expect_true(!mesm$success) mesd<-handle_openai$messages$delete(thc$id,mesc$id,verbosity = 4) expect_true(!mesd$success) })