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

create a more ipythonic context manager #62

Merged
merged 4 commits into from
Mar 19, 2023
Merged

Conversation

rgbkrk
Copy link
Owner

@rgbkrk rgbkrk commented Mar 19, 2023

  1. Introduced a Context class to capture IPython history as ChatCompletion compatible messages while retaining execution count
  2. Replaced the get_historical_context function with the build_context function, which constructs the context using the new Context class.
  3. Updated %%assist to use build_context and trim down the messages based on estimated token size


if index in outputs:
context.append(craft_output_message(outputs[index]))
output = history_manager.output_hist.get(execution_counter)
Copy link
Owner Author

Choose a reason for hiding this comment

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

TIL that there exists history_manager.output_hist_reprs that we could use for the plain reprs so we don't have to compute them again.

@rgbkrk rgbkrk changed the title [WIP] create a more ipythonic context manager create a more ipythonic context manager Mar 19, 2023
@rgbkrk rgbkrk merged commit a0edd18 into main Mar 19, 2023
@rgbkrk rgbkrk deleted the rgbkrk/context-builder branch March 19, 2023 18:38
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.

None yet

1 participant