Skip to content

Commit

Permalink
Fix/conversation rename (#34)
Browse files Browse the repository at this point in the history
* fix: fix the bug that prevents the second conversation from being renamed

* fix: add qdrant database reset prompt

Add a reset prompt for when the qdrant database encounters error.

Set the animation as a daemon thread.

* fix: stop the waiting animation for a conversation when it is deleted
  • Loading branch information
happyapplehorse authored Jan 2, 2024
1 parent 357e768 commit 480ed16
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [0.5.2] - 2023-01-02

### Fixed

- Fixed the bug that prevents the second conversation from being renamed
- Stop the waiting animation for a conversation when it is deleted

## [0.5.1] - 2023-01-02

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/gptui/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__title__ = "gptui"
__version__ = "0.5.1"
__version__ = "0.5.2"
1 change: 1 addition & 0 deletions src/gptui/data/vector_memory/qdrant_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(
gptui_logger.error(
f"An error occurred while initializing the local vector database. Database path: {url}. Error: {repr(e)} "
"Warning: Rebuilding of the vector database may be required."
"You can remove '~/.gptui/user/vector_memory_database/' to rebuild it if you are using default config."
)
else:
self._qdrantclient = QdrantClient(location=":memory:")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class ConversationService:
def __init__(self, manager):
self.gk_kernel = Kernel(manager.dot_env_config_path)
self.manager = manager

@auto_init_params("0")
@classmethod
Expand Down Expand Up @@ -43,7 +43,9 @@ def chat_context_to_string(chat_context_json_str: str) -> str:
)

chat_context = chat_context_to_string(chat_context_json_str)
make_title_function = self.gk_kernel.sk_kernel.create_semantic_function(sk_prompt, max_tokens=50)
# A new kernel must be created here, otherwise, there will be context confilicts.
gk_kernel = Kernel(self.manager.dot_env_config_path)
make_title_function = gk_kernel.sk_kernel.create_semantic_function(sk_prompt, max_tokens=50)
name = await make_title_function.invoke_async(chat_context)
name = str(name)
if name.startswith('"'):
Expand Down
1 change: 1 addition & 0 deletions src/gptui/views/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def __init__(self, animation_manager: AnimationManager, message: AnimationReques
self.animation_manager = animation_manager
self.message = message
animation_manager.priority_dict[message.displayer][self] = message.priority
self.daemon = True

def run(self) -> None:
animation = self.animation_manager.ani_links.get(self.message.ani_type)
Expand Down
17 changes: 17 additions & 0 deletions src/gptui/views/tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,7 @@ async def delete_conversation_check(self) -> None:
self.no_context_manager.no_context_chat_delete(int(old_tab_id[3:]))
return

conversation_id = int(old_tab_id[3:])
def check_dialog_handle(confirm: bool) -> None:
if confirm:
tab_mode = old_tab_id[:3]
Expand All @@ -1287,6 +1288,7 @@ def check_dialog_handle(confirm: bool) -> None:
elif tab_mode == "lxt":
self.openai.delete_group_talk_conversation(group_talk_conversation_id=int(old_tab_id[3:]))
self.chat_display.delete_buffer_id(id=int(old_tab_id[3:]))
self.post_message(AnimationRequest(ani_id=conversation_id, action="end"))
else:
return

Expand Down Expand Up @@ -1515,6 +1517,21 @@ async def app_init_process(self, init_log: RichLog) -> bool:
}
)
collections.remove(collection)
except AttributeError as e:
init_log.write(
Text(
f"An error occurred during cleaning collections. Error: {e}.\n"
"Warning: Rebulding of the vector database may be required\n"
"You can remove '~/.gptui/user/vector_memory_database/' to rebuild it if you are using default config.\n",
tc("red") or "red"
)
)
gptui_logger.error(
f"An error occurred during cleaning collections. Error: {e}."
"Warning: Rebulding of the vector database may be required"
"You can remove '~/.gptui/user/vector_memory_database/' to rebuild it if you are using default config."
)
await asyncio.sleep(1)
except Exception as e:
init_log.write(Text(f"An error occurred during cleaning collections. Error: {e}", tc("red") or "red"))
gptui_logger.error(f"An error occurred during cleaning collections. Error: {e}")
Expand Down

0 comments on commit 480ed16

Please sign in to comment.