Skip to content

Commit 8600041

Browse files
jayhackcodegen-bot
and
codegen-bot
authored
feat: adds system-prompt.txt (#108)
# Motivation <!-- Why is this change necessary? --> # Content <!-- Please include a summary of the change --> # Testing <!-- How was the change tested? --> # Please check the following before marking your PR as ready for review - [ ] I have added tests for my changes - [ ] I have updated the documentation or added new documentation as needed - [ ] I have read and agree to the [Contributor License Agreement](../CLA.md) --------- Co-authored-by: codegen-bot <[email protected]>
1 parent 06b7ba6 commit 8600041

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

docs/introduction/work-with-ai.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ iconType: "solid"
77

88
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.
99

10+
## System Prompt
11+
12+
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.
13+
14+
import {
15+
CODEGEN_SYSTEM_PROMPT
16+
} from "/snippets/links.mdx";
17+
18+
<Card title="Download System Prompt" href={CODEGEN_SYSTEM_PROMPT} icon="download">
19+
Download System Prompt
20+
</Card>
21+
1022
## Codegen Playground
1123

1224
The [Codegen Playground](https://codegen.sh/playground) includes an integrated chat assistant purpose-built for generating Codegen programs.

docs/snippets/links.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ export const CODEGEN_SDK_GITHUB_URL =
55

66
export const CODEGEN_SDK_EXAMPLES_GITHUB_URL =
77
"https://github.com/codegen-sh/codegen-examples";
8+
9+
export const CODEGEN_SYSTEM_PROMPT = "https://gist.githubusercontent.com/jayhack/15681a2ceaccd726f19e6fdb3a44738b/raw/17c08054e3931b3b7fdf424458269c9e607541e8/codegen-system-prompt.txt"

src/codegen/cli/workspace/initialize_workspace.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ def modify_gitignore(codegen_folder: Path):
153153
"prompts/",
154154
"jupyter/",
155155
"",
156+
"# Python cache files",
157+
"__pycache__/",
158+
"*.py[cod]",
159+
"*$py.class",
160+
"",
156161
"# Keep config.toml and codemods",
157162
"!config.toml",
158163
"!codemods/",
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import json
2+
from pathlib import Path
3+
4+
docs = Path("./docs")
5+
mint = json.load(open(docs / "mint.json"))
6+
7+
8+
def render_page(page_str: str):
9+
return open(docs / (page_str + ".mdx")).read()
10+
11+
12+
def render_group(page_strs: list[str]):
13+
return "\n\n".join([render_page(x) for x in page_strs])
14+
15+
16+
def get_group(name) -> list[str]:
17+
group = next((x for x in mint["navigation"] if x.get("group") == name), None)
18+
if group:
19+
return group["pages"]
20+
21+
22+
def render_groups(group_names: list[str]) -> str:
23+
groups = [get_group(x) for x in group_names]
24+
return "\n\n".join([render_group(g) for g in groups])
25+
26+
27+
def get_system_prompt() -> str:
28+
"""Generates a string system prompt based on the docs"""
29+
return render_groups(["Introduction", "Building with Codegen", "Tutorials"])
30+
31+
32+
if __name__ == "__main__":
33+
system_prompt = get_system_prompt()
34+
open("/tmp/system-prompt.txt", "w").write(system_prompt)
35+
print("Wrote to /tmp/system-prompt.txt")

0 commit comments

Comments
 (0)