MittaAI / webwright

An AI powered shell for building, deploying, and running software.
MIT License
31 stars 2 forks source link

Implement Code Scrubbing for Conversation History #44

Open kordless opened 1 month ago

kordless commented 1 month 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