You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: backend/agent/coding_agent.py
+44-4Lines changed: 44 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,8 @@
1
1
# import os
2
+
"""
3
+
This Python module defines the classes and functions used by the coding agent in the backend of an application. The coding agent is responsible for interacting with various components such as the database, memory management system, and external APIs to facilitate code generation, manipulation, and management tasks. It utilizes models for code generation, applies AST (Abstract Syntax Tree) operations to modify code, and manages the working context and system prompts for the user. Additionally, it handles the execution of generated code operations and integrates with external services like OpenAI and AWS for enhanced functionality.
4
+
"""
5
+
2
6
importre
3
7
importjson
4
8
importboto3
@@ -37,6 +41,7 @@ class NestedNamespace(SimpleNamespace):
37
41
"""
38
42
A class to convert a dictionary into a nested namespace.
Copy file name to clipboardExpand all lines: backend/database/my_codebase.py
+19Lines changed: 19 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,7 @@
1
+
"""
2
+
This module defines the MyCodebase class, which is responsible for managing the database operations related to codebase management. It includes functionalities such as initializing the database connection, setting up the directory to scan for code, creating necessary database tables, updating files and embeddings, and removing old files from the database. The class utilizes an external encoder (tiktoken) for encoding model specifics and interacts with the database to store and manage the codebase information efficiently.
Copy file name to clipboardExpand all lines: backend/memory/memory_manager.py
+39-6Lines changed: 39 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,7 @@
1
+
"""
2
+
This module contains the implementation of the memory management system for the backend. It includes the `WorkingContext` class, which is responsible for managing the working context of the user, including the database connection, project directory, and interaction with the OpenAI API client. The module also handles the creation of necessary database tables and provides methods for managing the working context data within the database. Additionally, it integrates with other components such as the system prompt handler and the OpenAI API client to facilitate the generation and management of system prompts and responses.
This method queries the system prompt table for messages, filtering based on the chat_box flag. If chat_box is True, it fetches messages with a higher token limit to accommodate more verbose interactions typical in a chat interface. Otherwise, it uses the default max_tokens limit defined for the system.
170
+
171
+
Args:
172
+
chat_box (Optional[bool]): A flag indicating whether the messages are being fetched for a chat box interface. Defaults to None.
173
+
174
+
Returns:
175
+
List[dict]: A list of dictionaries, each containing the role and content of a message.
This method inserts a new message into the memory database with the provided role, content, and optional command and function response. It also calculates the timestamp, the total number of tokens in the message, and optionally summarizes the message if the number of tokens exceeds a certain threshold.
253
+
254
+
Args:
255
+
role (str): The role of the message sender (e.g., "user" or "assistant").
256
+
content (str): The content of the message.
257
+
command (Optional[str]): An optional command associated with the message.
258
+
function_response (Optional[str]): An optional function response associated with the message.
Copy file name to clipboardExpand all lines: backend/memory/system_prompt_handler.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
"""
2
-
Methods and CRUD operations for managing systemprompts.
2
+
This module contains classes and methods for handling system prompts and logging relevant information within the backend memory system. It includes a `RelevantLogHandler` class for managing logs relevant to the system's operation, focusing on error logs, and a `SystemPromptHandler` class for managing system prompts, including CRUD operations on system prompts stored in a database. These components are essential for maintaining a responsive and informed system environment, aiding in debugging and user interaction management.
0 commit comments