mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-21 02:11:29 +00:00
fix: personas settings state
This commit is contained in:
parent
88b6d112f8
commit
487fe81692
3 changed files with 26 additions and 7 deletions
|
|
@ -569,7 +569,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
[2.8.4-223]: https://github.com/carlrobertoh/CodeGPT/compare/v2.8.3-223...v2.8.4-223
|
||||
[2.8.3-223]: https://github.com/carlrobertoh/CodeGPT/compare/v2.8.2-233...v2.8.3-223
|
||||
[2.8.2-223]: https://github.com/carlrobertoh/CodeGPT/compare/v2.8.1-223...v2.8.2-223
|
||||
[2.8.2-233]: https://github.com/carlrobertoh/CodeGPT/compare/v2.8.1-223...v2.8.2-233
|
||||
[2.8.1-223]: https://github.com/carlrobertoh/CodeGPT/compare/v2.8.0-223...v2.8.1-223
|
||||
[2.8.0-223]: https://github.com/carlrobertoh/CodeGPT/compare/v2.7.1-223...v2.8.0-223
|
||||
[2.7.1-223]: https://github.com/carlrobertoh/CodeGPT/compare/v2.7.0-223...v2.7.1-223
|
||||
|
|
|
|||
|
|
@ -105,7 +105,13 @@ class PersonasSettingsForm {
|
|||
}
|
||||
|
||||
userCreatedPersonas.removeIf { removedItemIds.contains(it.id) }
|
||||
userCreatedPersonas.addAll(addedItems.map { it.toPersonaDetailsState() })
|
||||
userCreatedPersonas.forEach {
|
||||
if (it.id == persona?.id) {
|
||||
it.name = persona.name
|
||||
it.instructions = persona.instructions
|
||||
}
|
||||
}
|
||||
userCreatedPersonas.addAll(findMatchingRows(addedItems.map { it.id }).map { it.toPersonaDetailsState() })
|
||||
}
|
||||
clear()
|
||||
}
|
||||
|
|
@ -154,8 +160,7 @@ class PersonasSettingsForm {
|
|||
}
|
||||
|
||||
private fun createNewPersona(name: String, prompt: String): PersonaDetails {
|
||||
val newId = findMaxId() + 1
|
||||
return PersonaDetails(newId, name, prompt)
|
||||
return PersonaDetails(findMaxId() + 1, name, prompt)
|
||||
}
|
||||
|
||||
private fun addPersonaToTable(persona: PersonaDetails) {
|
||||
|
|
@ -209,7 +214,7 @@ class PersonasSettingsForm {
|
|||
index
|
||||
)
|
||||
}
|
||||
ResourceUtil.getFilteredPersonaSuggestions().forEachIndexed { index, persona ->
|
||||
ResourceUtil.getDefaultPersonas().forEachIndexed { index, persona ->
|
||||
tableModel.addPersonaRow(persona, selectedPersona.id, index, true)
|
||||
}
|
||||
}
|
||||
|
|
@ -285,4 +290,19 @@ class PersonasSettingsForm {
|
|||
addedItems.clear()
|
||||
removedItemIds.clear()
|
||||
}
|
||||
|
||||
private fun findMatchingRows(ids: List<Long>): List<PersonaDetails> {
|
||||
val matchingRows = mutableListOf<PersonaDetails>()
|
||||
|
||||
for (rowIndex in 0 until tableModel.rowCount) {
|
||||
val personaId = tableModel.getValueAt(rowIndex, 0) as Long
|
||||
if (ids.contains(personaId)) {
|
||||
val name = tableModel.getValueAt(rowIndex, 1) as String
|
||||
val instructions = tableModel.getValueAt(rowIndex, 2) as String
|
||||
matchingRows.add(PersonaDetails(personaId, name, instructions))
|
||||
}
|
||||
}
|
||||
|
||||
return matchingRows
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ object ResourceUtil {
|
|||
fun getFilteredPersonaSuggestions(
|
||||
filterPredicate: ((PersonaDetails) -> Boolean)? = null
|
||||
): List<SuggestionItem> {
|
||||
var personaDetails = getFilteredPersonaSuggestions()
|
||||
var personaDetails = getDefaultPersonas()
|
||||
if (filterPredicate != null) {
|
||||
personaDetails = personaDetails.filter(filterPredicate).toMutableList()
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ object ResourceUtil {
|
|||
.take(10) + listOf(SuggestionItem.ActionItem(DefaultAction.CREATE_NEW_PERSONA))
|
||||
}
|
||||
|
||||
fun getFilteredPersonaSuggestions(): MutableList<PersonaDetails> {
|
||||
fun getDefaultPersonas(): MutableList<PersonaDetails> {
|
||||
return ObjectMapper().readValue(
|
||||
getResourceContent("/prompts.json"),
|
||||
object : TypeReference<MutableList<PersonaDetails>>() {})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue