Skip to content
Merged
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
30 changes: 20 additions & 10 deletions aws_doc_sdk_examples_tools/agent/make_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

from aws_doc_sdk_examples_tools.doc_gen import DocGen, Snippet

DEFAULT_METADATA_PREFIX = "[DEFAULT]"


# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand All @@ -23,16 +26,23 @@ def write_prompts(doc_gen: DocGen, out_dir: Path, language: str) -> None:
examples = doc_gen.examples
snippets = doc_gen.snippets
for example_id, example in examples.items():
prompt_path = out_dir / f"{example_id}.md"
snippet_key = (
example.languages[language]
.versions[0]
.excerpts[0]
.snippet_files[0]
.replace("/", ".")
)
snippet = snippets[snippet_key]
prompt_path.write_text(snippet.code, encoding="utf-8")
# "Title" and "Abbrev" are the defaults. If they're not there, it suggests we've already
# added new titles.
title = example.title or ""
title_abbrev = example.title_abbrev or ""
if title.startswith(DEFAULT_METADATA_PREFIX) and title_abbrev.startswith(
DEFAULT_METADATA_PREFIX
):
prompt_path = out_dir / f"{example_id}.md"
snippet_key = (
example.languages[language]
.versions[0]
.excerpts[0]
.snippet_files[0]
.replace("/", ".")
)
snippet = snippets[snippet_key]
prompt_path.write_text(snippet.code, encoding="utf-8")


def setup_ailly(system_prompts: List[str], out_dir: Path) -> None:
Expand Down