diff --git a/docs/introduction/work-with-ai.mdx b/docs/introduction/work-with-ai.mdx index dc5e7cd53..fb63578c6 100644 --- a/docs/introduction/work-with-ai.mdx +++ b/docs/introduction/work-with-ai.mdx @@ -7,6 +7,18 @@ iconType: "solid" Codegen is designed to be used with AI assistants. This document describes how to use Codegen with common AI tools, including Copilot, Cursor, Devin and more. +## System Prompt + +Codegen provides a `.txt` file that you can drag-and-drop into any chat assistant. This is roughly 60k tokens and will enable chat assistants like, ChatGPT, Claude 3.5 etc. to build effectively with Codegen. + +import { + CODEGEN_SYSTEM_PROMPT +} from "/snippets/links.mdx"; + + + Download System Prompt + + ## Codegen Playground The [Codegen Playground](https://codegen.sh/playground) includes an integrated chat assistant purpose-built for generating Codegen programs. diff --git a/docs/snippets/links.mdx b/docs/snippets/links.mdx index 3ec8cb712..bb9332ee5 100644 --- a/docs/snippets/links.mdx +++ b/docs/snippets/links.mdx @@ -5,3 +5,5 @@ export const CODEGEN_SDK_GITHUB_URL = export const CODEGEN_SDK_EXAMPLES_GITHUB_URL = "https://github.com/codegen-sh/codegen-examples"; + +export const CODEGEN_SYSTEM_PROMPT = "https://gist.githubusercontent.com/jayhack/15681a2ceaccd726f19e6fdb3a44738b/raw/17c08054e3931b3b7fdf424458269c9e607541e8/codegen-system-prompt.txt" \ No newline at end of file diff --git a/src/codegen/cli/workspace/initialize_workspace.py b/src/codegen/cli/workspace/initialize_workspace.py index 8c7839d20..eac71b5c3 100644 --- a/src/codegen/cli/workspace/initialize_workspace.py +++ b/src/codegen/cli/workspace/initialize_workspace.py @@ -153,6 +153,11 @@ def modify_gitignore(codegen_folder: Path): "prompts/", "jupyter/", "", + "# Python cache files", + "__pycache__/", + "*.py[cod]", + "*$py.class", + "", "# Keep config.toml and codemods", "!config.toml", "!codemods/", diff --git a/src/codegen/gscli/generate/system_prompt.py b/src/codegen/gscli/generate/system_prompt.py new file mode 100644 index 000000000..3ab2aefd1 --- /dev/null +++ b/src/codegen/gscli/generate/system_prompt.py @@ -0,0 +1,35 @@ +import json +from pathlib import Path + +docs = Path("./docs") +mint = json.load(open(docs / "mint.json")) + + +def render_page(page_str: str): + return open(docs / (page_str + ".mdx")).read() + + +def render_group(page_strs: list[str]): + return "\n\n".join([render_page(x) for x in page_strs]) + + +def get_group(name) -> list[str]: + group = next((x for x in mint["navigation"] if x.get("group") == name), None) + if group: + return group["pages"] + + +def render_groups(group_names: list[str]) -> str: + groups = [get_group(x) for x in group_names] + return "\n\n".join([render_group(g) for g in groups]) + + +def get_system_prompt() -> str: + """Generates a string system prompt based on the docs""" + return render_groups(["Introduction", "Building with Codegen", "Tutorials"]) + + +if __name__ == "__main__": + system_prompt = get_system_prompt() + open("/tmp/system-prompt.txt", "w").write(system_prompt) + print("Wrote to /tmp/system-prompt.txt")