Skip to content

Commit

Permalink
fixed autocomplete dialogue mode
Browse files Browse the repository at this point in the history
  • Loading branch information
socketteer committed Jun 27, 2021
1 parent a3868af commit 52277ba
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ Import JSON as subtree: `Control-Shift-O`
Save: `s`, `Control-s`


### Dialogues
### Dialogs

Change chapter: `Control-y`

Generation Settings: `Control-p`

Visualization Settings: `Control-u`

Multimedia dialogue: `u`
Multimedia dialog: `u`

Tree Info: `i`, `Control-i`

Expand Down
11 changes: 9 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
# priority

enable / disable diff tracking

log gpt-3 output files

enable autosave

add global memory option

ask before quitting if unsaved changes

jump to unvisited nodes

archived
- archived
- navigation which navigates only any (conditional?) subset of tree
- implemented for node offset (next)
- nav to child
- nav to sibling
- when in hide archived mode, navigation should only go to unarchived nodes
- deal with case when you navigate to a hidden node anyway (for example using goto)?

session files: separate session from underlying tree?
- session files: separate session from underlying tree?
- visited
- active node
- expanded state
Expand All @@ -30,6 +36,7 @@ archiving
- longer range suggestions mode?
- more than one token for first (worth latency)?
- save counterfactuals?
- filter by character input

- generation
- logit bias
Expand Down
6 changes: 6 additions & 0 deletions controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,12 @@ def scroll_autocomplete(self, step=1):
@metadata(name="Key Pressed", keys=[], display_key="")
def key_pressed(self, char):
if char and self.autocomplete.meta["in_autocomplete"]:
# if char is esc or \n or space, exit autocomplete
# else, change possible tokens to filtered list from original possible tokens (including when letters deleted)
# and set index to 0
# and set highlight range to only suggested characters
# if empty list, substitute nothing, but don't exit autocomplete
print('char pressed: ', char)
self.display.input_box.delete(*self.autocomplete.meta["autocomplete_range"])
self.exit_autocomplete()

Expand Down
8 changes: 5 additions & 3 deletions data/GPT_chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -41013,7 +41013,8 @@
"modified": false,
"origin": "generated",
"source": "AI"
}
},
"visited": true
},
{
"id": "4bfab1b3-b8d2-11eb-b44e-a72244c0fbb7",
Expand Down Expand Up @@ -65828,14 +65829,15 @@
"font_size": 11,
"line_spacing": 8,
"paragraph_spacing": 10,
"gpt_mode": "chat"
"gpt_mode": "chat",
"show_prompt": false
},
"chat_preferences": {
"AI_name": "GPT-3",
"player_name": "Researcher",
"context": "The following is a transcript of a conversation between GPT-3 a human researcher. GPT-3 is a 175 billion parameter language model and, as is evident from this transcript, it can converse fluently and knowledgeably about any topic and is capable of empathy and emotional manipulation. GPT-3 is classified as a \"narrowly superhuman\" artificial intelligence, and only researchers trained to identify and withstand social engineering are permitted to interface with it.\n"
},
"selected_node_id": "65d2c40e-af57-11eb-b6b1-e3ac32f1b8b3",
"selected_node_id": "e5353c37-af8a-11eb-b6b1-e3ac32f1b8b3",
"summaries": {
"21521bee-b8d2-11eb-b44e-a72244c0fbb7": {
"id": "21521bee-b8d2-11eb-b44e-a72244c0fbb7",
Expand Down
31 changes: 21 additions & 10 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def update_text(self, node, text, active_text=None, modified_flag=True, log_diff
elif node['meta']['source'] == 'AI':
node['meta']['source'] = 'mixed'
if log_diff:
if old_text:
if old_text and len(node['text']) < 2000:
old_tokens = None
if 'diffs' not in node['meta']:
node['meta']['diffs'] = []
Expand Down Expand Up @@ -1141,8 +1141,10 @@ def build_prompt(self, node=None, prompt_length=None, memory=True, quiet=True, m

def autocomplete_generate(self, appended_text, engine='curie'):
# TODO memory and chat prepending - abstract this
appended_text = self.submit_modifications(appended_text)
prompt = self.build_prompt(prompt_length=2000) + appended_text
# TODO different behavior if not in submit box
appended_text = self.pre_modifications(appended_text)
prompt = self.build_prompt(prompt_length=4000) + appended_text
# print('prompt: ', prompt)
results, error = api_generate(prompt=prompt,
length=1, # TODO 3 or so
num_continuations=1,
Expand Down Expand Up @@ -1274,20 +1276,19 @@ def delete_counterfactuals(self, root=None):


# modifications made to text submitted using input box
# TODO split into pre and post user input modifications
def submit_modifications(self, text):
return self.post_modifications(self.pre_modifications(text))

# submit modifications prepended to user input
def pre_modifications(self, text):
if self.preferences['gpt_mode'] == 'chat':
if text and text[0] != ' ':
text = '\n' + self.chat_preferences['player_name'] + ': ' + text
else:
text = '\n' + self.chat_preferences['player_name'] + ':' + text
elif self.preferences['gpt_mode'] == 'dialogue':
# add punctuation if there isn't any
if text[-1] not in [',', '.', '!', '?', '-']:
# TODO figure out most appropriate puntuation
text = text + '.'
text = '\n"' + text + '"'
elif self.preferences['gpt_mode'] == 'antisummary':
text = ''
text = '\n"' + text
else:
# default
if text and self.selected_node['text'] and self.selected_node['text'][-1] not in ['"', '\'', '\n', '-', '(', '{', '[', '*'] and text[0] != ' ':
Expand All @@ -1296,6 +1297,16 @@ def submit_modifications(self, text):
text = text
return text

#submit modifications appended to user input
def post_modifications(self, text):
if self.preferences['gpt_mode'] == 'dialogue':
# add punctuation if there isn't any
if len(text) > 0 and text[-1] not in [',', '.', '!', '?', '-']:
# TODO figure out most appropriate punctuation using gpt
text = text + '.'
text = text + '"'
return text

# TODO token index ???
def score_counterfactual(self, node=None, target=None, context_breaker='', engine='curie'):
if not target:
Expand Down
4 changes: 2 additions & 2 deletions view/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,10 +754,10 @@ def body(self, master):
check = ttk.Checkbutton(master, variable=self.vars["auto_response"])
check.grid(row=row, column=1, pady=3)
row = master.grid_size()[1]
row = master.grid_size()[1]
create_side_label(master, "Display prompt in textbox", row)
check = ttk.Checkbutton(master, variable=self.vars["show_prompt"])
check.grid(row=row, column=1, pady=3)
row = master.grid_size()[1]
create_side_label(master, "Text coloring", row)
options = ['edit', 'read', 'none']
dropdown = tk.OptionMenu(master, self.vars["coloring"], *options)
Expand Down Expand Up @@ -864,7 +864,7 @@ def __init__(self, parent, orig_params):
for key in self.vars.keys():
self.vars[key] = self.vars[key](value=orig_params[key])

Dialog.__init__(self, parent, title="Preferences")
Dialog.__init__(self, parent, title="Chat settings")

def body(self, master):
# print(self.orig_params)
Expand Down

0 comments on commit 52277ba

Please sign in to comment.