Skip to content

Commit

Permalink
Use task types for create operation
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Dec 4, 2024
1 parent 4dcde7b commit fab1e27
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ import com.nextcloud.common.NextcloudClient
import com.nextcloud.operations.PostMethod
import com.owncloud.android.lib.common.operations.RemoteOperation
import com.owncloud.android.lib.common.operations.RemoteOperationResult
import com.owncloud.android.lib.resources.assistant.model.TaskTypeData
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody.Companion.toRequestBody
import org.apache.commons.httpclient.HttpStatus

class CreateTaskRemoteOperation(private val input: String, private val type: String) :
class CreateTaskRemoteOperation(private val input: String, private val taskType: TaskTypeData) :
RemoteOperation<Void>() {
override fun run(client: NextcloudClient): RemoteOperationResult<Void> {
val inputField = hashMapOf("input" to input)

val requestBody =
hashMapOf(
"input" to inputField,
"type" to type,
"type" to taskType.id,
"appId" to "assistant",
"customId" to ""
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,31 @@ package com.owncloud.android.lib.resources.assistant.model

import com.google.gson.annotations.SerializedName

enum class TaskIds(val id: String) {
GenerateText("core:text2text"),
ExtractTopics("core:text2text:topics"),
GenerateHeadline("core:text2text:headline"),
Summarize("core:text2text:summary")
}
private const val generateTextId = "core:text2text"
private const val extractTopicsId = "core:text2text:topics"
private const val generateHeadlineId = "core:text2text:headline"
private const val summarizeId = "core:text2text:summary"

data class TaskTypes(val types: TaskType)

data class TaskType(
@SerializedName("core:text2text")
val generateText: GenerateText,
@SerializedName("core:text2text:topics")
val extractTopics: ExtractTopics,
@SerializedName("core:text2text:headline")
val generateHeadline: GenerateHeadline,
@SerializedName("core:text2text:summary")
val summarize: Summarize
@SerializedName(generateTextId)
val generateText: TaskTypeData,
@SerializedName(extractTopicsId)
val extractTopics: TaskTypeData,
@SerializedName(generateHeadlineId)
val generateHeadline: TaskTypeData,
@SerializedName(summarizeId)
val summarize: TaskTypeData
)

data class GenerateText(val name: String, val description: String)

data class ExtractTopics(val name: String, val description: String)
data class TaskTypeData(val id: String?, val name: String?, val description: String?)

data class GenerateHeadline(val name: String, val description: String)

data class Summarize(val name: String, val description: String)
fun TaskTypes.toTaskTypeDataList(): List<TaskTypeData> {
return listOf(
types.generateText to generateTextId,
types.extractTopics to extractTopicsId,
types.generateHeadline to generateHeadlineId,
types.summarize to summarizeId
).map { (taskData, id) -> taskData.copy(id = taskData.id ?: id) }
}

0 comments on commit fab1e27

Please sign in to comment.