-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,149 additions
and
53 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
96 changes: 96 additions & 0 deletions
96
openai-client/src/commonMain/kotlin/com.aallam.openai.client/Messages.kt
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,96 @@ | ||
package com.aallam.openai.client | ||
|
||
import com.aallam.openai.api.core.SortOrder | ||
import com.aallam.openai.api.file.FileId | ||
import com.aallam.openai.api.message.Message | ||
import com.aallam.openai.api.message.MessageFile | ||
import com.aallam.openai.api.message.MessageId | ||
import com.aallam.openai.api.message.MessageRequest | ||
import com.aallam.openai.api.thread.ThreadId | ||
|
||
/** | ||
* Create messages within threads | ||
*/ | ||
public interface Messages { | ||
|
||
/** | ||
* Create a message. | ||
* | ||
* @param threadId the identifier of the thread | ||
* @param message message creation request | ||
*/ | ||
public suspend fun message(threadId: ThreadId, message: MessageRequest): Message | ||
|
||
/** | ||
* Retrieve a message. | ||
* | ||
* @param threadId the identifier of the thread | ||
* @param messageId the identifier of the message | ||
*/ | ||
public suspend fun message(threadId: ThreadId, messageId: MessageId): Message | ||
|
||
/** | ||
* Modify a message. | ||
* | ||
* @param threadId the identifier of the thread | ||
* @param messageId the identifier of the message | ||
* @param metadata set of 16 key-value pairs that can be attached to an object. | ||
* This can be useful for storing additional information about the object in a structured format. | ||
* Keys can be a maximum of 64 characters long, and values can be a maximum of 512 characters long. | ||
*/ | ||
public suspend fun message(threadId: ThreadId, messageId: MessageId, metadata: Map<String, String>? = null): Message | ||
|
||
/** | ||
* Returns a list of messages for a given thread. | ||
* | ||
* @param threadId the identifier of the thread | ||
* @param limit a limit on the number of objects to be returned. | ||
* The Limit can range between 1 and 100, and the default is 20. | ||
* @param order sort order by the `created_at` timestamp of the objects. | ||
* @param after a cursor for use in pagination. [after] is an object ID that defines your place in the list. | ||
* For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call | ||
* can include `after = MessageId("obj_foo")` in order to fetch the next page of the list. | ||
* @param before a cursor for use in pagination. [before] is an object ID that defines your place in the list. | ||
* For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call | ||
* can include `before = MessageId("obj_foo")` in order to fetch the previous page of the list. | ||
*/ | ||
public suspend fun messages( | ||
threadId: ThreadId, | ||
limit: Int? = null, | ||
order: SortOrder? = null, | ||
after: MessageId? = null, | ||
before: MessageId? = null, | ||
): List<Message> | ||
|
||
/** | ||
* Retrieves a message file. | ||
* | ||
* @param threadId the ID of the thread to which the message and File belong | ||
* @param messageId the ID of the message the file belongs to | ||
* @param fileId the ID of the file being retrieved | ||
*/ | ||
public suspend fun messageFile(threadId: ThreadId, messageId: MessageId, fileId: FileId): MessageFile | ||
|
||
/** | ||
* Returns a list of message files. | ||
* | ||
* @param threadId the ID of the thread to which the message and File belong to | ||
* @param messageId the ID of the message the file belongs to | ||
* @param limit a limit on the number of objects to be returned | ||
* @param order sort order by the `created_at` timestamp of the objects | ||
* @param after a cursor for use in pagination. [after] is an object ID that defines your place in the list. | ||
* For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call | ||
* can include `after = FileId("obj_foo")` in order to fetch the next page of the list. | ||
* @param before a cursor for use in pagination. [before] is an object ID that defines your place in the list. | ||
* For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call | ||
* can include `before = FileId("obj_foo")` in order to fetch the previous page of the list. | ||
*/ | ||
public suspend fun messageFiles( | ||
threadId: ThreadId, | ||
messageId: MessageId, | ||
limit: Int? = null, | ||
order: SortOrder? = null, | ||
after: FileId? = null, | ||
before: FileId? = null, | ||
) | ||
} |
111 changes: 111 additions & 0 deletions
111
openai-client/src/commonMain/kotlin/com.aallam.openai.client/Runs.kt
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,111 @@ | ||
package com.aallam.openai.client | ||
|
||
import com.aallam.openai.api.core.SortOrder | ||
import com.aallam.openai.api.core.Status | ||
import com.aallam.openai.api.run.* | ||
import com.aallam.openai.api.thread.ThreadId | ||
|
||
/** | ||
* Represents an execution run on a thread. | ||
*/ | ||
public interface Runs { | ||
|
||
/** | ||
* Create a run. | ||
* | ||
* @param threadId The ID of the thread to run | ||
* @param request request for a run | ||
* | ||
*/ | ||
public suspend fun createRun(threadId: ThreadId, request: RunRequest): Run | ||
|
||
/** | ||
* Retrieves a run. | ||
* | ||
* @param threadId The ID of the thread to run | ||
* @param runId The ID of the run to retrieve | ||
*/ | ||
public suspend fun retrieveRun(threadId: ThreadId, runId: String): Run | ||
|
||
/** | ||
* Retrieves a run. | ||
* | ||
* @param threadId the ID of the thread to run | ||
* @param runId the ID of the run to retrieve | ||
* @param metadata set of 16 key-value pairs that can be attached to an object. | ||
* This can be useful for storing additional information about the object in a structured format. | ||
* Keys can be a maximum of 64 characters long, and values can be a maximum of 512 characters long. | ||
*/ | ||
public suspend fun modifyRun(threadId: ThreadId, runId: String, metadata: Map<String, String>? = null): Run | ||
|
||
/** | ||
* Returns a list of runs belonging to a thread. | ||
* | ||
* @param threadId the ID of the thread the run belongs to | ||
* @param order sort order by the `created_at` timestamp of the objects. | ||
* @param after a cursor for use in pagination. [after] is an object ID that defines your place in the list. | ||
* For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call | ||
* can include `after = RunId("obj_foo")` in order to fetch the next page of the list. | ||
* @param before a cursor for use in pagination. [before] is an object ID that defines your place in the list. | ||
* For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call | ||
* can include `before = RunId("obj_foo")` in order to fetch the previous page of the list. | ||
*/ | ||
public suspend fun listRuns( | ||
threadId: ThreadId, | ||
order: SortOrder? = null, | ||
after: RunId? = null, | ||
before: RunId? = null, | ||
): List<Run> | ||
|
||
/** | ||
* When a run has the status: [Status.RequiresAction] and required action is [RequiredAction.SubmitToolOutputs], | ||
* this endpoint can be used to submit the outputs from the tool calls once they're all completed. | ||
* All outputs must be submitted in a single request. | ||
*/ | ||
public suspend fun submitToolOutput(threadId: ThreadId, runId: String, output: List<ToolOutput>): Run | ||
|
||
/** | ||
* Cancels a run that is [Status.InProgress]. | ||
* | ||
* @param threadId the ID of the thread to which this run belongs | ||
* @param runId the ID of the run to cancel | ||
*/ | ||
public suspend fun cancel(threadId: ThreadId, runId: String): Run | ||
|
||
/** | ||
* Create a thread and run it in one request. | ||
* | ||
* @param request request for a thread run | ||
*/ | ||
public suspend fun createThreadRun(request: RunRequest): Run | ||
|
||
/** | ||
* Retrieves a run step. | ||
* | ||
* @param threadId the ID of the thread to which the run and run step belongs | ||
* @param runId the ID of the run to which the run step belongs | ||
* @param stepId the ID of the run step to retrieve | ||
*/ | ||
public suspend fun getRunStep(threadId: ThreadId, runId: RunId, stepId: RunStepId): RunStep | ||
|
||
/** | ||
* Retrieves a run step. | ||
* | ||
* @param threadId the ID of the thread to which the run and run step belongs | ||
* @param runId the ID of the run to which the run step belongs | ||
* @param order sort order by the `created_at` timestamp of the objects. | ||
* @param after a cursor for use in pagination. [after] is an object ID that defines your place in the list. | ||
* For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call | ||
* can include `after = RunId("obj_foo")` in order to fetch the next page of the list. | ||
* @param before a cursor for use in pagination. [before] is an object ID that defines your place in the list. | ||
* For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call | ||
* can include `before = RunId("obj_foo")` in order to fetch the previous page of the list. | ||
*/ | ||
public suspend fun listRunSteps( | ||
threadId: ThreadId, | ||
runId: RunId, | ||
order: SortOrder? = null, | ||
after: RunStepId? = null, | ||
before: RunStepId? = null, | ||
): List<RunStep> | ||
} |
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
50 changes: 50 additions & 0 deletions
50
openai-client/src/commonMain/kotlin/com.aallam.openai.client/internal/api/MessagesApi.kt
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,50 @@ | ||
package com.aallam.openai.client.internal.api | ||
|
||
import com.aallam.openai.api.core.SortOrder | ||
import com.aallam.openai.api.file.FileId | ||
import com.aallam.openai.api.message.Message | ||
import com.aallam.openai.api.message.MessageFile | ||
import com.aallam.openai.api.message.MessageId | ||
import com.aallam.openai.api.message.MessageRequest | ||
import com.aallam.openai.api.thread.ThreadId | ||
import com.aallam.openai.client.Messages | ||
import com.aallam.openai.client.internal.http.HttpRequester | ||
|
||
internal class MessagesApi(requester: HttpRequester) : Messages { | ||
override suspend fun message(threadId: ThreadId, message: MessageRequest): Message { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun message(threadId: ThreadId, messageId: MessageId): Message { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun message(threadId: ThreadId, messageId: MessageId, metadata: Map<String, String>?): Message { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun messages( | ||
threadId: ThreadId, | ||
limit: Int?, | ||
order: SortOrder?, | ||
after: MessageId?, | ||
before: MessageId? | ||
): List<Message> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun messageFile(threadId: ThreadId, messageId: MessageId, fileId: FileId): MessageFile { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun messageFiles( | ||
threadId: ThreadId, | ||
messageId: MessageId, | ||
limit: Int?, | ||
order: SortOrder?, | ||
after: FileId?, | ||
before: FileId? | ||
) { | ||
TODO("Not yet implemented") | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
openai-client/src/commonMain/kotlin/com.aallam.openai.client/internal/api/RunsApi.kt
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,51 @@ | ||
package com.aallam.openai.client.internal.api | ||
|
||
import com.aallam.openai.api.core.SortOrder | ||
import com.aallam.openai.api.run.* | ||
import com.aallam.openai.api.thread.ThreadId | ||
import com.aallam.openai.client.Runs | ||
import com.aallam.openai.client.internal.http.HttpRequester | ||
|
||
internal class RunsApi(requester: HttpRequester) : Runs { | ||
override suspend fun createRun(threadId: ThreadId, request: RunRequest): Run { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun retrieveRun(threadId: ThreadId, runId: String): Run { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun modifyRun(threadId: ThreadId, runId: String, metadata: Map<String, String>?): Run { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun listRuns(threadId: ThreadId, order: SortOrder?, after: RunId?, before: RunId?): List<Run> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun submitToolOutput(threadId: ThreadId, runId: String, output: List<ToolOutput>): Run { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun cancel(threadId: ThreadId, runId: String): Run { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun createThreadRun(request: RunRequest): Run { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun getRunStep(threadId: ThreadId, runId: RunId, stepId: RunStepId): RunStep { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override suspend fun listRunSteps( | ||
threadId: ThreadId, | ||
runId: RunId, | ||
order: SortOrder?, | ||
after: RunStepId?, | ||
before: RunStepId? | ||
): List<RunStep> { | ||
TODO("Not yet implemented") | ||
} | ||
} |
Oops, something went wrong.