pubmed_search: exclude_paper_types(RCT 제외 등) 추가

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
kimandClaude Sonnet 5.5 committed 2026-10-19 21:33:48 +09:00
1 parent d9bd60abfb
commit 16c4ba2c0f
3 files changed
+13 -4

No files matched your search

+1
View File
@@ -663,6 +663,7 @@ export function createBuildTools(isOrchestrationSkillEnabled: () => boolean) {
compact: { type: 'boolean', description: 'true = one line per result (PMID | journal | year | title) and max_results up to 200 — use to read a long result set in one call' },
journals: { type: 'string', description: 'Restrict to dental journals: "dental" (JOE, IEJ, JAD, JERD, Oper Dent, Dent Mater, JDR, J Dent, Clin Oral Investig, Dent Mater J, Am J Dent, J Conserv Dent) or comma-separated ids (joe,iej,jad,jerd,od,dm,jdr,jdent,coi,dmj,ajd,jcd). Use for 치과 저널/치의학 논문 requests; query must be English keywords.' },
paper_types: { type: 'string', description: 'Comma-separated: rct,ct,sr,ma,review,obs,case,guide' },
exclude_paper_types: { type: 'string', description: 'Same ids; excludes them (e.g. "rct" when the user says RCT 빼고/RCT 제외). Prefer this over guessing with query words.' },
},
},
},
+8 -2
View File
@@ -29,7 +29,7 @@ export const PAPER_TYPES: { id: string; label: string; pt: string }[] = [
// 채팅 도구(pubmed_search)용: 저널·논문 종류 id를 PubMed 검색식으로 감싼다.
// journals: "dental"|"all"(치과 저널 전체) 또는 id/약칭 목록(쉼표 구분 문자열·배열). 알 수 없는 값은 unknown에 모은다.
export function applyDentalFilters(query: string, journals: unknown, paperTypes: unknown): { term: string; unknown: string[] } {
export function applyDentalFilters(query: string, journals: unknown, paperTypes: unknown, excludeTypes?: unknown): { term: string; unknown: string[] } {
const list = (v: unknown): string[] => (Array.isArray(v) ? v : String(v ?? '').split(','))
.map(x => String(x).trim().toLowerCase()).filter(Boolean);
const unknown: string[] = [];
@@ -47,5 +47,11 @@ export function applyDentalFilters(query: string, journals: unknown, paperTypes:
for (const x of ts) if (!PAPER_TYPES.some(t => t.id === x)) unknown.push(x);
if (picked.length) clauses.push('(' + picked.map(t => `"${t.pt}"[pt]`).join(' OR ') + ')');
}
return { term: clauses.join(' AND '), unknown };
const xs = list(excludeTypes);
if (xs.length) {
const picked = PAPER_TYPES.filter(t => xs.includes(t.id));
for (const x of xs) if (!PAPER_TYPES.some(t => t.id === x)) unknown.push(x);
if (picked.length) clauses.push('NOT (' + picked.map(t => `"${t.pt}"[pt]`).join(' OR ') + ')');
}
return { term: clauses.join(' AND ').replace(/ AND NOT /g, ' NOT '), unknown };
}
+4 -2
View File
@@ -71,6 +71,7 @@ export const pubmedSearchTool = {
compact: 'Optional: true = one line per result ("PMID | journal | year | title"), allows max_results up to 200 — use to read a long result set in one call',
journals: 'Optional: restrict to dental journals — "dental" (all 12) or comma-separated ids: ' + DENTAL_JOURNALS.map(j => j.id).join(','),
paper_types: 'Optional: comma-separated paper types: ' + PAPER_TYPES.map(t => t.id).join(','),
exclude_paper_types: 'Optional: paper types to exclude (e.g. "rct" for 비RCT), same ids',
},
jsonSchema: {
type: 'object',
@@ -83,6 +84,7 @@ export const pubmedSearchTool = {
compact: { type: 'boolean', description: 'One line per result, max_results up to 200' },
journals: { type: 'string', description: 'Dental journal filter: "dental" or comma-separated ids' },
paper_types: { type: 'string', description: 'Paper type filter, comma-separated ids' },
exclude_paper_types: { type: 'string', description: 'Paper types to exclude, comma-separated ids' },
},
required: ['query'],
additionalProperties: false,
@@ -100,8 +102,8 @@ export const pubmedSearchTool = {
const sort = args?.sort === 'date' ? 'pub+date' : 'relevance';
const minYear = args?.min_year ? Number(args.min_year) : null;
if (args?.journals || args?.paper_types) {
const f = applyDentalFilters(query, args.journals, args.paper_types);
if (args?.journals || args?.paper_types || args?.exclude_paper_types) {
const f = applyDentalFilters(query, args.journals, args.paper_types, args.exclude_paper_types);
if (f.unknown.length) return { success: false, error: `unknown journals/paper_types: ${f.unknown.join(', ')}` };
query = f.term;
}