From 1e992939d431dbd8f1250f9e61f528c8c9f5d449 Mon Sep 17 00:00:00 2001 From: davidshwn Date: Mon, 2 Feb 2026 13:03:17 +0100 Subject: [PATCH] Created init and base system prompt --- ProjectCreator.py | 115 ++++++++++++++++++++++++++++++++++++++-------- modules/init.py | 43 ++++++++++++++--- 2 files changed, 132 insertions(+), 26 deletions(-) diff --git a/ProjectCreator.py b/ProjectCreator.py index e557edd..46c86fd 100644 --- a/ProjectCreator.py +++ b/ProjectCreator.py @@ -1,38 +1,115 @@ -''' -Init -''' - # import libraries import argparse +import os + from modules.init import init # load the classes initClass = init() -''' +""" Parser functions -''' +""" + + # init funtion -def initParser(): - - pass +def initParser(args): + print("Creating project idea. This may take some time based on hardware.") + # get systemPrompt + print("Creating system prompt. (1/3") + systemPrompt: str = initClass.generatePrompt(args) + print(systemPrompt) + + # Let the LLM generate a system prompt + print("Generating Instructions (.MD) file. (2/3)") + instructions = initClass.generateMd(systemPrompt, args.model) + + print(f"Creating instructions file. (3/3)") + with open(f"{os.path.abspath(os.getcwd())}/Instructions.md", "w") as f: + f.write(instructions) + + print( + f"-- COMPLETED --\nInstructions: {os.path.abspath(os.getcwd())}/Instructions.md" + ) + return -''' +""" Main class -''' +""" + + def main(): # create the parser and subparser - parser = argparse.ArgumentParser(description="Use LLM's to create project ideas. Powered by ollama!") + parser = argparse.ArgumentParser( + description="Use LLM's to create project ideas. Powered by ollama!" + ) subparsers = parser.add_subparsers(required=True) - parser_init = subparsers.add_parser("init", help="Creates a new project using LLM's") - parser_init.add_argument("-m", "--model", help="Defines the ollama model. [Default; ministral-3]", default="ministral-3", required=False, type=str) - parser_init.add_argument("-l", "--language", help="Defines which programming language you want to create the project in. This will be send to the LLM", required=True, type=str) - parser_init.add_argument("-d", "--difficulty", help="Set your difficulty to the LLM [Default; Beginner]", default="Beginner", required=False) - parser_init.add_argument("-t", "--time", help="Set the estimated time you want to work on the project. [Default; 1 Hour]", default="1 Hour", type=str) - parser_init.add_argument("-p", "--project", help="Set the type of project. (For example; CLI-app, Website, Etc) [Default; Any]", default="Any", type=str) + parser_init = subparsers.add_parser( + "init", help="Creates a new project using LLM's" + ) + parser_init.add_argument( + "-m", + "--model", + help="Defines the ollama model. [Default; ministral-3]", + default="ministral-3", + required=False, + type=str, + ) + parser_init.add_argument( + "-l", + "--language", + help="Defines which programming language you want to create the project in. This will be send to the LLM [default: Any]", + required=False, + default="Any", + type=str, + ) + parser_init.add_argument( + "-f", + "--framework", + help="Defines a framework if prefered. [default; Not specified]", + required=False, + default="Not specified", + type=str, + ) + parser_init.add_argument( + "-e", + "--packages", + help="Defines if external packages are allowed", + required=False, + default=True, + type=bool, + ) + parser_init.add_argument( + "-d", + "--difficulty", + help="Set your difficulty to the LLM [Default; Beginner]", + default="Beginner", + required=False, + ) + parser_init.add_argument( + "-t", + "--time", + help="Set the estimated time you want to work on the project. [Default; 1 Hour]", + default="1 Hour", + type=str, + ) + parser_init.add_argument( + "-p", + "--project", + help="Set the type of project. (For example; CLI-app, Website, Etc) [Default; Any]", + default="Any", + type=str, + ) + parser_init.add_argument( + "-c", + "--custom", + help="Give the llm custom instructions if needed. [Default; None]", + default="none", + type=str, + ) parser_init.set_defaults(func=initParser) args = parser.parse_args() @@ -40,4 +117,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/modules/init.py b/modules/init.py index 6ee4a41..2718513 100644 --- a/modules/init.py +++ b/modules/init.py @@ -1,12 +1,41 @@ -from ollama import chat +from ollama import ChatResponse, chat -class init(): + +class init: def __init__(self) -> None: pass - def generateMd(self): - pass + def generateMd(self, sysPrompt, providedModel) -> str: + response: ChatResponse = chat( + model=providedModel, + messages=[ + { + "role": "system", + "content": sysPrompt, + }, + ], + ) - def generatePrompt(self) -> str: - return f"""You will give the user a markdown formatted project they can work on. -""" \ No newline at end of file + return response["message"]["content"] + + def generatePrompt(self, args) -> str: + return f"""You will give the user a markdown formatted programming project they can work on. +-- Details -- +Language: [[ {args.language} ]] +Framework: [[ {args.framework} ]] +External packages allowed: [[ {str(args.packages)} ]] +Difficulty: [[ {args.difficulty} ]] +Estimated Time the user want to spend on the project: [[ {args.time} ]] +Type of project: [[ {args.project} ]] +Custom instructions: [[ {args.custom} ]] + +-- information -- +- Align the project based on this information. +- This project is intended for users that want to practise their programming skills. +- When creating the markdown file always include the following things; header, instruction, final product, rules, general information provided by user (Details), Technical Requirements, and lastly the points (score) +- do NOT use markdown blocks as your response will immediately be injected into a .MD file upon completion. +- If the user did not provide a Programming Language (based on details) the assign the user one based on the project. Clearly define the language in the MD file +- If there is a framework (such as symfony) included (or a engine such as unity) or a library/package that requires a advanced instalation (based on difficulty), provide a installation guide in the MD file and/or a cheatsheet unless the assistant is unsure on how to set it up. +- Make the user decide on their own which packages they want to use unless explicitly specified in Custom instructions and/or General Details +- Do NOT provide any code structures or samples (unless required by previous instructions). Let the user figure it out on its own as this is intended to be a challenge +"""