Skip to content

Commit

Permalink
bugfix: ChatHistory -- skip embedding whitespace-only text (#577)
Browse files Browse the repository at this point in the history
(Noticed this causing failures with some of the game code.)
  • Loading branch information
eob authored Oct 6, 2023
1 parent 436f6fb commit 4bdb8ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/steamship/agents/schema/chathistory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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()

Expand Down
5 changes: 4 additions & 1 deletion src/steamship/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 4bdb8ce

Please sign in to comment.