MittaAI / webwright

Webwright is an AI-powered terminal emulator that lives within your OS. It eliminates time spent on repetitive tasks, conjures code, summons software, and bends the OS to its will. Are you ready to release the ghost in your shell?
MIT License
31 stars 2 forks source link

Implement Code Scrubbing for Conversation History #44

Open kordless opened 3 months ago

kordless commented 3 months ago

Description

To save on token usage, we need to implement a method for scrubbing code snippets from the conversation history. The conversation history can grow large over time, particularly with LLM responses that include code. By identifying and removing old or unnecessary code snippets, we can reduce the token usage in subsequent LLM calls.

Observations from lib/aifunc.py and webwright/main.py

Relevant Code from lib/aifunc.py

This file encompasses functions to call AI models, handle function execution requests, and process chat completion requests from different APIs (OpenAI and Anthropic). It tracks and processes conversation history, which may include code responses from the LLMs.

Relevant Code from webwright/main.py

This file establishes the main entry point of the application, maintains the main event loop, handles user prompts, and processes AI responses. The conversation history is built and maintained here, with each LLM response appended to the history, potentially growing large over time.

Tasks

Benefits