dataguy.ContextManager¶
- class ContextManager(max_code_history=100)[source]¶
- Tracks a concise Python execution context for LLM prompts:
Non-private module imports
Relevant variables (DataFrames, arrays, primitives, lists, dicts)
Recent executed code history
Methods
__init__([max_code_history])add_code(code)Appends executed code lines to history (up to max length).
get_context_summary()Returns a markdown-like summary:
update_from_globals(globals_dict)Rebuilds the context from the given globals dictionary, keeping only non-private modules and meaningful variables.