feat: add IP geolocation tracking and include location in prompts

- Add GeoLite2-City.mmdb database for IP lookup
- Create geoip.py module for IP location services
- Extract client IP from requests and log location info
- Pass location context to LLM prompts for enhanced responses
This commit is contained in:
2026-02-18 08:59:28 +08:00
parent 2b79f20e19
commit d2b64ad5d6
7 changed files with 181 additions and 13 deletions
+3 -2
View File
@@ -29,12 +29,13 @@ def prepare_prompt_context(prefix: str, suffix: str) -> Tuple[str, str]:
return _prepare_context(prefix, suffix)
def build_prompt(prefix: str, suffix: str, language_id: str = "markdown") -> str:
def build_prompt(prefix: str, suffix: str, language_id: str = "markdown", location: str = "") -> str:
safe_language_id = _sanitize_language_id(language_id)
recent_prefix, recent_suffix = _prepare_context(prefix, suffix)
current_time = _get_current_datetime()
location_info = f"\nUser location: {location}" if location else ""
prompt = f"""Current time: {current_time}
prompt = f"""Current time: {current_time}{location_info}
You are an inline completion engine for a {safe_language_id} editor with ghost-text suggestions.