-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from sashirestela/64-streamming-in-the-assista…
…nts-api Streaming in the Assistants API
- Loading branch information
Showing
18 changed files
with
298 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Enable auto-env through the sdkman_auto_env config | ||
# Add key=value pairs of SDKs to use below | ||
java=11.0.15-tem | ||
java=11.0.22-tem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/io/github/sashirestela/openai/domain/assistant/AssistantStreamEvents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package io.github.sashirestela.openai.domain.assistant; | ||
|
||
import io.github.sashirestela.cleverclient.annotation.StreamType; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import static io.github.sashirestela.openai.domain.assistant.Events.ERROR; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_CREATED; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_MESSAGE_COMPLETED; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_MESSAGE_CREATED; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_MESSAGE_DELTA; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_MESSAGE_INCOMPLETE; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_MESSAGE_IN_PROGRESS; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_RUN_CANCELLED; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_RUN_CANCELLING; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_RUN_COMPLETED; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_RUN_CREATED; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_RUN_EXPIRED; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_RUN_FAILED; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_RUN_IN_PROGRESS; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_RUN_QUEUED; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_RUN_REQUIRES_ACTION; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_RUN_STEP_CANCELLED; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_RUN_STEP_COMPLETED; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_RUN_STEP_CREATED; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_RUN_STEP_DELTA; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_RUN_STEP_EXPIRED; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_RUN_STEP_FAILED; | ||
import static io.github.sashirestela.openai.domain.assistant.Events.THREAD_RUN_STEP_IN_PROGRESS; | ||
|
||
@StreamType(type = Thread.class, events = { THREAD_CREATED }) | ||
@StreamType(type = ThreadRun.class, events = { THREAD_RUN_CREATED, THREAD_RUN_QUEUED, THREAD_RUN_IN_PROGRESS, | ||
THREAD_RUN_REQUIRES_ACTION, THREAD_RUN_COMPLETED, THREAD_RUN_FAILED, THREAD_RUN_CANCELLING, | ||
THREAD_RUN_CANCELLED, THREAD_RUN_EXPIRED }) | ||
@StreamType(type = ThreadRunStep.class, events = { THREAD_RUN_STEP_CREATED, THREAD_RUN_STEP_IN_PROGRESS, | ||
THREAD_RUN_STEP_COMPLETED, THREAD_RUN_STEP_FAILED, THREAD_RUN_STEP_CANCELLED, THREAD_RUN_STEP_EXPIRED }) | ||
@StreamType(type = ThreadRunStepDelta.class, events = { THREAD_RUN_STEP_DELTA }) | ||
@StreamType(type = ThreadMessage.class, events = { THREAD_MESSAGE_CREATED, THREAD_MESSAGE_IN_PROGRESS, | ||
THREAD_MESSAGE_COMPLETED, THREAD_MESSAGE_INCOMPLETE }) | ||
@StreamType(type = ThreadMessageDelta.class, events = { THREAD_MESSAGE_DELTA }) | ||
@StreamType(type = String.class, events = { ERROR }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.METHOD) | ||
public @interface AssistantStreamEvents { | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/io/github/sashirestela/openai/domain/assistant/Events.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.github.sashirestela.openai.domain.assistant; | ||
|
||
public interface Events { | ||
|
||
static final String THREAD_CREATED = "thread.created"; | ||
|
||
static final String THREAD_RUN_CREATED = "thread.run.created"; | ||
static final String THREAD_RUN_QUEUED = "thread.run.queued"; | ||
static final String THREAD_RUN_IN_PROGRESS = "thread.run.in_progress"; | ||
static final String THREAD_RUN_REQUIRES_ACTION = "thread.run.requires_action"; | ||
static final String THREAD_RUN_COMPLETED = "thread.run.completed"; | ||
static final String THREAD_RUN_FAILED = "thread.run.failed"; | ||
static final String THREAD_RUN_CANCELLING = "thread.run.cancelling"; | ||
static final String THREAD_RUN_CANCELLED = "thread.run.cancelled"; | ||
static final String THREAD_RUN_EXPIRED = "thread.run.expired"; | ||
|
||
static final String THREAD_RUN_STEP_CREATED = "thread.run.step.created"; | ||
static final String THREAD_RUN_STEP_IN_PROGRESS = "thread.run.step.in_progress"; | ||
static final String THREAD_RUN_STEP_COMPLETED = "thread.run.step.completed"; | ||
static final String THREAD_RUN_STEP_FAILED = "thread.run.step.failed"; | ||
static final String THREAD_RUN_STEP_CANCELLED = "thread.run.step.cancelled"; | ||
static final String THREAD_RUN_STEP_EXPIRED = "thread.run.step.expired"; | ||
|
||
static final String THREAD_RUN_STEP_DELTA = "thread.run.step.delta"; | ||
|
||
static final String THREAD_MESSAGE_CREATED = "thread.message.created"; | ||
static final String THREAD_MESSAGE_IN_PROGRESS = "thread.message.in_progress"; | ||
static final String THREAD_MESSAGE_COMPLETED = "thread.message.completed"; | ||
static final String THREAD_MESSAGE_INCOMPLETE = "thread.message.incomplete"; | ||
|
||
static final String THREAD_MESSAGE_DELTA = "thread.message.delta"; | ||
|
||
static final String ERROR = "error"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/io/github/sashirestela/openai/domain/assistant/ThreadMessageDelta.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.github.sashirestela.openai.domain.assistant; | ||
|
||
import com.fasterxml.jackson.databind.PropertyNamingStrategies; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
import java.util.List; | ||
|
||
@NoArgsConstructor | ||
@Getter | ||
@ToString | ||
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) | ||
public class ThreadMessageDelta { | ||
|
||
private String id; | ||
private String object; | ||
private ThreadMessageDeltaDetail delta; | ||
|
||
@NoArgsConstructor | ||
@Getter | ||
@ToString | ||
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) | ||
public class ThreadMessageDeltaDetail { | ||
|
||
private String role; | ||
private List<ThreadMessageContent> content; | ||
private List<String> fileIds; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.