Skip to content

Commit

Permalink
conversation can now be deleted from the list
Browse files Browse the repository at this point in the history
Signed-off-by: pengzhile <[email protected]>
  • Loading branch information
pengzhile committed Feb 21, 2023
1 parent 7dd572c commit b82c231
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.0
0.2.1
20 changes: 17 additions & 3 deletions src/pandora/bots/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def __process_command(self, command):
self.__print_access_token()
elif '/cls' == command or '/clear' == command:
self.__clear_screen()
elif '/help' == command or 'usage' == command or '/?' == command:
else:
self.__print_usage()

@staticmethod
Expand All @@ -120,7 +120,9 @@ def __print_access_token(self):

def __clear_screen(self):
Console.clear()
self.__print_conversation_title(self.state.title)

if self.state:
self.__print_conversation_title(self.state.title)

def __new_conversation(self):
self.state = State(model_slug=self.__choice_model()['slug'])
Expand All @@ -144,7 +146,7 @@ def __set_conversation_title(self, state: State):
return

if self.chatgpt.set_conversation_title(state.conversation_id, new_title):
self.state.title = new_title
state.title = new_title
Console.debug('#### Set title success.')
else:
Console.error('#### Set title failed.')
Expand Down Expand Up @@ -272,6 +274,8 @@ def __choice_conversation(self, page=1, page_size=20):
for idx, item in enumerate(items):
number = str(idx + 1)
choices.append(number)
choices.append('t' + number)
choices.append('d' + number)
Console.info(' {}. {}'.format(number, item['title']))

if not last_page:
Expand All @@ -282,6 +286,8 @@ def __choice_conversation(self, page=1, page_size=20):
choices.append('p')
Console.warn(' p. << Previous page')

Console.warn(' t?. Set title for the conversation, eg: t1')
Console.warn(' d?. Delete the conversation, eg: d1')
Console.warn(' c. ** Start new chat')

while True:
Expand All @@ -295,6 +301,14 @@ def __choice_conversation(self, page=1, page_size=20):
if 'p' == choice:
return self.__choice_conversation(page - 1, page_size)

if 't' == choice[0]:
self.__set_conversation_title(State(conversation_id=items[int(choice[1:]) - 1]['id']))
return self.__choice_conversation(page, page_size)

if 'd' == choice[0]:
self.__del_conversation(State(conversation_id=items[int(choice[1:]) - 1]['id']))
continue

return items[int(choice) - 1]

def __choice_model(self):
Expand Down

0 comments on commit b82c231

Please sign in to comment.