Skip to content

feat: adds system-prompt.txt #108

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

Merged
merged 3 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/introduction/work-with-ai.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

<Card title="Download System Prompt" href={CODEGEN_SYSTEM_PROMPT} icon="download">
Download System Prompt
</Card>

## Codegen Playground

The [Codegen Playground](https://codegen.sh/playground) includes an integrated chat assistant purpose-built for generating Codegen programs.
Expand Down
2 changes: 2 additions & 0 deletions docs/snippets/links.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 5 additions & 0 deletions src/codegen/cli/workspace/initialize_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
35 changes: 35 additions & 0 deletions src/codegen/gscli/generate/system_prompt.py
Original file line number Diff line number Diff line change
@@ -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")
Loading