Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add project_metadata the DBs class. Instantiate it in main.py and let its path be .gpteng #665

Closed
4 tasks done
AntonOsika opened this issue Sep 3, 2023 · 2 comments
Closed
4 tasks done
Labels
sweep Assigns Sweep to an issue or pull request.

Comments

@AntonOsika
Copy link
Owner

AntonOsika commented Sep 3, 2023

Add a field called project_metadata in the DBs class, that is of type DB.

Set project_metadata_path .gpteng

Use it when instantiating DBs

Move: memory, archive, file_list.txt, to project_metadata

(Also, separate PR: start writing all_output.txt to memory)

Checklist
  • gpt_engineer/project_metadata.py ✅ Commit eec2cae
• Define the `DB` class in `gpt_engineer/project_metadata.py`.
  • gpt_engineer/db.py ❌ Failed
• Import the `DB` class from `gpt_engineer.project_metadata`. • Modify the `DBs` class to include a `project_metadata` field of type `DB`.
  • gpt_engineer/main.py ❌ Failed
• Import the `DB` class from `gpt_engineer.project_metadata`. • Instantiate the `project_metadata` field of `DBs` with the path `.gpteng`.
  • gpt_engineer/main.py ❌ Failed
• Move the `memory`, `archive`, and `file_list.txt` to the `project_metadata` directory.
@AntonOsika AntonOsika added the sweep Assigns Sweep to an issue or pull request. label Sep 3, 2023
Repository owner deleted a comment from sweep-ai bot Sep 3, 2023
@AntonOsika AntonOsika reopened this Sep 3, 2023
Repository owner deleted a comment from sweep-ai bot Sep 3, 2023
@AntonOsika AntonOsika reopened this Sep 3, 2023
@AntonOsika AntonOsika changed the title Sweep: Add project_metadata the DBs class. Instantiate it in main.py and let its path be .gpteng Add project_metadata the DBs class. Instantiate it in main.py and let its path be .gpteng Sep 12, 2023
Repository owner deleted a comment from sweep-ai bot Sep 12, 2023
@sweep-ai
Copy link
Contributor

sweep-ai bot commented Sep 17, 2023

Here's the PR! #712.

⚡ Sweep Free Trial: I used GPT-3.5 to create this ticket. You have 0 GPT-4 tickets left for the month and 0 for the day. For more GPT-4 tickets, visit our payment portal.


Actions (click)

  • Restart Sweep

Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description.

import logging
import os
from pathlib import Path
import openai
import typer
from dotenv import load_dotenv
from gpt_engineer.ai import AI
from gpt_engineer.collect import collect_learnings
from gpt_engineer.db import DB, DBs, archive
from gpt_engineer.learning import collect_consent
from gpt_engineer.steps import STEPS, Config as StepsConfig
app = typer.Typer() # creates a CLI app
def load_env_if_needed():
if os.getenv("OPENAI_API_KEY") is None:
load_dotenv()
openai.api_key = os.getenv("OPENAI_API_KEY")
@app.command()
def main(
project_path: str = typer.Argument("projects/example", help="path"),
model: str = typer.Argument("gpt-4", help="model id string"),
temperature: float = 0.1,
steps_config: StepsConfig = typer.Option(
StepsConfig.DEFAULT, "--steps", "-s", help="decide which steps to run"
),
improve_option: bool = typer.Option(
False,
"--improve",
"-i",
help="Improve code from existing project.",
),
azure_endpoint: str = typer.Option(
"",
"--azure",
"-a",
help="""Endpoint for your Azure OpenAI Service (https://xx.openai.azure.com).
In that case, the given model is the deployment name chosen in the Azure AI Studio.""",
),
verbose: bool = typer.Option(False, "--verbose", "-v"),
):
logging.basicConfig(level=logging.DEBUG if verbose else logging.INFO)
# For the improve option take current project as path and add .gpteng folder
if improve_option:
# The default option for the --improve is the IMPROVE_CODE, not DEFAULT
if steps_config == StepsConfig.DEFAULT:
steps_config = StepsConfig.IMPROVE_CODE
load_env_if_needed()
ai = AI(
model_name=model,
temperature=temperature,
azure_endpoint=azure_endpoint,
)
input_path = Path(project_path).absolute()
memory_path = input_path / "memory"
workspace_path = input_path / "workspace"
archive_path = input_path / "archive"
dbs = DBs(
memory=DB(memory_path),
logs=DB(memory_path / "logs"),
input=DB(input_path),
workspace=DB(workspace_path),
preprompts=DB(
Path(__file__).parent / "preprompts"
), # Loads preprompts from the preprompts directory
archive=DB(archive_path),
)
if steps_config not in [
StepsConfig.EXECUTE_ONLY,
StepsConfig.USE_FEEDBACK,
StepsConfig.EVALUATE,
StepsConfig.IMPROVE_CODE,
]:
archive(dbs)
if not dbs.input.get("prompt"):
dbs.input["prompt"] = input(
"\nWhat application do you want gpt-engineer to generate?\n"
)
steps = STEPS[steps_config]
for step in steps:
messages = step(ai, dbs)
dbs.logs[step.__name__] = AI.serialize_messages(messages)
print("Total api cost: $ ", ai.usage_cost())
if collect_consent():
collect_learnings(model, temperature, steps, dbs)
dbs.logs["token_usage"] = ai.format_token_usage_log()
if __name__ == "__main__":

from typing import Callable, List, TypeVar
from gpt_engineer.ai import AI
from gpt_engineer.db import DBs


Step 2: ⌨️ Coding

  • gpt_engineer/project_metadata.py ✅ Commit eec2cae
• Define the `DB` class in `gpt_engineer/project_metadata.py`.
  • gpt_engineer/db.py ❌ Failed
• Import the `DB` class from `gpt_engineer.project_metadata`. • Modify the `DBs` class to include a `project_metadata` field of type `DB`.
  • gpt_engineer/main.py ❌ Failed
• Import the `DB` class from `gpt_engineer.project_metadata`. • Instantiate the `project_metadata` field of `DBs` with the path `.gpteng`.
  • gpt_engineer/main.py ❌ Failed
• Move the `memory`, `archive`, and `file_list.txt` to the `project_metadata` directory.

Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/add-project-metadata.

.


🎉 Latest improvements to Sweep:


💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.
Join Our Discord

@ATheorell
Copy link
Collaborator

Closing, since solved in #720, right @RareMojo ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sweep Assigns Sweep to an issue or pull request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants