Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rewind to user message #30

Merged
merged 7 commits into from
Sep 9, 2024
Merged

Conversation

lukealvoeiro
Copy link
Collaborator

  • Removes retry logic from Exchange.generate, as this may result in undefined behavior
  • Adds a rewind_to_last_user_message method on the Exchange

Copy link
Collaborator

@baxen baxen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

except HTTPStatusError as e:
# in the future, if models are hosted on machines we may need to add
# other types of exceptions here
raise FailedToGenerateMessageError(f"Failed to generate message: {e}") from e
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest leaving this as the original HTTP Status Error? that has more actionable information when caught downstream or for debugging (like the request etc)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I figured we might want to handle all generate errors similarly, but not attached to it.

@@ -337,6 +319,19 @@ def prepend_checkpointed_message(self, message: Message, token_count: int) -> No
)
self.checkpoint_data.message_index_offset = new_index

def rewind_to_last_user_message(self) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rewind_to sounds like the last user message is included, maybe rewind_past_

Copy link
Collaborator Author

@lukealvoeiro lukealvoeiro Sep 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼. Thinking about it a bit more, there is no other situation that you would rewind to. Thoughts on just calling it rewind?

ex.rewind_to_last_user_message()

assert len(ex.messages) == 2
assert len(ex.checkpoint_data.checkpoints) == 2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably worth also adding tool use/results into this test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@lukealvoeiro lukealvoeiro changed the title Lalvoeiro/rewind to user message feat: rewind to user message Sep 6, 2024
@lukealvoeiro lukealvoeiro merged commit 87ddd0c into main Sep 9, 2024
4 checks passed
lifeizhou-ap added a commit that referenced this pull request Sep 18, 2024
* main:
  feat: Rework error handling (#48)
  chore(release): release version 0.9.0 (#45)
  chore: add just command for releases and update pyproject for changelog (#43)
  feat: convert ollama provider to an openai configuration (#34)
  fix: Bedrock Provider request (#29)
  test: Update truncate and summarize tests to check for sytem prompt t… (#42)
  chore: update test_tools to read a file instead of get a password (#38)
  fix: Use placeholder message to check tokens (#41)
  feat: rewind to user message (#30)
  chore: Update LICENSE (#40)
  fix: shouldn't hardcode truncate to gpt4o mini (#35)
codefromthecrypt pushed a commit to codefromthecrypt/exchange that referenced this pull request Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants