Skip to content

Commit

Permalink
Fixed crash with empty Stop Token string
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmicEventHorizon committed Aug 11, 2023
1 parent 8db74a1 commit b0fadc8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions app/src/main/java/com/pirouette/chibichat/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ class MainActivity : AppCompatActivity() {
subStringArray.clear()
var tmp = ""
stopToken = stopToken + ",";
subString = subString + ",";
if(subString != "") {
subString = subString + ",";
}
for (charIndex in stopToken.indices) {
if (stopToken[charIndex] == ',') {
stopTokenArray.add(tmp)
Expand Down Expand Up @@ -116,8 +118,10 @@ class MainActivity : AppCompatActivity() {
val jsonIndex = jsonResult.getJSONObject(0)
val jsonText = jsonIndex.get("text")
result = jsonText.toString()
for (item in subStringArray){
result = result.substringBefore(item)
if (subStringArray.isNotEmpty() && subStringArray.size>0) {
for (item in subStringArray) {
result = result.substringBefore(item)
}
}
addMessage(result)
promptsList = promptsList + result
Expand Down

0 comments on commit b0fadc8

Please sign in to comment.