Skip to content

Commit 1f00b1e

Browse files
committed
modified: lazydev/develop.py
modified: lazydev/modules/developer.py modified: lazydev/modules/prompts.py
1 parent ecf606b commit 1f00b1e

File tree

3 files changed

+51
-13
lines changed

3 files changed

+51
-13
lines changed

lazydev/develop.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44
from dotenv import load_dotenv
55

6-
from lazydev.modules.prompts import PrompBook
76
from .modules.developer import Developer
87

98

lazydev/modules/developer.py

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11

22
from typing import List
3-
from .prompts import PrompBook
3+
from .prompts import PromptBook
44
from langchain.llms import OpenAI
5+
from langchain.chat_models import ChatOpenAI
6+
from langchain.prompts.chat import (
7+
ChatPromptTemplate,
8+
SystemMessagePromptTemplate,
9+
AIMessagePromptTemplate,
10+
HumanMessagePromptTemplate,
11+
)
12+
from langchain.schema import (
13+
AIMessage,
14+
HumanMessage,
15+
SystemMessage
16+
)
17+
518
import json
619

720
from .utils import Utilities
@@ -11,16 +24,24 @@ def __init__(self, requirement:str,root_dir:str, openai_api_key:str):
1124
self.requirement=requirement
1225
self.root_dir=root_dir
1326
self.api_key=openai_api_key
14-
self.brain = OpenAI(
15-
model_name="gpt-3.5-turbo",
27+
self.brain = ChatOpenAI(
28+
model="gpt-3.5-turbo",
1629
openai_api_key=self.api_key,
1730
temperature=0,
1831
streaming=False
1932
)
20-
33+
34+
def brain_storm(self,prompt:str)->str:
35+
messages = [
36+
SystemMessage(content="you are a senior software developer"),
37+
HumanMessage(content=prompt)
38+
]
39+
aiMessage:AIMessage= self.brain(messages=messages)
40+
return aiMessage.content
41+
2142
def clear_doubts(self):
22-
prompt=PrompBook.expand_requirements(self.requirement)
23-
doubts:str=self.brain(prompt)
43+
prompt=PromptBook.expand_requirements(self.requirement)
44+
doubts=self.brain_storm(prompt)
2445
doubt_list:List[str]=doubts.split("\n")
2546
doubt_list=[doubt.strip() for doubt in doubt_list if doubt.strip()!=""]
2647
print("""
@@ -45,21 +66,20 @@ def clear_doubts(self):
4566
return doubt_list,answer_list
4667

4768
def plan_project(self):
48-
prompt=PrompBook.plan_project(self.requirement,self.clarifications)
49-
plannings:str=self.brain(prompt)
69+
prompt=PromptBook.plan_project(self.requirement,self.clarifications)
70+
plannings:str=self.brain_storm(prompt)
5071
return plannings
5172

5273
def generate_folder_structure(self):
53-
prompt=PrompBook.design_folder_structure(
74+
prompt=PromptBook.design_folder_structure(
5475
question=self.requirement,
5576
plan=self.plannings,
5677
clarifications=self.clarifications
5778
)
58-
folder_tree_str:str=self.brain(prompt)
79+
folder_tree_str:str=self.brain_storm(prompt)
5980
folder_tree:dict=json.loads(folder_tree_str)
6081
Utilities.generate_files_and_folders(structure=folder_tree,root_dir=self.root_dir)
6182

62-
6383
def develop(self):
6484
# clearing all doubts
6585
doubts,answers=self.clear_doubts()

lazydev/modules/prompts.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11

2-
class PrompBook:
2+
from typing import List
3+
4+
5+
class PromptBook:
36
@staticmethod
47
def expand_requirements(question:str)->str:
58
return f"""
@@ -76,4 +79,20 @@ def design_folder_structure(question:str,plan:str,clarifications:str)->str:
7679
* do not write the contents of the files that will be done by the next developer
7780
Begin!
7881
"""
82+
@staticmethod
83+
def prioritise_file_list(filelist:List[str])->List[str]:
84+
list_string='\n'.join(filelist)
85+
return f"""
86+
you are a senior programmer. you going to write a api service.
87+
below are the file list that you are going to complete in future.
88+
89+
reorder them in a way that most suitable based on how one will be dependent on other
90+
91+
{list_string}
92+
93+
As your response will go to an automated parser, things to keep in mind all the time:
94+
* only write file list in order nothing else
95+
* do not write any explanation
96+
Begin!
97+
"""
7998

0 commit comments

Comments
 (0)