Skip to content

Commit 19b3e8f

Browse files
author
codegen-bot
committed
.
1 parent 5e2edba commit 19b3e8f

File tree

4 files changed

+136
-0
lines changed

4 files changed

+136
-0
lines changed

Untitled.ipynb

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "0",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"import json\n",
11+
"from pathlib import Path\n",
12+
"\n",
13+
"docs = Path(\"./docs\")\n",
14+
"mint = json.load(open(docs / \"mint.json\"))"
15+
]
16+
},
17+
{
18+
"cell_type": "code",
19+
"execution_count": null,
20+
"id": "1",
21+
"metadata": {},
22+
"outputs": [],
23+
"source": [
24+
"def render_page(page_str: str):\n",
25+
" return open(docs / (page_str + \".mdx\")).read()\n",
26+
"\n",
27+
"\n",
28+
"def render_group(page_strs: list[str]):\n",
29+
" return \"\\n\\n\".join([render_page(x) for x in page_strs])\n",
30+
"\n",
31+
"\n",
32+
"def get_group(name) -> list[str]:\n",
33+
" group = next((x for x in mint[\"navigation\"] if x.get(\"group\") == name), None)\n",
34+
" if group:\n",
35+
" return group[\"pages\"]\n",
36+
"\n",
37+
"\n",
38+
"def render_groups(group_names: list[str]) -> str:\n",
39+
" groups = [get_group(x) for x in group_names]\n",
40+
" return \"\\n\\n\".join([render_group(g) for g in groups])\n",
41+
"\n",
42+
"\n",
43+
"def get_system_prompt():\n",
44+
" return render_groups([\"Introduction\", \"Building with Codegen\", \"Tutorials\"])"
45+
]
46+
},
47+
{
48+
"cell_type": "code",
49+
"execution_count": null,
50+
"id": "2",
51+
"metadata": {},
52+
"outputs": [],
53+
"source": [
54+
"get_system_prompt(\"test\")"
55+
]
56+
},
57+
{
58+
"cell_type": "code",
59+
"execution_count": null,
60+
"id": "3",
61+
"metadata": {},
62+
"outputs": [],
63+
"source": []
64+
}
65+
],
66+
"metadata": {
67+
"kernelspec": {
68+
"display_name": "Python 3 (ipykernel)",
69+
"language": "python",
70+
"name": "python3"
71+
},
72+
"language_info": {
73+
"codemirror_mode": {
74+
"name": "ipython",
75+
"version": 3
76+
},
77+
"file_extension": ".py",
78+
"mimetype": "text/x-python",
79+
"name": "python",
80+
"nbconvert_exporter": "python",
81+
"pygments_lexer": "ipython3",
82+
"version": "3.12.7"
83+
}
84+
},
85+
"nbformat": 4,
86+
"nbformat_minor": 5
87+
}

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"
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)