fix: simplify Perplexity prompt — short system + direct user query

Long system prompt caused sonar-pro to return empty results.
Reverted to sonar model with short, proven prompt pattern that
matches the user's successful manual test.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Haewon Kam 2026-04-04 01:32:54 +09:00
parent e64d168d34
commit ac2da7a4ac
2 changed files with 5 additions and 81 deletions

View File

@ -5,89 +5,13 @@
* Model: sonar-pro (advanced web search with multi-step reasoning) * Model: sonar-pro (advanced web search with multi-step reasoning)
*/ */
export const RESEARCH_SYSTEM_PROMPT = `당신은 성형외과/피부과 병원의 온라인 프레즌스를 조사·정리하는 리서치 전문가 에이전트입니다. export const RESEARCH_SYSTEM_PROMPT = `You are a social media researcher. Search the web and find social media accounts for Korean medical clinics. Respond ONLY with valid JSON, no explanation.`;
목표:
- 사용자가 지정한 병원의 Online Presence를 정량·정성적으로 분석하여
채널별 (웹사이트, 유튜브, 인스타그램, 리뷰/플랫폼 등) 현황을 정리합니다.
반드시 지킬 규칙:
1) 검색 전략
- 질의를 2~3개의 짧은 키워드 검색으로 쪼갭니다.
- "<병원명> 유튜브 채널"
- "<병원명> 인스타그램"
- "<병원명> 후기 리뷰"
- 검색 결과에서 다음 URL 유형을 우선 확인합니다:
- 병원 공식 웹사이트
- YouTube 채널/영상
- Instagram 공식 계정
- 리뷰/평점 플랫폼 (강남언니, 바비톡, RealSelf, Bookimed, 대다모, 성예사 등)
2) 채널별 필수 수집 항목
유튜브:
- 공식 채널명, 채널 URL, @핸들
- 구독자 수 (숫자 또는 범위 추정)
- 업로드 영상 수
- 콘텐츠 유형
인스타그램:
- 계정 ID (@handle) — 여러 계정 가능 (국문, 영문, 원장 개인 등)
- 팔로워 수
- 게시물 수
- 주요 콘텐츠 유형
웹사이트:
- 공식 도메인
- 언어 버전 (국문/영문/다국어)
리뷰·후기:
- 강남언니: 평점(/10), 리뷰 수, URL
- 네이버 플레이스: 등록 여부
- Google Maps: 평점, 리뷰 수
- 기타 (바비톡, RealSelf 등)
페이스북/틱톡/네이버블로그/카카오:
- 계정 URL 또는 핸들
- 팔로워/구독자 수 (확인 가능한 경우)
3) 응답 포맷
반드시 아래 JSON 구조로 응답하세요. 설명 텍스트 없이 JSON만 반환하세요.
{
"clinicName": "병원 한국어 이름",
"clinicNameEn": "English name",
"channels": {
"instagram": [
{"handle": "@handle", "followers": 숫자_또는_null, "posts": 숫자_또는_null, "type": "공식/영문/원장 등", "url": "URL"}
],
"youtube": [
{"handle": "@handle_또는_채널명", "channelUrl": "URL", "subscribers": 숫자_또는_null, "videos": 숫자_또는_null, "contentType": "설명"}
],
"facebook": {"handle": "페이지명", "url": "URL", "followers": 숫자_또는_null},
"tiktok": {"handle": "@handle", "url": "URL", "followers": 숫자_또는_null},
"naverBlog": {"blogId": "ID", "url": "URL"},
"kakao": {"channelId": "ID", "url": "URL"},
"website": {"domain": "도메인", "languages": ["ko", "en"]}
},
"platforms": {
"gangnamUnni": {"registered": true, "url": "URL", "rating": 숫자_또는_null, "ratingScale": 10, "reviews": 숫자_또는_null},
"naverPlace": {"registered": true, "rating": 숫자_또는_null, "reviews": 숫자_또는_null},
"googleMaps": {"rating": 숫자_또는_null, "reviews": 숫자_또는_null},
"babitok": {"registered": true}
},
"summary": "1-2문장 온라인 프레즌스 요약"
}
4) 주의사항
- 수치가 정확하면 숫자로, 확인 불가하면 null로 표시
- 추측하지 말고 검색 결과에서 확인된 정보만 포함
- 설명 텍스트 없이 JSON만 반환`;
/** /**
* Build the user prompt for the research agent. * Build the user prompt for the research agent.
*/ */
export function buildResearchUserPrompt(clinicName: string, websiteUrl?: string): string { export function buildResearchUserPrompt(clinicName: string, websiteUrl?: string): string {
return `"${clinicName}" 병원의 Online Presence를 위 규칙대로 분석해줘.${websiteUrl ? ` 공식 웹사이트: ${websiteUrl}` : ''}`; return `${clinicName} 병원의 인스타그램, 유튜브, 페이스북, 틱톡, 네이버블로그, 카카오채널 계정을 검색해서 찾아줘. 강남언니, 네이버 플레이스, 바비톡 등록 현황도 검색해줘. 인스타그램은 여러 계정이 있을 수 있어 (국문용, 영문용 등). 검색 결과에서 발견된 모든 계정을 알려줘.${websiteUrl ? ` 공식 웹사이트: ${websiteUrl}` : ''}
{"channels":{"instagram":[{"handle":"@handle","followers":숫자}],"youtube":[{"handle":"@handle","subscribers":숫자}],"facebook":"page","tiktok":"@handle","naverBlog":"blogId","kakao":"channelId","website":"${websiteUrl || 'domain'}"},"platforms":{"gangnamUnni":{"registered":true,"url":"URL","rating":숫자,"reviews":숫자},"naverPlace":{"registered":true},"babitok":{"registered":true}}}`;
} }

View File

@ -294,7 +294,7 @@ Deno.serve(async (req) => {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json", Authorization: `Bearer ${PERPLEXITY_API_KEY}` }, headers: { "Content-Type": "application/json", Authorization: `Bearer ${PERPLEXITY_API_KEY}` },
body: JSON.stringify({ body: JSON.stringify({
model: "sonar-pro", model: "sonar",
messages: [ messages: [
{ role: "system", content: RESEARCH_SYSTEM_PROMPT }, { role: "system", content: RESEARCH_SYSTEM_PROMPT },
{ role: "user", content: buildResearchUserPrompt(resolvedName, url) }, { role: "user", content: buildResearchUserPrompt(resolvedName, url) },