Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Update to version 0.18.0 #406

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=com.theokanning.openai-gpt3-java
VERSION_NAME=0.17.0
VERSION_NAME=0.18.0

POM_URL=https://github.com/theokanning/openai-java
POM_SCM_URL=https://github.com/theokanning/openai-java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ static void setup() {

@AfterAll
static void teardown() {
// todo delete thread
try {
service.deleteThread(threadId);
} catch (Exception e) {
// ignore
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@
import com.theokanning.openai.messages.MessageRequest;
import com.theokanning.openai.threads.Thread;
import com.theokanning.openai.threads.ThreadRequest;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;

import java.util.*;

import static org.junit.jupiter.api.Assertions.*;


@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class ThreadTest {

String token = System.getenv("OPENAI_TOKEN");
OpenAiService service = new OpenAiService(token);

static String threadId;

@Test
@Order(1)
void createThread() {
MessageRequest messageRequest = MessageRequest.builder()
.content("Hello")
Expand All @@ -27,34 +33,34 @@ void createThread() {
.build();

Thread thread = service.createThread(threadRequest);
System.out.println(thread.getId());
threadId = thread.getId();
assertEquals("thread", thread.getObject());
}

@Test
@Order(2)
void retrieveThread() {
String threadId = "thread_K82pTg9kmhxpplGqalW6IHlc";

Thread thread = service.retrieveThread(threadId);
System.out.println(thread.getMetadata());
assertEquals("thread", thread.getObject());
}

@Test
@Order(3)
void modifyThread() {
String threadId = "thread_K82pTg9kmhxpplGqalW6IHlc";
Map<String, String> metadata = new HashMap<>();
metadata.put("action", "modify");
ThreadRequest threadRequest = ThreadRequest.builder()
.metadata(metadata)
.build();
Thread thread = service.modifyThread(threadId, threadRequest);
assertEquals("thread", thread.getObject());
assertEquals("modify", thread.getMetadata().get("action"));
}

@Test
@Order(4)
void deleteThread() {
String threadId = "thread_K82pTg9kmhxpplGqalW6IHlc";
DeleteResult deleteResult = service.deleteThread(threadId);
assertEquals("thread.deleted", deleteResult.getObject());
}
Expand Down