Spaces:
Runtime error
Runtime error
Delete utils.py
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970import openaiimport osimport requests
client = openai.OpenAI(api_key=os.getenv("OPENAI_API_KEY"))SERPER_API_KEY = os.getenv("SERPER_API_KEY")
def search_company_info(company): url = "https://google.serper.dev/search" headers = {"X-API-KEY": SERPER_API_KEY, "Content-Type": "application/json"} data = {"q": f"{company} site:news.zurichna.com OR site:zurichna.com OR site:prnewswire.com"} try: response = requests.post(url, headers=headers, json=data) results = response.json() search_snippets = []
if "organic" in results: for item in results["organic"][:5]: title = item.get("title", "") link = item.get("link", "") snippet = item.get("snippet", "") search_snippets.append(f"- [{title}]({link}): {snippet}")
return "\n".join(search_snippets) if search_snippets else "No relevant news found." except Exception as e: return f"Error retrieving search results: {e}"
def generate_rtm(company, website, use_serper=False): news_snippets = search_company_info(company) if use_serper else "News search skipped."
prompt = f"""You are an enterprise sales executive building a strategic account plan for {company} ({website}).Please return a full Reason-to-Meet (RTM) summary with detailed bullet points and sections.
Use the following search results as context if helpful:{news_snippets}
Follow this structure:1. **Company Overview** — location, employee count, public/private, industry, key customers2. **Business Breakdown** — revenue segments or products, where available3. **Strategic Initiatives** — major projects, innovation themes, cloud/AI/IT transformation efforts4. **Executive Team** — list relevant C-level titles (CIO, CTO, COO, CISO, SVP of Ops), if public5. **Challenges** — call out potential pains related to: MTTR, incident response, monitoring, legacy tech, digital transformation6. **How We Can Help** — tie back to PagerDuty’s value props7. **Sources** — use real links if available
Return in markdown format with bold headers and bullet points.""" response = client.chat.completions.create( model="gpt-4-turbo", messages=[{"role": "user", "content": prompt}] ) return response.choices[0].message.content
def generate_prospecting_message(linkedin_url, profile_context, rtm_context): prompt = f"""You are generating a highly personalized prospecting email.Prospect LinkedIn: {linkedin_url}Prospect Details: {profile_context}RTM Account Context: {rtm_context}
Generate a short, strategic outreach message for the prospect (under 125 words).Frame it around a pain point or opportunity they would care about based on their role and the company context.""" response = client.chat.completions.create( model="gpt-4-turbo", messages=[{"role": "user", "content": prompt}] ) return response.choices[0].message.contentutils.pyDeleted-70