completed the portland_wildlife_dex_entries.csv

added a method to skip species that don't have a wiki page
This commit is contained in:
Suppai_Neko committed 2026-03-26 15:45:28 -07:00
1 parent 8978130b7c
commit de8a7e7c66
2 files changed
+209 -1

No files matched your search

+7 -1
View File
@@ -8,7 +8,7 @@ from urllib.parse import urlparse
import requests
from bs4 import BeautifulSoup
from dotenv import load_dotenv
from openai import OpenAI
from openai import OpenAI, BadRequestError
load_dotenv(Path(__file__).parent.parent / ".env")
@@ -137,6 +137,9 @@ def prompt_llm(prompt: str) -> str:
"tool_call_id": tc.id,
"content": result,
})
# Some models (e.g. Qwen via LM Studio) require a user message to
# follow tool results or their jinja prompt template errors out.
messages.append({"role": "user", "content": "Now write the Pokédex entry."})
# ---------------------------------------------------------------------------
# CSV
@@ -186,6 +189,9 @@ if __name__ == "__main__":
except requests.HTTPError:
print(f" No article found, skipping.")
continue
except BadRequestError as e:
print(f" Bad request error, skipping: {e}")
continue
description = re.sub(r"[^A-Za-z0-9.,!?'\-: ]", "", description)
print(f" {description}")
writer.writerow([taxon_id, specie["common_name"], description])