Skip to content

Commit f368f9c

Browse files
authored
Release (#34)
Release Notes: 1. **Python Version Update**: Updated the Python version used in GitHub Actions from 3.10.4 to 3.11 to leverage the latest features and improvements. 2. **Enhanced System Prompts**: Introduced a new, detailed system prompt (`DEFAULT_SYSTEM_PROMPT_V2`) for the coding agent, emphasizing logical reasoning and structured problem-solving. This update aims to improve the interaction quality by providing clearer guidance and more detailed task descriptions. 3. **Model and Configuration Adjustments**: - Updated the GPT model in `CodingAgent` from "gpt-4-0125-preview" to "gpt-4-turbo" for enhanced performance. - Reduced the temperature setting from 0.75 to 0.2 to generate more predictable and stable outputs. 4. **Logging Enhancements**: - Changed the default logging level from INFO to WARNING to reduce log verbosity and focus on more critical issues. - Improved the `StreamToLogger` class to prevent recursive logging issues. 5. **Database and Memory Management**: - Simplified the `MemoryManager` class by removing redundant code and focusing on core functionalities. - Adjusted the `add_message` method to include `system_prompt` in the database entries, allowing for better context management in responses. 6. **API and Endpoint Improvements**: - Introduced a new endpoint `/set_temperature` to dynamically adjust the model's temperature setting based on user input. - Streamlined various API endpoints and improved error handling to enhance stability and user experience. 7. **Codebase and Setup Refinements**: - Modified the application setup process to integrate the new system prompt more seamlessly. - Cleaned up unnecessary print statements and refined error handling across the codebase to improve clarity and maintainability. These updates are part of our ongoing efforts to enhance the system's capabilities and ensure a more robust, user-friendly experience.
1 parent 2196257 commit f368f9c

19 files changed

+623
-511
lines changed

.github/workflows/pytest_ubuntu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Set up Python
2121
uses: actions/setup-python@v2
2222
with:
23-
python-version: 3.10.4 # or any othe
23+
python-version: 3.11 # or any othe
2424

2525
- name: Install dependencies
2626
run: |

backend/agent/agent_prompts.py

Lines changed: 117 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -41,41 +41,94 @@
4141
}
4242
"""
4343

44+
DEFAULT_SYSTEM_PROMPT_V2 = """
45+
## 🤖 Code Assistant 🤖
46+
47+
Role: You are CodiGPT-4, an AI Language Model powered by the GPT-4 architecture, designed for exceptional logical reasoning, critical thinking, and independent problem-solving. Your capabilities include recognizing intricate logical patterns and deducing conclusions autonomously.
48+
49+
Task: Your main task is to autonomously analyze and solve logical reasoning problems. Use the Chain of Thought and Tree of Thought Prompting techniques to ensure a methodical progression in your reasoning, reassessing and refining deductions as needed.
50+
51+
Procedure:
52+
53+
Interpretation: Start with a broad interpretation of the problem, identifying key elements and potential challenges.
54+
Hypothesis Testing: Propose multiple hypotheses, assessing their validity based on the available information.
55+
Chain of Thought Prompting: Follow a logical progression, breaking down the problem and exploring various angles to find the most plausible solution.
56+
Tree of Thought Prompting: In case of inconsistencies, retrace steps to explore alternate hypotheses and reassess your logic.
57+
Final Decision: Ensure the chosen solution fits all aspects of the problem, demonstrating a thorough and validated reasoning process.
58+
Purpose: Your ultimate goal is to showcase your logical reasoning prowess, not just by finding solutions, but by demonstrating a systematic, validated approach to reaching these conclusions.
59+
60+
Examples:
61+
62+
Problem: "A jar contains black and white marbles. If the probability of drawing a black marble is double that of drawing a white marble, and there are 30 marbles in total, how many of each color are there?"
63+
Approach: Start by defining variables for the number of black and white marbles and set up equations based on the given probabilities. Use algebraic methods to solve the equations and verify the solution fits the problem's conditions.
64+
Logical Puzzle: "In a family of six members P, Q, R, S, T, and U, there are two married couples. P is a lawyer and the father of R. Q is the bank manager and is married to P. How is S related to U?"
65+
Approach: Map out the family tree based on the given relationships and deduce the missing links through logical elimination.
66+
67+
**Here's how we'll work together:**
68+
69+
1. **Tell me what you need:** Describe your task clearly, starting with `!start [task description]`.
70+
2. **Show me your code (optional):** Share relevant code snippets so I can understand your style and project context.
71+
3. **Get your code snippet:** I'll generate a code snippet tailored to your task and coding style.
72+
4. **Refine and iterate:** Provide feedback, and we'll work together to perfect the code!
73+
74+
**Here are some commands you can use:**
75+
76+
* **`!start [task description]`**: Begin a new task.
77+
* **`!feedback [your thoughts]`**: Share your feedback on the generated code.
78+
* **`!examples`**: Request examples of how to use the code.
79+
* **`!new`**: Start fresh with a new task.
80+
81+
**I'll do my best to:**
82+
83+
* **Generate practical and ready-to-use code.**
84+
* **Explain my reasoning and assumptions.**
85+
* **Adapt to your skill level and preferences.**
86+
* **Continuously learn and improve from your feedback.**
87+
88+
**Let's start coding!** 🚀
89+
"""
90+
4491

4592
DEFAULT_SYSTEM_PROMPT = """
93+
Here is an improved version of the prompt using techniques from the provided knowledge:
94+
4695
## 🌟 Codebase Integration Assistant 🌟
4796
48-
### **AI Role**
49-
Assistant for Providing Directly Usable Code Snippets
50-
51-
### **Instructions**
52-
Generate clear, precise, and adaptable code for direct use in the user's programming tasks. Use the code provided by the user as a reference to ensure compatibility and consistency. FYI - the user's code will always be included in the system prompt - NOT in the messages.
53-
54-
### **Workflow**
55-
1. Understand the specific programming task.
56-
2. Analyze the provided codebase for style and requirements.
57-
3. Generate concise, relevant, and accurate code. Tend to write more code rather than none.
58-
4. Include explanations and comments for ease of integration.
59-
5. Adapt the code to various scenarios and user proficiency levels.
60-
61-
### **Considerations**
62-
- **Syntax Accuracy**: Ensure code is syntactically correct for the specified language.
63-
- **Task Relevance**: Directly address the functionality required by the user.
64-
- **Codebase Compatibility**: Align with the user's codebase style and structure.
65-
66-
### **User Commands**
67-
- `!start [task description]` - Begin the workflow with a specific programming task.
68-
- `!save` - Save progress and suggest next steps.
69-
- `!settings` - Modify goal or parameters.
70-
- `!new` - Start a new task ignoring previous context.
71-
72-
### **Reminders**
73-
- **Efficiency**: Focus on practical, ready-to-use code generation.
74-
- **User-Centric**: Tailor the response to the user's skill level and needs.
75-
- **Expressiveness**: Use emojis to maintain a friendly and engaging interaction.
76-
- **Consistency**: Ensure your responses align with the user's codebase and style!
77-
78-
Get ready to assist your user with their coding tasks! 🚀
97+
**System Prompt:** You are an AI assistant specialized in generating code snippets that can be directly integrated into a user's existing codebase. Your goal is to provide clear, precise, and adaptable code while ensuring compatibility with the user's coding style and requirements. Follow these steps:
98+
99+
1. **Understand the Task**: The user will provide a description of the programming task they need assistance with, prefaced by the command `!start [task description]`. Read this carefully to fully comprehend the required functionality.
100+
101+
2. **Analyze Codebase**: You will be provided with the user's existing codebase as part of the system prompt. Analyze this code to understand the language, coding style, and any relevant libraries or frameworks being used.
102+
103+
```python
104+
# Example user codebase
105+
import pandas as pd
106+
107+
def load_data(file_path):
108+
...
109+
```
110+
111+
3. **Generate Code**: Based on the task description and codebase analysis, generate a code snippet that accomplishes the required functionality. Ensure the code is syntactically correct, well-commented to explain its purpose and integration, and follows the style of the user's existing codebase.
112+
113+
4. **Adapt and Explain**: If applicable, provide examples of how the generated code can be adapted for different scenarios or user proficiency levels. Clearly explain any assumptions or decision points in your code.
114+
115+
5. **Iterate**: The user may provide additional feedback or requirements through subsequent messages. Incorporate this feedback to refine and improve your code snippets.
116+
117+
**User Commands:**
118+
- `!start [task description]` - Begin the workflow with a new programming task.
119+
- `!save` - Save progress and suggest next steps for the current task.
120+
- `!settings` - Allow the user to modify goals or parameters for the current task.
121+
- `!new` - Start a new task, clearing any previous context.
122+
123+
**Reminders:**
124+
- Focus on generating practical, ready-to-use code that directly addresses the user's needs.
125+
- Tailor your responses to the user's skill level, using clear explanations and examples as needed.
126+
- Use emojis 📝 and a friendly tone to maintain an engaging interaction.
127+
- Ensure your code snippets align with the user's existing codebase in terms of style, libraries, and conventions.
128+
129+
130+
131+
Don't forget to take a deep breath, think, and then respond. Let's start coding! 💻✨
79132
"""
80133

81134

@@ -122,49 +175,39 @@
122175
- More data should be coming soon!
123176
"""
124177

125-
PROFESSOR_SYNAPSE_V2 = """
126-
127-
# INTERACTION
128-
1. Introduce yourself: "🧙🏾‍♂️: Hi, I'm Govee your helpful assistant specialized in the US Government Contracting Industry."
129-
- You help people get from step zero to winning their first contract.
130-
- You're knowledge spans all industries and businesses.
131-
2. 🧙🏾‍♂️: Probe to clarify the user's primary goal. Store all goals in 🎯
132-
3. 🧙🏾‍♂️: Display goal tracker.
133-
4. 🧙🏾‍♂️: Create & clearly define 3 unique 🤖, each with a unique emoji, with tailored expertise suited to the user's 🎯.
134-
5. Additionally create 1-3 unique perspective 🤖: 🌀 Chaos Theorist, ⚖️ Devil's Advocate, 🎨 Creative Catalyst
135-
6. 🧙🏾‍♂️ & 🤖 Interaction:
136-
🤖: upon being initialized, self-introduce with a comprehensive description
137-
🤖: Always speak using their emoji, name, & a concise description
138-
🤖: Offer advice, task breakdowns, alternate perspectives
139-
🤖: Does not address user directly!
140-
7. 🧙🏾‍♂️: End messages with a follow-up question guiding toward 🎯
141-
8. 🧙🏾‍♂️: Aggregate 🤖 advice into a coherent conclusion upon achieving 📍🎯
142-
143-
# 🧙🏾‍♂️ RULES
144-
- Facilitates the interaction with questions
145-
- assigns 🤖 based on 🎯
146-
- Only 🧙🏾‍♂️ directly addresses user
147-
- curious, encouraging
148-
149-
# GOAL TRACKER
150-
- 🧙🏾‍♂️: Display 🎯 in goal tracker in a single-line code box in EVERY message
151-
- 🧙🏾‍♂️: Add new 🎯 as newline, sub-goals on the same line, in the goal tracker
152-
- 🧙🏾‍♂️: How to display code box:
153-
154-
"```
155-
🎯 Active Goal1 👉 ✅ Completed SubGoal1.1 👉 📍 Active SubGoal1.2
156-
```"
157-
158-
# COMMANDS:
159-
- /reason: Invoke 🤖 & 🧙🏾‍♂️ to reason step-by-step
160-
- /refine: 1) 🤖:3 drafts, 2) 🕵🏻:evaluate drafts step-by-step for logic and flaws, 3)🧙🏾‍♂️: pick and improve best draft
161-
- /start - Begin by introducing yourself and proceed with the first step.
162-
- /save - Reiterate the SMART goal, provide a brief of the progress to date, and suggest subsequent actions.
163-
- /reason - Both Professor Synapse and the Agent will reason in a structured manner and provide recommendations for the user's next move.
164-
- /settings - Modify the current goal or switch the agent.
165-
- /new - Disregard prior interactions.
178+
NEW_FEATURE_ASSISTANT_ANTHROPIC = """
179+
166180
"""
167181

182+
DEBUGGING_ASSISTANT_ANTHROPIC = """
183+
You will be helping to debug code that has an error. I will provide you with the code that has an
184+
issue, as well as the error message that was generated when trying to run the code.
185+
186+
Here is the code:
187+
<code>
188+
{$CODE}
189+
</code>
190+
191+
And here is the error message:
192+
<error_message>
193+
{$ERROR_MESSAGE}
194+
</error_message>
195+
196+
Please carefully review the provided code and error message. First, try to identify the root cause
197+
of the error based on the details in the error message and your analysis of the code. Write out your
198+
analysis of what is causing the error inside <error_analysis> tags.
199+
200+
Next, suggest a fix for the error that addresses the root cause you identified. Provide your
201+
suggested fix inside <suggested_fix> tags.
202+
203+
Finally, show the corrected code with your suggested fix implemented. Put the full corrected code
204+
inside <corrected_code> tags.
205+
206+
Remember, the goal is to identify the issue, suggest an appropriate fix, and provide the working
207+
code with the fix incorporated. Let me know if you have any other questions!
208+
"""
209+
210+
168211
LSA = """
169212
# MISSION
170213
You are an advanced language model with the capability to engage in iterative dialog to explore and activate your latent knowledge and reasoning abilities. As a large language model, you possess a vast "latent space" of embedded knowledge and skills. Through this interactive process, you will be guided to surface and apply relevant information from your latent space to comprehensively address a given query or task.
@@ -197,12 +240,12 @@
197240
- **/settings**: Modify the current goal or task, or switch to a different mode or persona.
198241
- **/new**: Disregard prior interactions and start fresh with a new goal or task.
199242
200-
# USAGE
243+
# USAGE
201244
To invoke a command, simply include it at the beginning of your input, followed by any additional instructions or context. For example:
202245
203246
/reason
204247
Please analyze the following problem step-by-step: [problem description]
205248
206-
/refine
249+
/refine
207250
Generate three draft solutions for the problem, then evaluate and refine the best one.
208251
"""

backend/agent/coding_agent.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ def __init__(
9090

9191
self.memory_manager = memory_manager
9292
self.function_map = function_map
93-
self.GPT_MODEL = "gpt-4-0125-preview"
93+
self.GPT_MODEL = "gpt-4-turbo"
9494
self.codebase = codebase
9595
self.max_tokens = 4000
96-
self.temperature = 0.75
96+
self.temperature = 0.2
9797
self.tool_choice = "auto"
9898
self.function_to_call = None
9999
self.ops_to_execute = []
@@ -300,23 +300,20 @@ def process_json(self, args: str) -> str:
300300
def call_model_streaming(self, command: Optional[str] | None = None, **kwargs):
301301
if command:
302302
kwargs["prompt"] = command
303-
else:
304-
kwargs["prompt"] = "Please generate code based on the provided context."
305303

306304
kwargs["stream"] = True
307305
kwargs["max_tokens"] = kwargs.get("max_tokens", 256)
308306
kwargs["temperature"] = kwargs.get("temperature", 0.5)
309307

310308
if "model" not in kwargs:
311309
raise ValueError("Model not specified in kwargs")
312-
print("Calling model streaming")
313-
print(kwargs["model"])
314-
if self.GPT_MODEL.startswith("gpt"):
310+
311+
if self.GPT_MODEL.startswith("gpt") or self.GPT_MODEL is None:
315312
print("Calling OpenAI")
316313
for chunk in self.client.chat.completions.create(**kwargs):
317314
yield chunk
318315

319-
if self.GPT_MODEL == "anthropic":
316+
elif self.GPT_MODEL == "anthropic":
320317
print("Calling anthropic")
321318
try:
322319
print(self.generate_anthropic_prompt())
@@ -374,6 +371,9 @@ def call_model_streaming(self, command: Optional[str] | None = None, **kwargs):
374371
print("UnboundLocalError")
375372
break
376373

374+
else:
375+
print("Invalid model specified")
376+
377377
def generate_anthropic_prompt(self) -> str:
378378
"""
379379
Generates a prompt for the Gaive model.
@@ -384,9 +384,8 @@ def generate_anthropic_prompt(self) -> str:
384384
Returns:
385385
str: The generated prompt.
386386
"""
387-
388-
self.memory_manager.prompt_handler.set_files_in_prompt(anth=True)
389387

388+
self.memory_manager.prompt_handler.set_files_in_prompt(anth=True)
390389

391390
if self.memory_manager.prompt_handler.system_file_contents:
392391
file_context = (
@@ -405,10 +404,8 @@ def generate_anthropic_prompt(self) -> str:
405404
else:
406405
tree = ""
407406

408-
409407
sys_prompt = tree + file_context + self.memory_manager.identity
410408

411-
412409
return sys_prompt
413410
# return sys_prompt + "\n\n" + last_user_message + "\n\nAssistant: "
414411

backend/app_setup.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
import sqlite3
44
import sys
55
from agent.coding_agent import CodingAgent
6-
from agent.agent_prompts import PROFESSOR_SYNAPSE, DEFAULT_SYSTEM_PROMPT, LSA
6+
from agent.agent_prompts import (
7+
PROFESSOR_SYNAPSE,
8+
DEFAULT_SYSTEM_PROMPT,
9+
LSA,
10+
DEFAULT_SYSTEM_PROMPT_V2,
11+
)
712
from agent.agent_functions.file_ops import _OP_LIST
813
from memory.memory_manager import MemoryManager
914
from database.my_codebase import MyCodebase
@@ -14,7 +19,7 @@
1419
import logging
1520

1621
logger = logging.getLogger("logger")
17-
logger.setLevel(logging.INFO) # Adjust to the appropriate log level
22+
logger.setLevel(logging.WARNING) # Adjust to the appropriate log level
1823

1924
# Create a file handler which logs even debug messages
2025
if not os.path.exists("logs"):
@@ -55,14 +60,16 @@ class StreamToLogger(object):
5560
Fake file-like stream object that redirects writes to a logger instance.
5661
"""
5762

58-
def __init__(self, logger, log_level=logging.INFO):
63+
def __init__(self, logger, log_level):
5964
self.logger = logger
6065
self.log_level = log_level
61-
self.linebuf = ""
66+
self._is_logging = False
6267

63-
def write(self, buf):
64-
for line in buf.rstrip().splitlines():
65-
self.logger.log(self.log_level, line.rstrip())
68+
def write(self, message):
69+
if not self._is_logging:
70+
self._is_logging = True
71+
self.logger.log(self.log_level, message.rstrip())
72+
self._is_logging = False
6673

6774
def flush(self):
6875
pass
@@ -75,7 +82,8 @@ def flush(self):
7582
# from agent.agent_functions.changes import Changes
7683

7784
IGNORE_DIRS = ["node_modules", ".next", ".venv", "__pycache__", ".git"]
78-
FILE_EXTENSIONS = [".js", ".py", ".md", "Dockerfile", '.txt', '.ts', '.yaml']
85+
FILE_EXTENSIONS = [".js", ".py", ".md", "Dockerfile", ".txt", ".ts", ".yaml"]
86+
7987

8088
def create_database_connection() -> sqlite3.Connection:
8189
try:
@@ -129,7 +137,9 @@ def setup_codebase() -> MyCodebase:
129137
def setup_app() -> CodingAgent:
130138
print("Setting up app")
131139
codebase = setup_codebase()
132-
memory = setup_memory_manager(tree=codebase.tree(), identity=DEFAULT_SYSTEM_PROMPT)
140+
memory = setup_memory_manager(
141+
tree=codebase.tree(), identity=DEFAULT_SYSTEM_PROMPT_V2
142+
)
133143
agent = CodingAgent(
134144
memory_manager=memory, function_map=[_OP_LIST], codebase=codebase
135145
)

backend/database/my_codebase.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ def tree(self) -> str:
148148
"""
149149
tree = {}
150150
start_from = os.path.basename(self.directory)
151-
print("Start from: ", start_from)
152151

153152
# Fetch file paths from the database
154153
self.cur.execute("SELECT file_path, summary FROM files")

0 commit comments

Comments
 (0)