Skip to content

Commit

Permalink
feat: Updated backend/memory/memory_manager.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Dec 29, 2023
1 parent 08b3592 commit b11cd11
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions backend/memory/memory_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from instructor import OpenAISchema
from openai import OpenAI, AsyncOpenAI
import logging
from gensim.summarize import summarize

CLIENT = instructor.patch(AsyncOpenAI())

Expand All @@ -34,6 +35,7 @@ def __init__(self, db_connection, project_directory) -> None:
self.cur = self.conn.cursor()
self.client = CLIENT
self.project_directory = project_directory
self.turn_counter = 0
self.create_tables()

def create_tables(self) -> None:
Expand Down Expand Up @@ -93,6 +95,9 @@ def remove_context(self, context: str) -> None:
)
self.conn.commit()

def summarize_context(self):
return summarize(self.context)

def __str__(self) -> str:
return self.context

Expand Down Expand Up @@ -321,6 +326,10 @@ def create_tables(self) -> None:

async def update_context(self):
ctx = self.working_context.get_context()
self.turn_counter += 1
if self.turn_counter == 5:
self.context = self.summarize_context()
self.turn_counter = 0
print("Working Context: ", ctx)
prompt = f"""
You are monitoring a conversation between an engineer and their AI Assistant.
Expand Down

0 comments on commit b11cd11

Please sign in to comment.