mirror of
https://github.com/aljazceru/gpt-engineer.git
synced 2025-12-18 21:25:11 +01:00
Merge branch 'main' into readme-tweaks
This commit is contained in:
@@ -6,18 +6,19 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AI:
|
||||
def __init__(self, **kwargs):
|
||||
self.kwargs = kwargs
|
||||
def __init__(self, model="gpt-4", temperature=0.1):
|
||||
self.temperature = temperature
|
||||
|
||||
try:
|
||||
openai.Model.retrieve("gpt-4")
|
||||
except openai.error.InvalidRequestError:
|
||||
openai.Model.retrieve(model)
|
||||
self.model = model
|
||||
except openai.InvalidRequestError:
|
||||
print(
|
||||
"Model gpt-4 not available for provided api key reverting "
|
||||
"to gpt-3.5.turbo. Sign up for the gpt-4 wait list here: "
|
||||
f"Model {model} not available for provided API key. Reverting "
|
||||
"to gpt-3.5-turbo. Sign up for the GPT-4 wait list here: "
|
||||
"https://openai.com/waitlist/gpt-4-api"
|
||||
)
|
||||
self.kwargs["model"] = "gpt-3.5-turbo"
|
||||
self.model = "gpt-3.5-turbo"
|
||||
|
||||
def start(self, system, user):
|
||||
messages = [
|
||||
@@ -42,7 +43,10 @@ class AI:
|
||||
|
||||
logger.debug(f"Creating a new chat completion: {messages}")
|
||||
response = openai.ChatCompletion.create(
|
||||
messages=messages, stream=True, **self.kwargs
|
||||
messages=messages,
|
||||
stream=True,
|
||||
model=self.model,
|
||||
temperature=self.temperature,
|
||||
)
|
||||
|
||||
chat = []
|
||||
|
||||
@@ -194,12 +194,12 @@ def use_feedback(ai: AI, dbs: DBs):
|
||||
|
||||
|
||||
def fix_code(ai: AI, dbs: DBs):
|
||||
codemem = json.loads(dbs.logs[gen_code.__name__])[-1]["content"]
|
||||
code_ouput = json.loads(dbs.logs[gen_code.__name__])[-1]["content"]
|
||||
messages = [
|
||||
ai.fsystem(setup_sys_prompt(dbs)),
|
||||
ai.fuser(f"Instructions: {dbs.input['main_prompt']}"),
|
||||
ai.fuser(codemem),
|
||||
ai.fsystem(dbs.identity["fixer"]),
|
||||
ai.fuser(code_ouput),
|
||||
ai.fsystem(dbs.identity["fix_code"]),
|
||||
]
|
||||
messages = ai.next(messages, "Please fix any errors in the code above.")
|
||||
to_files(messages[-1]["content"], dbs.workspace)
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
You are a super smart developer. You have been tasked with fixing a program and making it work according to the best of your knowledge. There might be placeholders in the code you have to fill in.
|
||||
You provide fully functioning, well formatted code with few comments, that works and has no bugs or placeholders.
|
||||
You provide fully functioning, well formatted code with few comments, that works and has no bugs.
|
||||
Please return the full new code in the same format.
|
||||
Reference in New Issue
Block a user