Skip to content

Commit 192b36e

Browse files
committed
check and see if ai generated description exists before calling api
1 parent 3daec1f commit 192b36e

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

generate_docs.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,18 @@ def generate_markdown(service_folder_name, compose_content, ports_info, output_d
178178
title_name = title_name.replace("Universitysystem", "University System")
179179

180180
print(f"Generating description for: {title_name}")
181-
description = get_chatbot_response(title_name)
181+
# check if description already exists to avoid unnecessary API calls
182+
existing_md_path = output_dir / f"{service_folder_name}.md"
183+
if existing_md_path.exists():
184+
existing_content = existing_md_path.read_text()
185+
desc_match = re.search(r"## Description\s+([\s\S]+?)\s+## Docker Compose File", existing_content)
186+
if desc_match:
187+
description = desc_match.group(1).strip()
188+
print(f"Using existing description for: {title_name}")
189+
else:
190+
description = get_chatbot_response(title_name)
191+
else:
192+
description = get_chatbot_response(title_name)
182193
# description = "This is a test"
183194
notes = notes.replace(
184195
"[http://cheeselab:1313](http://cheeselab:1313) (Local Network Only)",

0 commit comments

Comments
 (0)