From 4bdb8ce8d61ed046c0685d23fa883ce6e379089d Mon Sep 17 00:00:00 2001 From: Ted Benson Date: Fri, 6 Oct 2023 12:31:12 -0400 Subject: [PATCH] bugfix: ChatHistory -- skip embedding whitespace-only text (#577) (Noticed this causing failures with some of the game code.) --- src/steamship/agents/schema/chathistory.py | 10 ++++++++-- src/steamship/cli/cli.py | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/steamship/agents/schema/chathistory.py b/src/steamship/agents/schema/chathistory.py index cad7fdbf..cf99602c 100644 --- a/src/steamship/agents/schema/chathistory.py +++ b/src/steamship/agents/schema/chathistory.py @@ -153,7 +153,10 @@ def append_message_with_role( block, kind=TagKind.CHAT, name=ChatTag.CHUNK ) block.tags.extend(chunk_tags) - self.embedding_index.insert(chunk_tags) + + # Only embed tags that aren't empty space. + non_empty_chunk_tags = [tag for tag in chunk_tags if tag.text.strip()] + self.embedding_index.insert(non_empty_chunk_tags) return block def append_user_message( @@ -268,7 +271,10 @@ def delete_messages(self, selector: MessageSelector): # TODO(dougreid): figure out why tag.text gets lost. if not tag.text: tag.text = msg.text[tag.start_idx : tag.end_idx] - self.embedding_index.insert(tag) + + # Only embed it if we've managed to generate a string representation. + if tag.text and tag.text.strip(): + self.embedding_index.insert(tag) self.refresh() diff --git a/src/steamship/cli/cli.py b/src/steamship/cli/cli.py index 71252fde..a475469d 100644 --- a/src/steamship/cli/cli.py +++ b/src/steamship/cli/cli.py @@ -330,7 +330,10 @@ def serve_local( # noqa: C901 # 2. The public_api_url should still be NGROK, not the Proxy. The local server emulates the Proxy and # the Proxy blocks this kind of development traffic. - public_api_url = ngrok_api_url + public_api_url = ( + f"https://{user.handle}.steamship.run/{workspace}/{registered_instance.handle}/" + ) + click.secho(f"🌎 Public API: {public_api_url}") # Start the local API Server. This has to happen after NGROK because the port & url need to be plummed.