Israa-M commited on
Commit
614bb71
·
verified ·
1 Parent(s): d51b3ea

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +149 -0
app.py ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import re
3
+ import gradio as gr
4
+ from huggingface_hub import InferenceClient
5
+
6
+ HF_TOKEN = os.getenv("HF_TOKEN", "")
7
+ DEFAULT_MODEL = os.getenv("HF_MODEL", "Qwen/Qwen2.5-72B-Instruct")
8
+
9
+ MAX_TOKENS = 1400
10
+ TEMPERATURE = 0.4
11
+
12
+ SYSTEM_INSTRUCTIONS = """
13
+ You are a senior enterprise Account Executive specializing in converting
14
+ open-source platform usage into enterprise-grade commercial engagements.
15
+
16
+ You do NOT represent any specific vendor.
17
+ You do NOT claim access to private or internal data.
18
+
19
+ Hard rules:
20
+ - Anchor everything in public signals
21
+ - Separate technical users from decision makers
22
+ - Be practical and executable
23
+ - Avoid generic SaaS language
24
+ - If information is missing, state assumptions clearly
25
+
26
+ You MUST output exactly these sections:
27
+
28
+ 1. Account Snapshot
29
+ 2. Usage Hypotheses
30
+ 3. Persona Mapping
31
+ 4. Outbound Campaign Design
32
+ 5. Message Examples
33
+ 6. How This Scales
34
+
35
+ Under Message Examples:
36
+ - One technical-user message
37
+ - One decision-maker message
38
+
39
+ Tone: senior AE speaking to peers. No emojis.
40
+ """
41
+
42
+ USER_TEMPLATE = """
43
+ Account (name or org URL):
44
+ {account}
45
+
46
+ Optional context:
47
+ Industry: {industry}
48
+ Region: {region}
49
+ Primary persona: {primary_persona}
50
+ Secondary personas: {secondary_personas}
51
+ Offer focus: {offer_focus}
52
+ Goal: {goal}
53
+ Notes: {notes}
54
+
55
+ Task:
56
+ Create a structured outbound plan for this account based on public
57
+ open-source platform usage and OSS → Enterprise conversion patterns.
58
+ """
59
+
60
+ def call_model(prompt, model):
61
+ if not HF_TOKEN:
62
+ return "Missing HF_TOKEN. Add it in Space Settings → Secrets."
63
+
64
+ client = InferenceClient(model=model, token=HF_TOKEN)
65
+
66
+ response = client.chat.completions.create(
67
+ messages=[
68
+ {"role": "system", "content": SYSTEM_INSTRUCTIONS},
69
+ {"role": "user", "content": prompt},
70
+ ],
71
+ temperature=TEMPERATURE,
72
+ max_tokens=MAX_TOKENS,
73
+ )
74
+
75
+ return response.choices[0].message.content.strip()
76
+
77
+ def generate(
78
+ account,
79
+ industry,
80
+ region,
81
+ primary_persona,
82
+ secondary_personas,
83
+ offer_focus,
84
+ goal,
85
+ notes,
86
+ model,
87
+ ):
88
+ if not account:
89
+ return "Please input an account name or org URL."
90
+
91
+ prompt = USER_TEMPLATE.format(
92
+ account=account,
93
+ industry=industry or "Not provided",
94
+ region=region or "Not provided",
95
+ primary_persona=primary_persona or "Not provided",
96
+ secondary_personas=secondary_personas or "Not provided",
97
+ offer_focus=offer_focus or "Not provided",
98
+ goal=goal or "Convert free usage to enterprise engagement",
99
+ notes=notes or "Not provided",
100
+ )
101
+
102
+ return call_model(prompt, model or DEFAULT_MODEL)
103
+
104
+ with gr.Blocks(title="Enterprise OSS → Outbound Ops") as app:
105
+ gr.Markdown(
106
+ "# Enterprise OSS → Outbound Ops\n"
107
+ "Input an **account name or public org URL** to generate an enterprise outbound plan."
108
+ )
109
+
110
+ account = gr.Textbox(label="Account name or org URL")
111
+
112
+ with gr.Row():
113
+ industry = gr.Textbox(label="Industry (optional)")
114
+ region = gr.Textbox(label="Region (optional)")
115
+
116
+ with gr.Row():
117
+ primary_persona = gr.Textbox(label="Primary persona (optional)")
118
+ secondary_personas = gr.Textbox(label="Secondary personas (optional)")
119
+
120
+ offer_focus = gr.Textbox(label="Offer focus (optional)")
121
+ goal = gr.Textbox(label="Goal (optional)")
122
+ notes = gr.Textbox(label="Notes / known public signals (optional)", lines=4)
123
+
124
+ model = gr.Textbox(
125
+ label="Model",
126
+ value=DEFAULT_MODEL,
127
+ help="Change only if you know what you're doing",
128
+ )
129
+
130
+ run = gr.Button("Generate outbound plan")
131
+ output = gr.Markdown()
132
+
133
+ run.click(
134
+ fn=generate,
135
+ inputs=[
136
+ account,
137
+ industry,
138
+ region,
139
+ primary_persona,
140
+ secondary_personas,
141
+ offer_focus,
142
+ goal,
143
+ notes,
144
+ model,
145
+ ],
146
+ outputs=output,
147
+ )
148
+
149
+ app.launch()