def __init__(self, api_key: str | None = None, test_mode: bool = False): """Initialize the LLM analyzer. Args: api_key: Anthropic API key. If None, will attempt to load from config. test_mode: If True, print prompts instead of making API calls """ self.test_mode = test_mode if config.anthropic_api_key and not test_mode: self.client = Anthropic(api_key=api_key or config.anthropic_api_key) self.model = "claude-3-5-sonnet-20241022" else: self.client = None def analyze_patent_content(self, patent_content: str, company_name: str) -> str: """Analyze patent content to estimate company innovation and performance. Args: patent_content: Minimized patent text (abstract, claims, summary) company_name: Name of the company for context Returns: Analysis text describing innovation quality and potential impact """ prompt = f"""You are a patent analyst evaluating {company_name}'s innovation strategy. Analyze the following patent content and provide insights on: 1. Innovation quality and novelty 2. Technical complexity and defensibility 3. Market potential and commercial viability 4. Strategic positioning relative to industry trends Patent Content: {patent_content} Provide a concise analysis (2-3 paragraphs) focusing on what this patent reveals about the company's technical direction and competitive advantage.""" if self.test_mode: print("=" * 80) print("TEST MODE - Prompt that would be sent to LLM:") print("=" * 80) print(prompt) print("=" * 80) return "[TEST MODE - No API call made]" if self.client: message = self.client.messages.create( model=self.model, max_tokens=1024, messages=[{"role": "user", "content": prompt}], ) return message.content[0].text else: with open(f"AI_Prompts/{company_name}", "w") as f: f.write(prompt) return True