Corin1998 commited on
Commit
4fc9f3a
·
verified ·
1 Parent(s): 7fce7e7

Create workflow.py

Browse files
Files changed (1) hide show
  1. modules/workflow.py +64 -0
modules/workflow.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from modules.company_score import score_company
3
+ from modules.rag_retriever import retrieve_contexts
4
+ from modules.proposal_generator import make_proposal, suggest_next_actions
5
+ from modules.exporters import export_docx, export_pptx
6
+ from modules.emailer import build_tracking_url
7
+ from modules.utils import truncate
8
+
9
+ def _make_email(company_name: str, lead_email: str, proposal_md: str) -> dict:
10
+ traking = build_tracking_url(
11
+ identifier=f"{company_name}",
12
+ payload={
13
+ "company": company_name,
14
+ "redirect": os.getenv("PUBLIC_BASE_URL","/")
15
+ },
16
+ )
17
+ subject = f"{company_name}さま向けご提案(無料PoCのご案内)"
18
+ body = (
19
+ f"{company_name} ご担当者さま\n\n"
20
+ "突然のご連絡失礼致します。貴社向けに要点を1枚にまとめた提案書を作成しました。\n\n"
21
+ f"▼提案要旨\n{truncate(proposal_md, 800)}\n\n"
22
+ f"詳細はこちら(クリック計測用リンク) :\n{traking}\n\n"
23
+ f"30分ほどのオンラインミーティングの機会を頂戴できればと幸いです。\n"
24
+ "ご検討のほど、よろしくお願いいたします。\n"
25
+ "\n--\nAgent Studio"
26
+ )
27
+ return {"subject": subject, "body": body}
28
+
29
+ def run_full_workflow(company_name: str,
30
+ company_website: str,
31
+ lead_email: str | None,
32
+ objective: str,
33
+ temperature: float=0.4) -> dict:
34
+ # 1) スコア
35
+ score = score_company(company_name, company_website)
36
+
37
+ # 2) RAG 検索
38
+ query = f"{company_name} {objective} {company_website}"
39
+ top_contexts = retrieve_contexts(query, k=5)
40
+
41
+ # 3) 提案生成
42
+ proposal_md = make_proposal(company_name, objective, top_contexts, temperature=temperature)
43
+
44
+ # 4) エクスポート
45
+ docx_path = export_docx(proposal_md, company_name)
46
+ pptx_path = export_pptx(proposal_md, company_name)
47
+
48
+ # 5) メール下書き
49
+ email = _make_email(company_name, lead_email or "", proposal_md)
50
+
51
+ # 6) 次アクション
52
+ next_actions = suggest_next_actions(proposal_md, score["overall"])
53
+
54
+ return {
55
+ "score": score,
56
+ "top_contexts": top_contexts,
57
+ "proposal_markdown": proposal_md,
58
+ "exports": {
59
+ "docx_path": docx_path,
60
+ "pptx_path": pptx_path,
61
+ },
62
+ "email": email,
63
+ "next_actions": next_actions
64
+ }