feat(maps): 국내 지도는 구글 대신 카카오맵 임베드
채팅 화면에서 map.kakao.com/link/(map|search|to)/... 한 줄 URL을 인라인 지도(iframe)로 바꾼다. MAPS 프롬프트는 국내 장소에 카카오맵 링크(좌표 있으면 link/map, 없으면 link/search), 해외만 구글로 바꾸고 place_search 결과의 지도 URL을 한 줄로 내도록 했다. 링크의 ( ) ! ' * 도 인코딩. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
74c323e9da
commit
07b3d42f3d
3 files changed
+12
-3
No files matched your search
@@ -223,11 +223,11 @@ export function buildChatSystemPrompt(input: SystemPromptInput): string {
|
||||
// /maps/dir/ is not embedded.
|
||||
// place_search(카카오맵)가 있을 때: 장소 주소·전화·거리는 도구로 찾는다. 기억으로 주소를 짓지 않는다.
|
||||
const placeSearchRuleBlock = toolNames.has('place_search')
|
||||
? '\nPLACE SEARCH: For a specific place, business, or "near X" request in Korea (restaurants, pharmacies, stations, an address or phone number), call place_search FIRST and answer from its results — never write an address or phone number from memory. Default reference point is 구미시; pass location for another area. Give the 카카오맵 link from the result for each place you recommend. Opening hours are not in the result: point to its 상세 link instead of guessing.'
|
||||
? '\nPLACE SEARCH: For a specific place, business, or "near X" request in Korea (restaurants, pharmacies, stations, an address or phone number), call place_search FIRST and answer from its results — never write an address or phone number from memory. Default reference point is 구미시; pass location for another area. Put the 카카오맵 `지도:` URL from the result for the top place on its own line so it renders as an inline map, and mention the others by name. Opening hours are not in the result: point to its 상세 link instead of guessing.'
|
||||
: '';
|
||||
const mapsRuleBlock = /지도|맵으로|위치(를|가|는)?|주소|어디(에|야|예요|에요|입니까|인가|니|냐|쯤|메)|어디\s*(있|찾|가|계|위치|살|사는|근처)|길\s*찾|가는\s*길|찾아가|찾아오|약도|도로명|지번|좌표|경위도|근처|인근|부근|가까운|\bmap\b|\baddress\b|directions|navigate|where\s+is|how\s+(do\s+i\s+|to\s+)get\s+to|nearby|landmark/i
|
||||
.test(String(input.message || ''))
|
||||
? '\nMAPS: When the user asks where a place is, for its address, or to see a map of a location, output `https://www.google.com/maps/search/<query>` on its own line — URL-encode the query, use the specific place name (add city/country when ambiguous). The client turns that standalone line into an inline map. Do NOT call browser_open for it and do NOT wrap it in ``. Still answer in text as well — the map is an addition, not a replacement. Not for pure route/turn-by-turn directions (those do not render).'
|
||||
? '\nMAPS: When the user asks where a place is, for its address, or to see a map of a location, output the map URL on its own line — the client turns that standalone line into an inline map. For places IN KOREA use 카카오맵: `https://map.kakao.com/link/map/<URL-encoded name>,<lat>,<lon>` when you have coordinates (e.g. from place_search), otherwise `https://map.kakao.com/link/search/<URL-encoded query>`. Use Google only for places OUTSIDE Korea: `https://www.google.com/maps/search/<query>` (URL-encode, add city/country when ambiguous). Do NOT call browser_open for it and do NOT wrap it in ``. Still answer in text as well — the map is an addition, not a replacement. Not for pure route/turn-by-turn directions (those do not render).'
|
||||
: '';
|
||||
// VERIFY CONCRETE FACTS는 ANTI-HALLUCINATION 안에 무조건 붙어 있었지만, 하는 말이 통째로
|
||||
// "web_search를 먼저 불러라"다 — 그 도구가 이번 턴 스키마에 없으면 실행 불가능한 지시이고,
|
||||
|
||||
@@ -58,7 +58,9 @@ export function formatPlaces(docs: PlaceDoc[], originName: string, total?: numbe
|
||||
const cat = String(d.category_name || '').split('>').map(s => s.trim()).filter(Boolean).slice(-2).join(' > ');
|
||||
const addr = d.road_address_name || d.address_name || '';
|
||||
const dist = fmtDistance(d.distance);
|
||||
const map = d.y && d.x ? `https://map.kakao.com/link/map/${encodeURIComponent(name)},${d.y},${d.x}` : (d.place_url || '');
|
||||
// ( ) ! ' * 는 encodeURIComponent가 그대로 두는데, 채팅 화면의 한 줄 URL 변환이 ')'에서 끊기므로 같이 인코딩한다.
|
||||
const encName = encodeURIComponent(name).replace(/[()!'*]/g, c => '%' + c.charCodeAt(0).toString(16).toUpperCase());
|
||||
const map = d.y && d.x ? `https://map.kakao.com/link/map/${encName},${d.y},${d.x}` : (d.place_url || '');
|
||||
lines.push(`${i + 1}. ${name}${cat ? ` (${cat})` : ''}${dist ? ` — ${dist}` : ''}`);
|
||||
if (addr) lines.push(` 주소: ${addr}`);
|
||||
if (d.phone) lines.push(` 전화: ${d.phone}`);
|
||||
|
||||
@@ -254,6 +254,13 @@ function renderMarkdown(text, opts) {
|
||||
return pre + '<div class="yt-embed-wrap"><iframe class="yt-embed" src="' + safeEmbed + '" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" loading="lazy"></iframe><div class="map-embed-link"><a href="' + safeOrig + '" target="_blank" rel="noopener">YouTube에서 열기 ↗</a></div></div>' + post;
|
||||
});
|
||||
|
||||
// Kakao Map URLs on their own line → inline iframe (2026-10-14: 국내 지도는 구글 대신 카카오맵).
|
||||
// map.kakao.com/link/map|search|to/... 는 이름·좌표만으로 열리는 공개 링크 형식이다(키 불필요).
|
||||
html = html.replace(/((?:^|\n)[ \t]*)(https:\/\/map\.kakao\.com\/link\/(?:map|search|to)\/[^\s<>")\n]+)([ \t]*)(?=\n|$)/gim, function(m, pre, url, post) {
|
||||
var safeEmbed = url.replace(/"/g, '"');
|
||||
return pre + '<div class="map-embed-wrap"><iframe class="map-embed" src="' + safeEmbed + '" allowfullscreen loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe><div class="map-embed-link"><a href="' + safeEmbed + '" target="_blank" rel="noopener">카카오맵에서 열기 ↗</a></div></div>' + post;
|
||||
});
|
||||
|
||||
// Google Maps URLs on their own line → inline iframe
|
||||
html = html.replace(/((?:^|\n)[ \t]*)(https?:\/\/(?:www\.google\.com\/maps|maps\.google\.com|goo\.gl\/maps)[^\s<>")\n]*)([ \t]*)(?=\n|$)/gim, function(m, pre, url, post) {
|
||||
var embedUrl = mapsToEmbedUrl(url);
|
||||
|
||||
Reference in new issue
Block a user