1
1
package com.cjcrafter.openai.threads.runs
2
2
3
+ import com.cjcrafter.openai.assistants.Assistant
4
+ import com.cjcrafter.openai.chat.tool.Tool
5
+ import com.cjcrafter.openai.threads.Thread
6
+ import com.cjcrafter.openai.threads.message.ThreadMessage
3
7
import com.fasterxml.jackson.annotation.JsonProperty
4
8
9
+ /* *
10
+ *
11
+ */
5
12
enum class RunStatus (
6
- val isDone : Boolean ,
13
+ val isTerminal : Boolean ,
7
14
) {
8
15
16
+ /* *
17
+ * When [Run]s are first created or when you complete the [RequiredAction],
18
+ * they are moved to this 'queued' status. They should _almost immediately_
19
+ * move to [IN_PROGRESS].
20
+ */
9
21
@JsonProperty(" queued" )
10
22
QUEUED (false ),
11
23
24
+ /* *
25
+ * While [IN_PROGRESS], the [Assistant] uses the mode and tools to perform
26
+ * steps. You can view progress being made by the [Run] by examining the
27
+ * [RunStep]s.
28
+ */
12
29
@JsonProperty(" in_progress" )
13
30
IN_PROGRESS (false ),
14
31
15
- @JsonProperty(" requires_action" )
16
- REQUIRES_ACTION (true ),
32
+ /* *
33
+ * When using the [Tool.FunctionTool], the [Run] will move to a [REQUIRED_ACTION]
34
+ * state once the model determines the names and arguments of the functions
35
+ * to be called. You must then run those functions and submit the outputs
36
+ * using [RunHandler.submitToolOutputs] before the run proceeds. If the
37
+ * outputs are not provided before the [Run.expiresAt] timestamp passes
38
+ * (roughly 10 minutes past creation), the run will move to an [EXPIRED]
39
+ * status.
40
+ */
41
+ @JsonProperty(" required_action" )
42
+ REQUIRED_ACTION (true ),
17
43
44
+ /* *
45
+ * You can attempt to cancel an [IN_PROGRESS] [Run] using [RunHandler.cancel].
46
+ * Once the attempt to cancel succeeds, status of the [Run] moves to
47
+ * [CANCELLED]. Cancellation is attempted but not guarenteed.
48
+ */
18
49
@JsonProperty(" cancelling" )
19
50
CANCELLING (false ),
20
51
52
+ /* *
53
+ * The [Run] was successfully cancelled.
54
+ */
21
55
@JsonProperty(" cancelled" )
22
56
CANCELLED (true ),
23
57
58
+ /* *
59
+ * You can view the reason for the failure by looking at the [Run.lastError]
60
+ * object in the run (see [RunError]). The timestamp for the failure is
61
+ * recorded under the [Run.failedAt].
62
+ */
24
63
@JsonProperty(" failed" )
25
64
FAILED (true ),
26
65
66
+ /* *
67
+ * The [Run] successfully completed! You can now view all [ThreadMessage]s
68
+ * the [Assistant] added to the [Thread], and all the steps the [Run] took.
69
+ * You can also continue the conversation by adding more [ThreadMessage]s
70
+ * to the [Thread] and creating another [Run].
71
+ */
27
72
@JsonProperty(" completed" )
28
73
COMPLETED (true ),
29
74
75
+ /* *
76
+ * This happens when the function calling outputs were not submitted before
77
+ * [Run.expiresAt] and the [Run] expires. Additionally, if the runs take
78
+ * too long to execute and go beyond the time stated in [Run.expiresAt],
79
+ * OpenAI's systems will expire the [Run].
80
+ */
30
81
@JsonProperty(" expired" )
31
82
EXPIRED (true ),
32
83
}
0 commit comments