From a0eeeb5334f2c2346670e3de12106cde4f84d55f Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Sat, 15 Jun 2024 13:21:16 +0200 Subject: [PATCH 01/23] Update state.py If no project is selected, return None immediately --- src/state.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/state.py b/src/state.py index 1e5c3491..458f7ab1 100644 --- a/src/state.py +++ b/src/state.py @@ -100,6 +100,9 @@ def update_latest_state(self, project: str, state: dict): emit_agent("agent-state", state_stack) def get_latest_state(self, project: str): + if not project: + # If no project is selected, return None immediately + return None with Session(self.engine) as session: agent_state = session.query(AgentStateModel).filter(AgentStateModel.project == project).first() if agent_state: @@ -174,4 +177,4 @@ def get_latest_token_usage(self, project: str): if agent_state: return json.loads(agent_state.state_stack_json)[-1]["token_usage"] return 0 - \ No newline at end of file + From 63d4e379bb47fbfe4db316c6abb4aaf297f4f3dd Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Sat, 15 Jun 2024 13:35:04 +0200 Subject: [PATCH 02/23] Update coder.py remove backtick (`) from generated files --- src/agents/coder/coder.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/agents/coder/coder.py b/src/agents/coder/coder.py index 3e021d61..1717049c 100644 --- a/src/agents/coder/coder.py +++ b/src/agents/coder/coder.py @@ -52,7 +52,10 @@ def validate_response(self, response: str) -> Union[List[Dict[str, str]], bool]: if line.startswith("File: "): if current_file and current_code: result.append({"file": current_file, "code": "\n".join(current_code)}) - current_file = line.split(":")[1].strip() + if "`" in line: + current_file = line.split("`")[1].strip() + else: + return False current_code = [] code_block = False elif line.startswith("```"): From 5cebc42949d0c00a4f311a1f39e8459f51a112c8 Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Sat, 15 Jun 2024 13:43:47 +0200 Subject: [PATCH 03/23] Update feature.py add normpath to resolvle backslach compatibilite beetwen linux and windows --- src/agents/feature/feature.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/agents/feature/feature.py b/src/agents/feature/feature.py index 99bcf30b..fc441832 100644 --- a/src/agents/feature/feature.py +++ b/src/agents/feature/feature.py @@ -69,10 +69,11 @@ def save_code_to_project(self, response: List[Dict[str, str]], project_name: str for file in response: file_path = os.path.join(self.project_dir, project_name, file['file']) - file_path_dir = os.path.dirname(file_path) + file_norm_path = os.path.normpath(file_path) + file_path_dir = os.path.dirname(file_norm_path) os.makedirs(file_path_dir, exist_ok=True) - with open(file_path, "w", encoding="utf-8") as f: + with open(file_norm_path, "w+", encoding="utf-8") as f: f.write(file["code"]) return file_path_dir From 28318a24d898ecbb3e894171ff1c551f449a1434 Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Sat, 15 Jun 2024 13:45:56 +0200 Subject: [PATCH 04/23] Update coder.py update save code function to resolve backslash issue --- src/agents/coder/coder.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/agents/coder/coder.py b/src/agents/coder/coder.py index 1717049c..b546bb8c 100644 --- a/src/agents/coder/coder.py +++ b/src/agents/coder/coder.py @@ -74,10 +74,11 @@ def save_code_to_project(self, response: List[Dict[str, str]], project_name: str for file in response: file_path = os.path.join(self.project_dir, project_name, file['file']) - file_path_dir = os.path.dirname(file_path) + file_norm_path = os.path.normpath(file_path) + file_path_dir = os.path.dirname(file_norm_path) os.makedirs(file_path_dir, exist_ok=True) - with open(file_path, "w", encoding="utf-8") as f: + with open(file_norm_path, "w+", encoding="utf-8") as f: f.write(file["code"]) return file_path_dir From 4728412d1d9edf9891c3d9f2ba966e469dd6f8b5 Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Sat, 15 Jun 2024 13:57:18 +0200 Subject: [PATCH 05/23] Update project.py When a project is created, the folder is created immediately. When the "Delete Project" button is triggered, the project is deleted immediately. --- src/project.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/project.py b/src/project.py index dd2c68be..75ffeda4 100644 --- a/src/project.py +++ b/src/project.py @@ -36,13 +36,30 @@ def create_project(self, project: str): project_state = Projects(project=project, message_stack_json=json.dumps([])) session.add(project_state) session.commit() + # Create project directory + project_dir = os.path.join(self.project_path, project) + os.makedirs(project_dir, exist_ok=True) def delete_project(self, project: str): with Session(self.engine) as session: - project_state = session.query(Projects).filter(Projects.project == project).first() + project_state = session.query(Projects).filter_by(project=project).first() if project_state: session.delete(project_state) session.commit() + # Delete project directory + project_dir = os.path.join(self.project_path, project) + if os.path.exists(project_dir): + # Empty the directory + for root, dirs, files in os.walk(project_dir, topdown=False): + for file in files: + file_path = os.path.join(root, file) + os.remove(file_path) + for dir1 in dirs: + dir_path = os.path.join(root, dir1) + os.rmdir(dir_path) + + # Remove the empty directory + os.rmdir(project_dir) def add_message_to_project(self, project: str, message: dict): with Session(self.engine) as session: From 2c763d5ed22af145789c81d98cbf4637f24e1454 Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Sat, 15 Jun 2024 14:01:05 +0200 Subject: [PATCH 06/23] Update gemini_client.py Setting the temperature to 0 is not good, because the model will return the prompt repeatedly. --- src/llm/gemini_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llm/gemini_client.py b/src/llm/gemini_client.py index 0d566673..ed51d7bc 100644 --- a/src/llm/gemini_client.py +++ b/src/llm/gemini_client.py @@ -10,7 +10,7 @@ def __init__(self): genai.configure(api_key=api_key) def inference(self, model_id: str, prompt: str) -> str: - config = genai.GenerationConfig(temperature=0) + config = genai.GenerationConfig(temperature=1) model = genai.GenerativeModel(model_id, generation_config=config) # Set safety settings for the request safety_settings = { From 4ef62341bd87f830d05e7ee8f7ab3323aed5e6e1 Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Sat, 15 Jun 2024 14:01:40 +0200 Subject: [PATCH 07/23] Update claude_client.py Setting the temperature to 0 is not good, because the model will return the prompt repeatedly. --- src/llm/claude_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llm/claude_client.py b/src/llm/claude_client.py index 68fa6eba..c9e261e9 100644 --- a/src/llm/claude_client.py +++ b/src/llm/claude_client.py @@ -20,7 +20,7 @@ def inference(self, model_id: str, prompt: str) -> str: } ], model=model_id, - temperature=0 + temperature=1 ) return message.content[0].text From c35be8038d88f95e99b25f7bc0d7a07ea35b273e Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Sat, 15 Jun 2024 14:02:43 +0200 Subject: [PATCH 08/23] Update groq_client.py Setting the temperature to 0 is not good, because the model will return the prompt repeatedly. so setting temperature to 1 will be better option. --- src/llm/groq_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llm/groq_client.py b/src/llm/groq_client.py index 828c9cc6..642a134b 100644 --- a/src/llm/groq_client.py +++ b/src/llm/groq_client.py @@ -18,7 +18,7 @@ def inference(self, model_id: str, prompt: str) -> str: } ], model=model_id, - temperature=0 + temperature=1 ) return chat_completion.choices[0].message.content From bd980e43972545fb8c8026217a7a6a3a20653dc6 Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Sat, 15 Jun 2024 14:03:00 +0200 Subject: [PATCH 09/23] Update mistral_client.py Setting the temperature to 0 is not good, because the model will return the prompt repeatedly. --- src/llm/mistral_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llm/mistral_client.py b/src/llm/mistral_client.py index ee019c42..f1b72372 100644 --- a/src/llm/mistral_client.py +++ b/src/llm/mistral_client.py @@ -17,6 +17,6 @@ def inference(self, model_id: str, prompt: str) -> str: messages=[ ChatMessage(role="user", content=prompt.strip()) ], - temperature=0 + temperature=1 ) return chat_completion.choices[0].message.content From d01dbe64ba530294e46835201c5fcb3140743e1f Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Sat, 15 Jun 2024 14:03:18 +0200 Subject: [PATCH 10/23] Update ollama_client.py Setting the temperature to 0 is not good, because the model will return the prompt repeatedly. --- src/llm/ollama_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llm/ollama_client.py b/src/llm/ollama_client.py index 95b1e365..a3e73d4e 100644 --- a/src/llm/ollama_client.py +++ b/src/llm/ollama_client.py @@ -20,6 +20,6 @@ def inference(self, model_id: str, prompt: str) -> str: response = self.client.generate( model=model_id, prompt=prompt.strip(), - options={"temperature": 0} + options={"temperature": 1} ) return response['response'] From f45f4b1e3a0f7862309412b96053c6c56f658d56 Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Sat, 15 Jun 2024 14:03:37 +0200 Subject: [PATCH 11/23] Update openai_client.py --- src/llm/openai_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llm/openai_client.py b/src/llm/openai_client.py index 17344c05..9f55f6d0 100644 --- a/src/llm/openai_client.py +++ b/src/llm/openai_client.py @@ -19,6 +19,6 @@ def inference(self, model_id: str, prompt: str) -> str: } ], model=model_id, - temperature=0 + temperature=1 ) return chat_completion.choices[0].message.content From 088525f44ec1043c696a7927a232dbda25666c88 Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Sun, 16 Jun 2024 08:39:24 +0200 Subject: [PATCH 12/23] Update devika.py Change the origin of frontend URL --- devika.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/devika.py b/devika.py index 9224f54e..6d5d57be 100644 --- a/devika.py +++ b/devika.py @@ -26,7 +26,13 @@ app = Flask(__name__) -CORS(app, resources={r"/*": {"origins": ["https://localhost:3000"]}}) # Change the origin to your frontend URL +CORS(app, resources={r"/*": {"origins": # Change the origin to your frontend URL + [ + "https://localhost:3000", + "http://localhost:3000", + "https://localhost:3001", + "http://localhost:3001", + ]}}) app.register_blueprint(project_bp) socketio.init_app(app) From 1c62f83262d1237d8156cbc03e09f93ba30ff117 Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Sun, 16 Jun 2024 08:42:54 +0200 Subject: [PATCH 13/23] Update coder.py handle more use cases of validate function of coder --- src/agents/coder/coder.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/agents/coder/coder.py b/src/agents/coder/coder.py index b546bb8c..a571da6f 100644 --- a/src/agents/coder/coder.py +++ b/src/agents/coder/coder.py @@ -49,11 +49,13 @@ def validate_response(self, response: str) -> Union[List[Dict[str, str]], bool]: code_block = False for line in response.split("\n"): - if line.startswith("File: "): + if line.startswith("File:"): if current_file and current_code: result.append({"file": current_file, "code": "\n".join(current_code)}) if "`" in line: current_file = line.split("`")[1].strip() + elif line.startswith("File:") and line.endswith(":") and "`" not in line: + current_file = line.split(":")[1].strip() else: return False current_code = [] From 894c6d0c49b0b2ed1e8bf1709c82106cc8477c6a Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Sun, 16 Jun 2024 08:52:07 +0200 Subject: [PATCH 14/23] Update coder.py this change fix this error File "C:\Users\pc\Desktop\stream_main\devika\src\agents\coder\coder.py", line 131, in execute valid_response = self.validate_response(response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\pc\Desktop\stream_main\devika\src\agents\coder\coder.py", line 37, in validate_response self.logger.debug(f"Response from the model: {response}") File "C:\Users\pc\Desktop\stream_main\devika\src\logger.py", line 32, in debug self.logger.debug(message) File "C:\Users\pc\Desktop\stream_main\devika\.venv\Lib\site-packages\fastlogging\fastlogging.py", line 248, in debug self.__log(DEBUG, msg, args, kwargs) File "C:\Users\pc\Desktop\stream_main\devika\.venv\Lib\site-packages\fastlogging\fastlogging.py", line 238, in __log self._logMessage(None, (log_time, domain, level, msg, kwargs), 0) File "C:\Users\pc\Desktop\stream_main\devika\.venv\Lib\site-packages\fastlogging\fastlogging.py", line 423, in _logMessage print(message, file=self.stdout if level < ERROR else self.stderr) File "C:\Users\pc\Desktop\stream_main\devika\.venv\Lib\site-packages\colorama\ansitowin32.py", line 47, in write self.__convertor.write(text) --- src/agents/coder/coder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/agents/coder/coder.py b/src/agents/coder/coder.py index a571da6f..cdaf2213 100644 --- a/src/agents/coder/coder.py +++ b/src/agents/coder/coder.py @@ -34,7 +34,7 @@ def render( def validate_response(self, response: str) -> Union[List[Dict[str, str]], bool]: response = response.strip() - self.logger.debug(f"Response from the model: {response}") + # self.logger.debug(f"Response from the model: {response}") if "~~~" not in response: return False From f8bb37dd89f8edcf6729897dad68c84e98359aa4 Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:45:00 +0100 Subject: [PATCH 15/23] Update claude_client.py --- src/llm/claude_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llm/claude_client.py b/src/llm/claude_client.py index c9e261e9..68fa6eba 100644 --- a/src/llm/claude_client.py +++ b/src/llm/claude_client.py @@ -20,7 +20,7 @@ def inference(self, model_id: str, prompt: str) -> str: } ], model=model_id, - temperature=1 + temperature=0 ) return message.content[0].text From 53ffe6a90dcd9368467a3da351c403fe6e328312 Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:45:25 +0100 Subject: [PATCH 16/23] Update gemini_client.py --- src/llm/gemini_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llm/gemini_client.py b/src/llm/gemini_client.py index ed51d7bc..0d566673 100644 --- a/src/llm/gemini_client.py +++ b/src/llm/gemini_client.py @@ -10,7 +10,7 @@ def __init__(self): genai.configure(api_key=api_key) def inference(self, model_id: str, prompt: str) -> str: - config = genai.GenerationConfig(temperature=1) + config = genai.GenerationConfig(temperature=0) model = genai.GenerativeModel(model_id, generation_config=config) # Set safety settings for the request safety_settings = { From 60dcd9b13c25893d84d3a9ef7fe17a86e3bd6571 Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:45:45 +0100 Subject: [PATCH 17/23] Update groq_client.py --- src/llm/groq_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llm/groq_client.py b/src/llm/groq_client.py index 642a134b..828c9cc6 100644 --- a/src/llm/groq_client.py +++ b/src/llm/groq_client.py @@ -18,7 +18,7 @@ def inference(self, model_id: str, prompt: str) -> str: } ], model=model_id, - temperature=1 + temperature=0 ) return chat_completion.choices[0].message.content From cc04946e9e4a9b11be3b571623f638edd5a7407e Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:46:04 +0100 Subject: [PATCH 18/23] Update mistral_client.py --- src/llm/mistral_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llm/mistral_client.py b/src/llm/mistral_client.py index f1b72372..ee019c42 100644 --- a/src/llm/mistral_client.py +++ b/src/llm/mistral_client.py @@ -17,6 +17,6 @@ def inference(self, model_id: str, prompt: str) -> str: messages=[ ChatMessage(role="user", content=prompt.strip()) ], - temperature=1 + temperature=0 ) return chat_completion.choices[0].message.content From 77c7b1fa36b2e27a9a69a34a67a3584df91db7a9 Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:46:23 +0100 Subject: [PATCH 19/23] Update ollama_client.py --- src/llm/ollama_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llm/ollama_client.py b/src/llm/ollama_client.py index a3e73d4e..95b1e365 100644 --- a/src/llm/ollama_client.py +++ b/src/llm/ollama_client.py @@ -20,6 +20,6 @@ def inference(self, model_id: str, prompt: str) -> str: response = self.client.generate( model=model_id, prompt=prompt.strip(), - options={"temperature": 1} + options={"temperature": 0} ) return response['response'] From a80086b837a0f2cbb8aefd86ba68eb3bfbd96753 Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:46:42 +0100 Subject: [PATCH 20/23] Update openai_client.py --- src/llm/openai_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llm/openai_client.py b/src/llm/openai_client.py index 9f55f6d0..17344c05 100644 --- a/src/llm/openai_client.py +++ b/src/llm/openai_client.py @@ -19,6 +19,6 @@ def inference(self, model_id: str, prompt: str) -> str: } ], model=model_id, - temperature=1 + temperature=0 ) return chat_completion.choices[0].message.content From 3d9b60da77333c0a6f93b09595e6256435f80164 Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:47:46 +0100 Subject: [PATCH 21/23] Update devika.py --- devika.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/devika.py b/devika.py index 6d5d57be..9947fa38 100644 --- a/devika.py +++ b/devika.py @@ -28,8 +28,6 @@ app = Flask(__name__) CORS(app, resources={r"/*": {"origins": # Change the origin to your frontend URL [ - "https://localhost:3000", - "http://localhost:3000", "https://localhost:3001", "http://localhost:3001", ]}}) From e18caeabe488173d398dcd3d3c6f16bacbca0862 Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:50:56 +0100 Subject: [PATCH 22/23] Update devika.py --- devika.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devika.py b/devika.py index 9947fa38..01543062 100644 --- a/devika.py +++ b/devika.py @@ -28,8 +28,8 @@ app = Flask(__name__) CORS(app, resources={r"/*": {"origins": # Change the origin to your frontend URL [ - "https://localhost:3001", - "http://localhost:3001", + "https://localhost:3000", + "http://localhost:3000", ]}}) app.register_blueprint(project_bp) socketio.init_app(app) From b0b388fe1fe2c8e650bc63f0a0d7a01649a0c16a Mon Sep 17 00:00:00 2001 From: Younes DARRASSI <105133429+darrassi1@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:53:51 +0100 Subject: [PATCH 23/23] Update devika.py --- devika.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devika.py b/devika.py index 01543062..961b792a 100644 --- a/devika.py +++ b/devika.py @@ -30,7 +30,7 @@ [ "https://localhost:3000", "http://localhost:3000", - ]}}) + ]}}) app.register_blueprint(project_bp) socketio.init_app(app)