Skip to content

Commit

Permalink
Merge pull request #428 from one-some/do-not-add-bugs
Browse files Browse the repository at this point in the history
Workaround for option panel popping up too much
  • Loading branch information
henk717 authored Jul 29, 2023
2 parents e94b4b9 + b20f320 commit 276efa6
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 144 deletions.
5 changes: 5 additions & 0 deletions aiserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3836,6 +3836,10 @@ def generate(txt, minimum, maximum, found_entries=None):
# Open up token stream
emit("stream_tokens", True, broadcast=True, room="UI_2")

# HACK: Show options when streaming more than 1 sequence
if utils.koboldai_vars.output_streaming:
koboldai_vars.actions.show_options(koboldai_vars.numseqs > 1, force=True)

koboldai_vars.generated_tkns = 0

if(found_entries is None):
Expand Down Expand Up @@ -6100,6 +6104,7 @@ def UI_2_Set_Selected_Text(data):
@socketio.on('Use Option Text')
@logger.catch
def UI_2_Use_Option_Text(data):
koboldai_vars.actions.show_options(False)
if koboldai_vars.prompt == "":
koboldai_vars.prompt = koboldai_vars.actions.get_current_options()[int(data['option'])]['text']
koboldai_vars.actions.clear_unused_options()
Expand Down
24 changes: 19 additions & 5 deletions koboldai_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1756,11 +1756,15 @@ def toggle_pin(self, action_step, option_number):

def go_forward(self):
action_step = self.action_count+1
if action_step in self.actions:
if len(self.get_current_options()) == 1:
logger.warning("Going forward with this text: {}".format(self.get_current_options()[0]["text"]))
self.use_option([x['text'] for x in self.actions[action_step]["Options"]].index(self.get_current_options()[0]["text"]))

if action_step not in self.actions:
return

self.show_options(len(self.get_current_options()) > 1)

if len(self.get_current_options()) == 1:
logger.warning("Going forward with this text: {}".format(self.get_current_options()[0]["text"]))
self.use_option([x['text'] for x in self.actions[action_step]["Options"]].index(self.get_current_options()[0]["text"]))

def use_option(self, option_number, action_step=None):
if action_step is None:
action_step = self.action_count+1
Expand Down Expand Up @@ -1798,6 +1802,16 @@ def delete_option(self, option_number, action_step=None):
process_variable_changes(self._socketio, "story", 'actions', {"id": action_step, 'action': self.actions[action_step]}, None)
self.set_game_saved()

def show_options(
self,
should_show: bool,
force: bool = False,

) -> None:
if self._koboldai_vars.aibusy and not force:
return
self._socketio.emit("show_options", should_show, broadcast=True, room="UI_2")

def delete_action(self, action_id, keep=True):
if action_id in self.actions:
old_options = copy.deepcopy(self.actions[action_id]["Options"])
Expand Down
42 changes: 21 additions & 21 deletions static/koboldai.css
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ body {
grid-template-columns: 30px auto 30% 30px;
grid-template-rows: auto min-content min-content 100px;
}
.main-grid[option_length="0"][model_numseqs="1"] {
.main-grid[hide-options="true"] {
grid-template-columns: 30px auto 0px 30px;
}

Expand Down Expand Up @@ -1613,39 +1613,39 @@ body {
font-style: italic;
}

.sequence_area {
#option-container {
margin-top: 10px;
grid-area: options;
background-color: var(--sequence_area_background);
overflow-y: scroll;
}

.sequence_area::-webkit-scrollbar {
#option-container::-webkit-scrollbar {
display: none;
}

@media only screen and (max-aspect-ratio: 7/5) {
.sequences {
margin-top: 5px;
width: 100%;
border: 0px;
border-spacing: 0;
display: flex;
flex-direction: row;
overflow-x: scroll;
scroll-snap-type: x mandatory;
}
#option-container {
margin-top: 5px;
width: 100%;
border: 0px;
border-spacing: 0;
display: flex;
flex-direction: row;
overflow-x: scroll;
scroll-snap-type: x mandatory;
}
}

@media only screen and (min-aspect-ratio: 7/5) {
.sequences {
margin-top: 5px;
width: 100%;
border: 0px;
border-spacing: 0;
display: flex;
flex-direction: column;
}
#option-container {
margin-top: 5px;
width: 100%;
border: 0px;
border-spacing: 0;
display: flex;
flex-direction: column;
}
}

.sequence_row {
Expand Down
Loading

0 comments on commit 276efa6

Please sign in to comment.