report output format 변경 및 clinic info출력 추가
This commit is contained in:
1 parent
c1f39aceff
commit
9b4e99abf9
7 files changed
+689
-55
No files matched your search
@@ -45,6 +45,7 @@ class LLMService:
|
||||
response = await self.client.chat.completions.create(
|
||||
model=prompt.model,
|
||||
messages=[{"role": "user", "content": prompt_text}],
|
||||
max_tokens=16000,
|
||||
response_format={
|
||||
"type": "json_schema",
|
||||
"json_schema": {"name": prompt.output_class.__name__, "schema": prompt.output_class.model_json_schema()},
|
||||
|
||||
@@ -1,8 +1,316 @@
|
||||
from __future__ import annotations
|
||||
from typing import Literal
|
||||
from pydantic import BaseModel
|
||||
|
||||
Severity = Literal["critical", "warning", "good", "excellent", "unknown"]
|
||||
ChannelStatus = Literal["active", "inactive", "unknown", "not_found"]
|
||||
DataSource = Literal["registry", "scrape"]
|
||||
Language = Literal["KR", "EN"]
|
||||
VideoType = Literal["Short", "Long"]
|
||||
AnnotationType = Literal["highlight", "arrow", "text"]
|
||||
|
||||
|
||||
class ScreenshotAnnotation(BaseModel):
|
||||
type: AnnotationType
|
||||
x: float
|
||||
y: float
|
||||
width: float | None = None
|
||||
height: float | None = None
|
||||
label: str | None = None
|
||||
color: str | None = None
|
||||
|
||||
|
||||
class ScreenshotEvidence(BaseModel):
|
||||
id: str
|
||||
url: str
|
||||
channel: str
|
||||
captured_at: str
|
||||
caption: str
|
||||
source_url: str | None = None
|
||||
annotations: list[ScreenshotAnnotation] | None = None
|
||||
|
||||
|
||||
class DiagnosisItem(BaseModel):
|
||||
category: str
|
||||
detail: str
|
||||
severity: Severity
|
||||
evidence_ids: list[str] | None = None
|
||||
|
||||
|
||||
# --- ClinicSnapshot ---
|
||||
|
||||
class LeadDoctor(BaseModel):
|
||||
name: str
|
||||
credentials: str
|
||||
rating: float
|
||||
review_count: int
|
||||
|
||||
|
||||
class PriceRange(BaseModel):
|
||||
min: str
|
||||
max: str
|
||||
currency: str
|
||||
|
||||
|
||||
class LogoImages(BaseModel):
|
||||
circle: str | None = None
|
||||
horizontal: str | None = None
|
||||
korean: str | None = None
|
||||
|
||||
|
||||
class BrandColors(BaseModel):
|
||||
primary: str
|
||||
accent: str
|
||||
text: str
|
||||
|
||||
|
||||
class RegistryData(BaseModel):
|
||||
district: str | None = None
|
||||
branches: str | None = None
|
||||
brand_group: str | None = None
|
||||
website_en: str | None = None
|
||||
naver_place_url: str | None = None
|
||||
gangnam_unni_url: str | None = None
|
||||
google_maps_url: str | None = None
|
||||
|
||||
|
||||
class ClinicSnapshot(BaseModel):
|
||||
name: str
|
||||
name_en: str
|
||||
established: str
|
||||
years_in_business: int
|
||||
staff_count: int
|
||||
lead_doctor: LeadDoctor
|
||||
overall_rating: float
|
||||
total_reviews: int
|
||||
price_range: PriceRange
|
||||
certifications: list[str]
|
||||
media_appearances: list[str]
|
||||
medical_tourism: list[str]
|
||||
location: str
|
||||
nearest_station: str
|
||||
phone: str
|
||||
domain: str
|
||||
logo_images: LogoImages | None = None
|
||||
brand_colors: BrandColors | None = None
|
||||
source: DataSource | None = None
|
||||
registry_data: RegistryData | None = None
|
||||
|
||||
|
||||
# --- ChannelScore ---
|
||||
|
||||
class ChannelScore(BaseModel):
|
||||
channel: str
|
||||
icon: str
|
||||
score: int
|
||||
max_score: int
|
||||
status: Severity
|
||||
headline: str
|
||||
|
||||
|
||||
# --- YouTube ---
|
||||
|
||||
class WeeklyViewGrowth(BaseModel):
|
||||
absolute: int
|
||||
percentage: float
|
||||
|
||||
|
||||
class EstimatedRevenue(BaseModel):
|
||||
min: int
|
||||
max: int
|
||||
|
||||
|
||||
class LinkedUrl(BaseModel):
|
||||
label: str
|
||||
url: str
|
||||
|
||||
|
||||
class TopVideo(BaseModel):
|
||||
title: str
|
||||
views: int
|
||||
uploaded_ago: str
|
||||
type: VideoType
|
||||
duration: str | None = None
|
||||
|
||||
|
||||
class YouTubeAudit(BaseModel):
|
||||
channel_name: str
|
||||
handle: str
|
||||
subscribers: int
|
||||
total_videos: int
|
||||
total_views: int
|
||||
weekly_view_growth: WeeklyViewGrowth
|
||||
estimated_monthly_revenue: EstimatedRevenue
|
||||
avg_video_length: str
|
||||
upload_frequency: str
|
||||
channel_created_date: str
|
||||
subscriber_rank: str
|
||||
channel_description: str
|
||||
linked_urls: list[LinkedUrl]
|
||||
playlists: list[str]
|
||||
top_videos: list[TopVideo]
|
||||
diagnosis: list[DiagnosisItem]
|
||||
|
||||
|
||||
# --- Instagram ---
|
||||
|
||||
class InstagramAccount(BaseModel):
|
||||
handle: str
|
||||
language: Language
|
||||
label: str
|
||||
posts: int
|
||||
followers: int
|
||||
following: int
|
||||
category: str
|
||||
profile_link: str
|
||||
highlights: list[str]
|
||||
reels_count: int
|
||||
content_format: str
|
||||
profile_photo: str
|
||||
bio: str
|
||||
|
||||
|
||||
class InstagramAudit(BaseModel):
|
||||
accounts: list[InstagramAccount]
|
||||
diagnosis: list[DiagnosisItem]
|
||||
|
||||
|
||||
# --- Facebook ---
|
||||
|
||||
class BrandInconsistencyValue(BaseModel):
|
||||
channel: str
|
||||
value: str
|
||||
is_correct: bool
|
||||
|
||||
|
||||
class BrandInconsistency(BaseModel):
|
||||
field: str
|
||||
values: list[BrandInconsistencyValue]
|
||||
impact: str
|
||||
recommendation: str
|
||||
|
||||
|
||||
class FacebookPage(BaseModel):
|
||||
url: str
|
||||
page_name: str
|
||||
language: Language
|
||||
label: str
|
||||
followers: int
|
||||
following: int
|
||||
category: str
|
||||
bio: str
|
||||
logo: str
|
||||
logo_description: str
|
||||
link: str
|
||||
linked_domain: str
|
||||
reviews: int
|
||||
recent_post_age: str
|
||||
has_whatsapp: bool
|
||||
post_frequency: str | None = None
|
||||
top_content_type: str | None = None
|
||||
engagement: str | None = None
|
||||
|
||||
|
||||
class FacebookAudit(BaseModel):
|
||||
pages: list[FacebookPage]
|
||||
diagnosis: list[DiagnosisItem]
|
||||
brand_inconsistencies: list[BrandInconsistency]
|
||||
consolidation_recommendation: str
|
||||
|
||||
|
||||
# --- 기타 채널 / 웹사이트 ---
|
||||
|
||||
class OtherChannel(BaseModel):
|
||||
name: str
|
||||
status: ChannelStatus
|
||||
details: str
|
||||
url: str | None = None
|
||||
|
||||
|
||||
class TrackingPixel(BaseModel):
|
||||
name: str
|
||||
installed: bool
|
||||
details: str | None = None
|
||||
|
||||
|
||||
class SnsLink(BaseModel):
|
||||
platform: str
|
||||
url: str
|
||||
location: str
|
||||
|
||||
|
||||
class AdditionalDomain(BaseModel):
|
||||
domain: str
|
||||
purpose: str
|
||||
|
||||
|
||||
class WebsiteAudit(BaseModel):
|
||||
primary_domain: str
|
||||
additional_domains: list[AdditionalDomain]
|
||||
sns_links_on_site: bool
|
||||
sns_links_detail: list[SnsLink] | None = None
|
||||
tracking_pixels: list[TrackingPixel]
|
||||
main_cta: str
|
||||
|
||||
|
||||
# --- Transformation ---
|
||||
|
||||
class AsIsToBeItem(BaseModel):
|
||||
area: str
|
||||
as_is: str
|
||||
to_be: str
|
||||
|
||||
|
||||
class StrategyDetail(BaseModel):
|
||||
strategy: str
|
||||
detail: str
|
||||
|
||||
|
||||
class PlatformStrategy(BaseModel):
|
||||
platform: str
|
||||
icon: str
|
||||
current_metric: str
|
||||
target_metric: str
|
||||
strategies: list[StrategyDetail]
|
||||
|
||||
|
||||
class NewChannelProposal(BaseModel):
|
||||
channel: str
|
||||
priority: str
|
||||
rationale: str
|
||||
|
||||
|
||||
class TransformationProposal(BaseModel):
|
||||
brand_identity: list[AsIsToBeItem]
|
||||
content_strategy: list[AsIsToBeItem]
|
||||
platform_strategies: list[PlatformStrategy]
|
||||
website_improvements: list[AsIsToBeItem]
|
||||
new_channel_proposals: list[NewChannelProposal]
|
||||
|
||||
|
||||
# --- Roadmap / KPI ---
|
||||
|
||||
class RoadmapTask(BaseModel):
|
||||
task: str
|
||||
completed: bool
|
||||
|
||||
|
||||
class RoadmapMonth(BaseModel):
|
||||
month: int
|
||||
title: str
|
||||
subtitle: str
|
||||
tasks: list[RoadmapTask]
|
||||
|
||||
|
||||
class KPIMetric(BaseModel):
|
||||
metric: str
|
||||
current: str
|
||||
target_3_month: str
|
||||
target_12_month: str
|
||||
|
||||
|
||||
# --- ReportInput (prompt 템플릿 변수) ---
|
||||
|
||||
# template.format(**model_dump()) 에 삽입될 변수들
|
||||
# 각 채널 raw_data를 호출부에서 json.dumps()로 직렬화해서 넘겨야 함
|
||||
class ReportInput(BaseModel):
|
||||
clinic_name: str | None = None
|
||||
clinic_name_en: str | None = None
|
||||
@@ -18,26 +326,25 @@ class ReportInput(BaseModel):
|
||||
gangnam_unni: str | None = None
|
||||
|
||||
|
||||
class ChannelScore(BaseModel):
|
||||
score: int
|
||||
summary: str
|
||||
strengths: list[str]
|
||||
weaknesses: list[str]
|
||||
# --- MarketingReport ---
|
||||
|
||||
|
||||
class ConversionStrategy(BaseModel):
|
||||
summary: str
|
||||
actions: list[str]
|
||||
|
||||
|
||||
# response_format으로 OpenAI structured output에 전달 — dict 필드 사용 불가
|
||||
class ReportOutput(BaseModel):
|
||||
class MarketingReport(BaseModel):
|
||||
id: str
|
||||
created_at: str
|
||||
target_url: str
|
||||
overall_score: int
|
||||
instagram: ChannelScore | None = None
|
||||
facebook: ChannelScore | None = None
|
||||
naver_blog: ChannelScore | None = None
|
||||
youtube: ChannelScore | None = None
|
||||
gangnam_unni: ChannelScore | None = None
|
||||
conversion_strategy: ConversionStrategy
|
||||
roadmap: list[str]
|
||||
kpis: list[str]
|
||||
clinic_snapshot: ClinicSnapshot
|
||||
channel_scores: list[ChannelScore]
|
||||
youtube_audit: YouTubeAudit
|
||||
instagram_audit: InstagramAudit
|
||||
facebook_audit: FacebookAudit
|
||||
other_channels: list[OtherChannel]
|
||||
website_audit: WebsiteAudit
|
||||
problem_diagnosis: list[DiagnosisItem]
|
||||
transformation: TransformationProposal
|
||||
roadmap: list[RoadmapMonth]
|
||||
kpi_dashboard: list[KPIMetric]
|
||||
screenshots: list[ScreenshotEvidence] | None = None
|
||||
|
||||
|
||||
ReportOutput = MarketingReport
|
||||
Reference in new issue
Block a user