scriptmonkey 1.0.1__tar.gz → 1.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/PKG-INFO +1 -1
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey/core.py +43 -35
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey.egg-info/PKG-INFO +1 -1
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/setup.py +1 -1
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/README.md +0 -0
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey/__init__.py +0 -0
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey/__main__.py +0 -0
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey/file_handler.py +0 -0
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey/openai_client/__init__.py +0 -0
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey/openai_client/basemodels.py +0 -0
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey/openai_client/client.py +0 -0
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey/openai_client/prompting.py +0 -0
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey/openai_client/prompts/fix_error.txt +0 -0
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey/openai_client/prompts/project_description.txt +0 -0
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey.egg-info/SOURCES.txt +0 -0
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey.egg-info/dependency_links.txt +0 -0
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey.egg-info/entry_points.txt +0 -0
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey.egg-info/requires.txt +0 -0
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey.egg-info/top_level.txt +0 -0
- {scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: scriptmonkey
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: A Python package that generates complex Python projects and fixes errors in your code using OpenAI's GPT API.
|
|
5
5
|
Home-page: https://github.com/lukerbs/ScriptMonkey
|
|
6
6
|
Author: Luke Kerbs
|
|
@@ -228,9 +228,15 @@ def generate_project_structure(description: str) -> ProjectStructureResponse:
|
|
|
228
228
|
return project_structure
|
|
229
229
|
|
|
230
230
|
|
|
231
|
-
def create_project_structure(
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
def create_project_structure(
|
|
232
|
+
project_structure_response: dict, project_description: str, base_directory: str = "./generated_project"
|
|
233
|
+
):
|
|
234
|
+
"""Creates the directories and files for the project and generates code content for all file types."""
|
|
235
|
+
# Extract the list of project files for context
|
|
236
|
+
project_files = project_structure_response["files"]
|
|
237
|
+
|
|
238
|
+
# Iterate through each file in the project structure
|
|
239
|
+
for project_file in project_files:
|
|
234
240
|
file_path = os.path.join(base_directory, project_file["path"].lstrip("/"))
|
|
235
241
|
|
|
236
242
|
# Check if it's a directory or file (directories end with '/')
|
|
@@ -240,23 +246,16 @@ def create_project_structure(project_structure_response: dict, base_directory: s
|
|
|
240
246
|
else:
|
|
241
247
|
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
|
242
248
|
|
|
243
|
-
#
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
print(f"File already exists, skipping: {file_path}")
|
|
249
|
+
# Generate content for all files, including Python, HTML, JSON, CSS, etc.
|
|
250
|
+
generated_content = generate_code_for_file(project_file, project_description, project_files)
|
|
251
|
+
|
|
252
|
+
# Write the generated content to the file if it doesn't already exist
|
|
253
|
+
if not os.path.exists(file_path):
|
|
254
|
+
with open(file_path, "w") as f:
|
|
255
|
+
f.write(generated_content)
|
|
256
|
+
print(f"🐒 ScriptMonkey created file with generated content at: '{file_path}'.")
|
|
252
257
|
else:
|
|
253
|
-
|
|
254
|
-
if not os.path.exists(file_path):
|
|
255
|
-
with open(file_path, "w") as f:
|
|
256
|
-
pass # Create an empty file for non-code files
|
|
257
|
-
print(f"🐒 ScriptMonkey reated file: {file_path}")
|
|
258
|
-
else:
|
|
259
|
-
print(f"File already exists, skipping: {file_path}")
|
|
258
|
+
print(f"File already exists, skipping: {file_path}")
|
|
260
259
|
|
|
261
260
|
|
|
262
261
|
def gather_project_context(project_description: str, project_files: list) -> str:
|
|
@@ -284,29 +283,39 @@ def gather_project_context(project_description: str, project_files: list) -> str
|
|
|
284
283
|
|
|
285
284
|
def generate_code_for_file(file_description: dict, project_description: str, project_files: list) -> str:
|
|
286
285
|
"""
|
|
287
|
-
Generates
|
|
286
|
+
Generates content for a given file based on its description using the chatgpt() function.
|
|
288
287
|
|
|
289
288
|
Args:
|
|
290
|
-
file_description (dict): The description of the file for which
|
|
289
|
+
file_description (dict): The description of the file for which content is being generated.
|
|
291
290
|
project_description (str): A high-level description of the project's purpose and goals.
|
|
292
291
|
project_files (list): List of all project files for context.
|
|
293
292
|
|
|
294
293
|
Returns:
|
|
295
|
-
str: The generated
|
|
294
|
+
str: The generated content for the file.
|
|
296
295
|
"""
|
|
297
296
|
# Gather context about the project goal and other files
|
|
298
297
|
context = gather_project_context(project_description, project_files)
|
|
299
298
|
|
|
300
|
-
#
|
|
299
|
+
# Extract the file extension to inform the content type
|
|
300
|
+
file_extension = os.path.splitext(file_description["path"])[1].lower().strip(".")
|
|
301
|
+
|
|
302
|
+
# Dynamically adjust the content type description based on the file extension
|
|
303
|
+
if file_extension:
|
|
304
|
+
content_type_description = f"{file_extension.upper()} file content"
|
|
305
|
+
else:
|
|
306
|
+
content_type_description = "text content"
|
|
307
|
+
|
|
308
|
+
# Prepare instructions for OpenAI to generate content based on the file description and type
|
|
301
309
|
instructions = (
|
|
302
|
-
"Write the complete
|
|
303
|
-
"
|
|
304
|
-
"
|
|
310
|
+
f"Write the complete content for a {content_type_description} that fulfills the following requirements. "
|
|
311
|
+
"Consider the context of the entire project when generating the content and make use of imports where available and appropriate."
|
|
312
|
+
"Use relevant imports, references, and appropriate formatting or structure where necessary. Do not add extra commentary or explanation. "
|
|
313
|
+
"Make sure to return the content directly, without wrapping it in any code fences like triple quotes or backticks."
|
|
305
314
|
f"\n\nFile Description: {file_description['description']}"
|
|
306
315
|
f"\n\n{context}\n"
|
|
307
316
|
)
|
|
308
317
|
|
|
309
|
-
#
|
|
318
|
+
# Include functions for code files (if provided)
|
|
310
319
|
if file_description.get("functions"):
|
|
311
320
|
instructions += "\n\nFunctions:\n"
|
|
312
321
|
for function in file_description["functions"]:
|
|
@@ -315,14 +324,14 @@ def generate_code_for_file(file_description: dict, project_description: str, pro
|
|
|
315
324
|
f"(Inputs: {function['inputs']}, Outputs: {function['outputs']})\n"
|
|
316
325
|
)
|
|
317
326
|
|
|
318
|
-
# Call the chatgpt function to generate the
|
|
319
|
-
|
|
327
|
+
# Call the chatgpt function to generate the content
|
|
328
|
+
generated_content = chatgpt(prompt=instructions)
|
|
320
329
|
|
|
321
|
-
#
|
|
322
|
-
if "```
|
|
323
|
-
|
|
330
|
+
# Clean up any unintended code blocks
|
|
331
|
+
if f"```{file_extension}" in generated_content:
|
|
332
|
+
generated_content = generated_content.split(f"```{file_extension}")[1].split("```")[0].strip()
|
|
324
333
|
|
|
325
|
-
return
|
|
334
|
+
return generated_content
|
|
326
335
|
|
|
327
336
|
|
|
328
337
|
def generate_readme(description: str, project_structure: dict) -> str:
|
|
@@ -341,7 +350,6 @@ def generate_readme(description: str, project_structure: dict) -> str:
|
|
|
341
350
|
return readme_content
|
|
342
351
|
|
|
343
352
|
|
|
344
|
-
# Example usage
|
|
345
353
|
def main():
|
|
346
354
|
if len(sys.argv) > 1 and sys.argv[1] == "--set-api-key":
|
|
347
355
|
update_api_key()
|
|
@@ -366,7 +374,7 @@ def main():
|
|
|
366
374
|
|
|
367
375
|
# Step 3: Create the project structure (directories and files) on the filesystem
|
|
368
376
|
print(f"\n🐒 ScriptMonkey is coding...")
|
|
369
|
-
create_project_structure(project_structure)
|
|
377
|
+
create_project_structure(project_structure_response=project_structure, project_description=project_description)
|
|
370
378
|
print("\nProject structure creation complete.")
|
|
371
379
|
|
|
372
380
|
# Step 4: Generate the README.md content based on the project description and structure
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: scriptmonkey
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: A Python package that generates complex Python projects and fixes errors in your code using OpenAI's GPT API.
|
|
5
5
|
Home-page: https://github.com/lukerbs/ScriptMonkey
|
|
6
6
|
Author: Luke Kerbs
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="scriptmonkey",
|
|
5
|
-
version="1.0.
|
|
5
|
+
version="1.0.3",
|
|
6
6
|
description="A Python package that generates complex Python projects and fixes errors in your code using OpenAI's GPT API.",
|
|
7
7
|
long_description=open("README.md", "r").read(),
|
|
8
8
|
long_description_content_type="text/markdown",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scriptmonkey-1.0.1 → scriptmonkey-1.0.3}/scriptmonkey/openai_client/prompts/project_description.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|