Skip to content

CG-10610: System Prompt Generation #221

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 7 commits into from
Jan 30, 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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ repos:
files: '' # Check all files
- id: generate-runner-imports
name: Generate Runner Imports
entry: bash -c "uv run --frozen python -m codegen.gscli.main generate runner-imports src/codegen/shared/compilation/function_imports.py"
entry: bash -c "uv run --frozen python -m codegen.gscli.cli generate runner-imports src/codegen/shared/compilation/function_imports.py"
language: system
pass_filenames: false
always_run: true
2 changes: 1 addition & 1 deletion docs/snippets/links.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ 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"
export const CODEGEN_SYSTEM_PROMPT = "https://raw.githubusercontent.com/codegen-sh/codegen-sdk/refs/heads/develop/src/codegen/sdk/system-prompt.txt"
10 changes: 2 additions & 8 deletions src/codegen/gscli/main.py → src/codegen/gscli/cli.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
#!/bin/python
import logging

import click

from codegen.gscli.generate.commands import generate


@click.group()
def cli() -> None:
def main() -> None:
pass


# ============= Import all command groups =============
cli.add_command(generate)


def main() -> None:
logging.basicConfig(level=logging.INFO)
cli()
main.add_command(generate)


if __name__ == "__main__":
Expand Down
19 changes: 12 additions & 7 deletions src/codegen/gscli/generate/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import click
from termcolor import colored

import codegen.sdk as sdk
from codegen.gscli.generate.runner_imports import _generate_runner_imports
from codegen.gscli.generate.system_prompt import get_system_prompt
from codegen.gscli.generate.utils import LanguageType, generate_builtins_file
from codegen.sdk.code_generation.codegen_sdk_codebase import get_codegen_sdk_codebase
from codegen.sdk.code_generation.doc_utils.generate_docs_json import generate_docs_json
Expand Down Expand Up @@ -104,9 +106,16 @@ def generate_docs(docs_dir: str) -> None:
This will generate docs using the codebase locally, including any unstaged changes
"""
generate_codegen_sdk_docs(docs_dir)
# generate_canonical_codemod_docs(docs_dir, codebase)
# generate_skills_docs(docs_dir)
# generate_guides(docs_dir)


@generate.command()
@click.argument("filepath", default=sdk.__path__[0] + "/system-prompt.txt", required=False)
def system_prompt(filepath: str) -> None:
print(f"Generating system prompt and writing to {filepath}...")
new_system_prompt = get_system_prompt()
with open(filepath, "w") as f:
f.write(new_system_prompt)
print(f"Successfully wrote system prompt to {filepath}.")


def get_snippet_pattern(target_name: str) -> str:
Expand Down Expand Up @@ -186,7 +195,3 @@ def generate_codegen_sdk_docs(docs_dir: str) -> None:
json.dump(mint_data, mint_file, indent=2)

print(colored("Updated mint.json with new page sets", "green"))


if __name__ == "__main__":
generate()
6 changes: 0 additions & 6 deletions src/codegen/gscli/generate/system_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,3 @@ def render_groups(group_names: list[str]) -> str:
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