feat: 영문 질문뱅크 러너에 Claude·Google AI Overview 엔진과 반복 회차를 추가하고 엔진별 비교 집계와 실측 결과를 넣는다
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c42b531844
commit
ec031f3149
9 files changed
+805
-12
No files matched your search
@@ -73,13 +73,15 @@ def domain(u):
|
||||
return u
|
||||
|
||||
|
||||
def out_path(d, engine):
|
||||
return os.path.join(d, f"qb_en_{engine}_results.jsonl")
|
||||
def out_path(d, engine, rep=1):
|
||||
"""rep=1 은 기존 파일명을 그대로 쓴다(기존 실측 보존). rep>=2 는 _repN 접미사."""
|
||||
suffix = "" if rep <= 1 else f"_rep{rep}"
|
||||
return os.path.join(d, f"qb_en_{engine}{suffix}_results.jsonl")
|
||||
|
||||
|
||||
def load_done(d, engine):
|
||||
def load_done(d, engine, rep=1):
|
||||
done = {}
|
||||
p = out_path(d, engine)
|
||||
p = out_path(d, engine, rep)
|
||||
if os.path.exists(p):
|
||||
for line in open(p):
|
||||
if line.strip():
|
||||
@@ -87,8 +89,8 @@ def load_done(d, engine):
|
||||
return done
|
||||
|
||||
|
||||
def summarize(d, engine, qfile):
|
||||
done = load_done(d, engine)
|
||||
def summarize(d, engine, qfile, rep=1):
|
||||
done = load_done(d, engine, rep)
|
||||
qs = json.load(open(qfile))
|
||||
cats = {"A": "Brand", "B": "Travel & logistics", "C": "Recommendation & comparison", "D": "Procedure info",
|
||||
"E": "Pricing", "F": "Safety & trust", "G": "Aftercare & remote follow-up"}
|
||||
@@ -136,7 +138,9 @@ def summarize(d, engine, qfile):
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--engine", choices=["openai", "perplexity"], default="perplexity")
|
||||
ap.add_argument("--engine", choices=["openai", "perplexity", "claude", "google_ai_overview"], default="perplexity")
|
||||
ap.add_argument("--rep", type=int, default=1, help="반복 회차. 2 이상이면 별도 파일(_repN)에 기록한다")
|
||||
ap.add_argument("--search-max-uses", type=int, default=5, help="claude 전용: 한 질문당 최대 웹검색 횟수")
|
||||
ap.add_argument("--model", default=None)
|
||||
ap.add_argument("--search-tool", default="web_search")
|
||||
ap.add_argument("--country", default="US"); ap.add_argument("--city", default="New York"); ap.add_argument("--tz", default="America/New_York")
|
||||
@@ -148,14 +152,21 @@ def main():
|
||||
base.load_dotenv()
|
||||
if a.summarize:
|
||||
summarize(a.dir, a.engine, a.questions); return
|
||||
eng = OpenAIEngineLoc(a.model or "gpt-4o", a.search_tool, a.country, a.city, a.tz) if a.engine == "openai" \
|
||||
else base.PerplexityEngine(a.model or "sonar")
|
||||
if a.engine == "openai":
|
||||
eng = OpenAIEngineLoc(a.model or "gpt-4o", a.search_tool, a.country, a.city, a.tz)
|
||||
elif a.engine == "google_ai_overview":
|
||||
eng = base.GoogleAIOverviewEngine(country=(a.country or "US").lower(), lang="en")
|
||||
elif a.engine == "claude":
|
||||
eng = base.ClaudeEngine(a.model or "claude-sonnet-5", a.search_max_uses,
|
||||
{"type": "approximate", "country": a.country, "city": a.city, "timezone": a.tz})
|
||||
else:
|
||||
eng = base.PerplexityEngine(a.model or "sonar")
|
||||
os.makedirs(a.dir, exist_ok=True)
|
||||
qs = json.load(open(a.questions)); done = load_done(a.dir, a.engine)
|
||||
qs = json.load(open(a.questions)); done = load_done(a.dir, a.engine, a.rep)
|
||||
todo = [q for q in qs if q["id"] not in done]
|
||||
if a.limit: todo = todo[:a.limit]
|
||||
print(f"{eng.name}: {len(todo)} to run ({len(done)} done)", flush=True)
|
||||
with open(out_path(a.dir, a.engine), "a") as f:
|
||||
with open(out_path(a.dir, a.engine, a.rep), "a") as f:
|
||||
for i, q in enumerate(todo, 1):
|
||||
t0 = time.time()
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user