@@ -2,20 +2,25 @@ package com.cjcrafter.openai.threads
22
33import com.cjcrafter.openai.threads.message.MessageHandler
44import com.cjcrafter.openai.threads.runs.RunHandler
5+ import org.jetbrains.annotations.Contract
56
67/* *
7- * Handles all API requests involving the [Thread] object (not to be confused
8- * with [java.lang.Thread]).
8+ * Handler used to interact with a [Thread] objects.
99 */
1010interface ThreadHandler {
1111
1212 /* *
1313 * Creates a new empty thread.
14+ *
15+ * @return The created thread
1416 */
1517 fun create (): Thread = create(createThreadRequest { /* intentionally empty */ })
1618
1719 /* *
1820 * Creates a new thread with the given options.
21+ *
22+ * @param request The values of the thread to create
23+ * @return The created thread
1924 */
2025 fun create (request : CreateThreadRequest ): Thread
2126
@@ -25,12 +30,20 @@ interface ThreadHandler {
2530 * This method returns a new thread object wrapper. The thread parameter is
2631 * used only for [Thread.id]. This method is useful for getting updated
2732 * information about a thread's status or values.
33+ *
34+ * @param thread The thread to retrieve
35+ * @return The retrieved thread
2836 */
37+ @Contract(pure = true )
2938 fun retrieve (thread : Thread ): Thread = retrieve(thread.id)
3039
3140 /* *
3241 * Retrieves the thread with the given id.
42+ *
43+ * @param id The id of the thread to retrieve
44+ * @return The retrieved thread
3345 */
46+ @Contract(pure = true )
3447 fun retrieve (id : String ): Thread
3548
3649 /* *
@@ -39,6 +52,9 @@ interface ThreadHandler {
3952 * You should **always** check the deletion status to ensure the thread was
4053 * deleted successfully. After confirming deletion, you should discard all
4154 * of your references to the thread, since they are now invalid.
55+ *
56+ * @param thread The thread to delete
57+ * @return The deletion status
4258 */
4359 fun delete (thread : Thread ): ThreadDeletionStatus = delete(thread.id)
4460
@@ -48,6 +64,9 @@ interface ThreadHandler {
4864 * You should **always** check the deletion status to ensure the thread was
4965 * deleted successfully. After confirming deletion, you should discard all
5066 * of your references to the thread, since they are now invalid.
67+ *
68+ * @param id The id of the thread to delete
69+ * @return The deletion status
5170 */
5271 fun delete (id : String ): ThreadDeletionStatus
5372
@@ -57,6 +76,10 @@ interface ThreadHandler {
5776 * This method returns a new thread object wrapper. The thread parameter is
5877 * used only for [Thread.id]. After this request, you should discard all of
5978 * your references to the thread, since they are now outdated.
79+ *
80+ * @param thread The thread to modify
81+ * @param request The values to update the thread with
82+ * @return The modified thread
6083 */
6184 fun modify (thread : Thread , request : ModifyThreadRequest ): Thread = modify(thread.id, request)
6285
@@ -65,26 +88,48 @@ interface ThreadHandler {
6588 *
6689 * This method returns a new thread object wrapper. After this request, you
6790 * should discard your references to the thread, since they are now outdated.
91+ *
92+ * @param id The id of the thread to modify
93+ * @param request The values to update the thread with
94+ * @return The modified thread
6895 */
6996 fun modify (id : String , request : ModifyThreadRequest ): Thread
7097
7198 /* *
72- * Returns a handler for the messages endpoint for the given thread.
99+ * Returns a handler for interacting with the messages in the given thread.
100+ *
101+ * @param thread The thread to get the messages for
102+ * @return The handler for interacting with the messages
73103 */
104+ @Contract(pure = true )
74105 fun messages (thread : Thread ): MessageHandler = messages(thread.id)
75106
76107 /* *
77- * Returns a handler for the messages endpoint for the thread with the given id.
108+ * Returns a handler for interacting with the messages in the thread with
109+ * the given id.
110+ *
111+ * @param threadId The id of the thread to get the messages for
112+ * @return The handler for interacting with the messages
78113 */
114+ @Contract(pure = true )
79115 fun messages (threadId : String ): MessageHandler
80116
81117 /* *
82- * Returns a handler for the runs endpoint for the given thread.
118+ * Returns a handler for interacting with the runs in the given thread.
119+ *
120+ * @param thread The thread to get the runs for
121+ * @return The handler for interacting with the runs
83122 */
123+ @Contract(pure = true )
84124 fun runs (thread : Thread ): RunHandler = runs(thread.id)
85125
86126 /* *
87- * Returns a handler for the runs endpoint for the thread with the given id.
127+ * Returns a handler for interacting with the runs in the thread with
128+ * the given id.
129+ *
130+ * @param threadId The id of the thread to get the runs for
131+ * @return The handler for interacting with the runs
88132 */
133+ @Contract(pure = true )
89134 fun runs (threadId : String ): RunHandler
90135}
0 commit comments