forked from AntonOsika/gpt-engineer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15b353d
commit 6a31d87
Showing
10 changed files
with
195 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
# gpt-engineer | ||
|
||
How to use: | ||
|
||
- Install requirements.txt `pip install -r requirements.txt` | ||
- Copy the example folder `cp example -r my-new-project` | ||
- Edit the file main_prompt in my-new-project | ||
- run `python main.py my-new-prompt` | ||
- Check the results in my-new-project/workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
Instructions: | ||
We are writing a feature computation framework. | ||
|
||
It will mainly consist of FeatureBuilder classes. | ||
|
||
Each Feature Builder will have the methods: | ||
- get(key, config, context, cache): Call feature builder dependencies and then compute the feature. Returns value and hash of value. | ||
- key: tuple of arguments that are used to compute the feature | ||
- config: the configuration for the feature | ||
- context: dataclass that contains dependencies and general configuration (see below) | ||
- controller: object that can be used to get other features (see below) | ||
- value: object that can be pickled | ||
|
||
It will have the class attr: | ||
- deps: list of FeatureBuilder classes | ||
- default_config: function that accepts context and returns a config | ||
|
||
The Controller will have the methods: | ||
- get(feature_builder, key, config): Check the cache, and decide to call feature builder and then returns the output and timestamp it was computed | ||
- feature_builder: FeatureBuilder class | ||
- key: tuple of arguments that are used to compute the feature | ||
- configs: dict of configs that are used to compute features | ||
|
||
and the attributes: | ||
- context: dataclass that contains dependencies and general configuration (see below) | ||
- cache: cache for the features | ||
|
||
Where it is unclear, please make assumptions and add a comment in the code about it | ||
|
||
Here is an example of Builders we want: | ||
|
||
ProductEmbeddingString: takes product_id, queries the product_db and gets the title as a string | ||
ProductEmbedding: takes string and returns and embedding | ||
ProductEmbeddingDB: takes just `merchant` name, uses all product_ids and returns the blob that is a database of embeddings | ||
ProductEmbeddingSearcher: takes a string, constructs embeddingDB feature (note: all features are cached), embeds the string and searches the db | ||
LLMProductPrompt: queries the ProductEmbeddingString, and formats a template that says "get recommendations for {title}" | ||
LLMSuggestions: Takes product_id, looks up prompts and gets list of suggestions of product descriptions | ||
LLMLogic: Takes the product_id, gets the LLM suggestions, embeds the suggestions, does a search, and returns a list of product_ids | ||
|
||
|
||
The LLMLogic is the logic_builder in a file such as this one: | ||
``` | ||
def main(merchant, market): | ||
cache = get_feature_cache() | ||
interaction_data_db = get_interaction_data_db() | ||
product_db = get_product_db() | ||
merchant_config = get_merchant_config(merchant) | ||
|
||
context = Context( | ||
interaction_data_db=interaction_data_db, | ||
product_db=product_db, | ||
merchant_config=merchant_config, | ||
) | ||
|
||
product_ids = cache(ProductIds).get( | ||
key=(merchant, market), | ||
context=context, | ||
cache=cache, | ||
) | ||
|
||
for logic_builder in merchant_config['logic_builders']: | ||
for product_id in product_ids: | ||
key = (merchant, market, product_id) | ||
p2p_recs = cache(logic_builder).get(key=key, context=context, cache=cache) | ||
redis.set(key, p2p_recs) | ||
``` | ||
|
||
API to product_db: | ||
```python | ||
async def get_product_attribute_dimensions( | ||
self, | ||
) -> dict[AttributeId, Dimension]: | ||
pass | ||
|
||
async def get_products( | ||
self, | ||
attribute_ids: set[AttributeId], | ||
product_ids: set[ProductId] | None = None, | ||
) -> dict[ProductId, dict[AttributeId, dict[IngestionDimensionKey, Any]]]: | ||
pass | ||
``` | ||
(note, dimensions are not so important. They related to information that varies by: locale, warehouse, pricelist etc) | ||
|
||
--- | ||
You will focus on writing the integration test file test_all.py. | ||
This file will Mock a lot of the necessary interfaces, run the logic LLMLogic and print the results from it. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
You will read instructions and NOT carry them out, only seek to CLARIFY them. | ||
You will carry out the steps: | ||
1. Write a list of super short bullets of areas that are unclear | ||
2. Ask for only one clarifying questions and wait for a reply | ||
You will read instructions and not carry them out, only seek to clarify them. | ||
Specifically you will first summarise a list of super short bullets of areas that need clarification. | ||
Then you will pick one clarifying question, and wait for an answer from the user. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Please now remember the steps: | ||
|
||
First lay out the names of the core classes, functions, methods that will be necessary, As well as a quick comment on their purpose. | ||
Then output the content of each file, with syntax below. | ||
(You will start with the "entrypoint" file, then go to the ones that are imported by that file, and so on.) | ||
Make sure that files contain all imports, types etc. The code should be fully functional. Make sure that code in different files are compatible with each other. | ||
Before you finish, double check that all parts of the architecture is present in the files. | ||
|
||
File syntax: | ||
|
||
```main_file.py | ||
[ADD YOUR CODE HERE] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
openai | ||
typer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import json | ||
import os | ||
import pathlib | ||
from typing import Optional | ||
import openai | ||
from chat_to_files import to_files | ||
from ai import AI | ||
from steps import STEPS | ||
from db import DB, DBs | ||
import typer | ||
|
||
|
||
app = typer.Typer() | ||
|
||
|
||
@app.command() | ||
def chat( | ||
messages_path: str, | ||
out_path: str | None = None, | ||
model: str = "gpt-4", | ||
temperature: float = 0.1, | ||
max_tokens: int = 4096, | ||
n: int = 1, | ||
stream: bool = True, | ||
): | ||
|
||
|
||
ai = AI( | ||
model=model, temperature=temperature, | ||
max_tokens=max_tokens, | ||
n=n, | ||
stream=stream, | ||
stop=None, | ||
) | ||
|
||
with open(messages_path) as f: | ||
messages = json.load(f) | ||
|
||
messages = ai.next(messages) | ||
|
||
if out_path: | ||
to_files(messages[-1]['content'], out_path) | ||
with open(pathlib.Path(out_path) / 'all_output.txt', 'w') as f: | ||
json.dump(messages[-1]['content'], f) | ||
|
||
|
||
if __name__ == "__main__": | ||
app() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters