-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate CommandService into SparkApiClient
CommandService has been added to SparkApiClient as a parameter. This adjustment allows the application to use this service to supervise the chat flow. The chat screen was modified accordingly to instantiate SparkApiClient using CommandService. This update also increments the package version to 1.0.4.
- Loading branch information
Showing
4 changed files
with
40 additions
and
5 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
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
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/dev/coderpwh/sparkapidesk/service/CommandService.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,29 @@ | ||
package dev.coderpwh.sparkapidesk.service | ||
|
||
import androidx.compose.runtime.snapshots.SnapshotStateList | ||
import dev.coderpwh.sparkapidesk.pojo.Message | ||
import java.util.* | ||
|
||
/** | ||
* @Auther: pangwenhao | ||
* @Date: 2023/12/8 16:40 | ||
* @Description: | ||
*/ | ||
class CommandService { | ||
fun doDispatch(msgList: SnapshotStateList<Message>):Boolean { | ||
val last = msgList.last() | ||
return when (last.content) { | ||
"/clear" -> { | ||
msgList.clear() | ||
true | ||
} | ||
"/help" -> { | ||
msgList.add(Message(UUID.randomUUID().toString(),"/clear: 清空聊天记录\n/help: 帮助", Date(),"assistant")) | ||
true | ||
} | ||
else -> { | ||
false | ||
} | ||
} | ||
} | ||
} |