nananie143 commited on
Commit
9ea5c9a
·
verified ·
1 Parent(s): 437028e

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. reasoning/venture_strategies.py +155 -0
reasoning/venture_strategies.py CHANGED
@@ -421,3 +421,158 @@ class VenturePortfolioStrategy(ReasoningStrategy):
421
  "burn_rate": sum(v.metrics.burn_rate for v in self.ventures)
422
  }
423
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  "burn_rate": sum(v.metrics.burn_rate for v in self.ventures)
422
  }
423
  }
424
+
425
+ class VentureStrategy(ReasoningStrategy):
426
+ """
427
+ Advanced venture strategy that combines multiple specialized strategies
428
+ to generate comprehensive business plans and recommendations.
429
+ """
430
+
431
+ def __init__(self, config: Optional[Dict[str, Any]] = None):
432
+ """Initialize venture strategy with component strategies."""
433
+ super().__init__()
434
+ self.config = config or {}
435
+
436
+ # Initialize component strategies
437
+ self.strategies = {
438
+ VentureType.AI_STARTUP: AIStartupStrategy(),
439
+ VentureType.SAAS: SaaSVentureStrategy(),
440
+ VentureType.AUTOMATION_SERVICE: AutomationVentureStrategy(),
441
+ VentureType.DATA_ANALYTICS: DataVentureStrategy(),
442
+ VentureType.API_SERVICE: APIVentureStrategy(),
443
+ VentureType.MARKETPLACE: MarketplaceVentureStrategy()
444
+ }
445
+
446
+ # Portfolio strategy for multi-venture optimization
447
+ self.portfolio_strategy = VenturePortfolioStrategy()
448
+
449
+ async def reason(self, query: str, context: Dict[str, Any]) -> Dict[str, Any]:
450
+ """
451
+ Generate venture strategy based on query and context.
452
+
453
+ Args:
454
+ query: The venture strategy query
455
+ context: Additional context and parameters
456
+
457
+ Returns:
458
+ Dict containing venture strategy and confidence scores
459
+ """
460
+ try:
461
+ # Determine venture type from query/context
462
+ venture_type = self._determine_venture_type(query, context)
463
+
464
+ # Get strategy for venture type
465
+ strategy = self.strategies.get(venture_type)
466
+ if not strategy:
467
+ raise ValueError(f"Unsupported venture type: {venture_type}")
468
+
469
+ # Generate strategy
470
+ strategy_result = await strategy.reason(query, context)
471
+
472
+ # Get portfolio analysis
473
+ portfolio_result = await self.portfolio_strategy.reason(query, context)
474
+
475
+ # Combine results
476
+ combined_result = self._combine_results(
477
+ strategy_result,
478
+ portfolio_result,
479
+ venture_type
480
+ )
481
+
482
+ return {
483
+ 'answer': self._format_strategy(combined_result),
484
+ 'confidence': combined_result.get('confidence', 0.0),
485
+ 'venture_type': venture_type.value,
486
+ 'strategy': strategy_result,
487
+ 'portfolio_analysis': portfolio_result
488
+ }
489
+
490
+ except Exception as e:
491
+ logging.error(f"Venture strategy generation failed: {str(e)}")
492
+ return {
493
+ 'error': f"Venture strategy generation failed: {str(e)}",
494
+ 'confidence': 0.0
495
+ }
496
+
497
+ def _determine_venture_type(self, query: str, context: Dict[str, Any]) -> VentureType:
498
+ """Determine venture type from query and context."""
499
+ # Use context if available
500
+ if 'venture_type' in context:
501
+ return VentureType(context['venture_type'])
502
+
503
+ # Simple keyword matching
504
+ query_lower = query.lower()
505
+ if any(term in query_lower for term in ['ai', 'ml', 'model', 'neural']):
506
+ return VentureType.AI_STARTUP
507
+ elif any(term in query_lower for term in ['saas', 'software', 'cloud']):
508
+ return VentureType.SAAS
509
+ elif any(term in query_lower for term in ['automate', 'automation', 'workflow']):
510
+ return VentureType.AUTOMATION_SERVICE
511
+ elif any(term in query_lower for term in ['data', 'analytics', 'insights']):
512
+ return VentureType.DATA_ANALYTICS
513
+ elif any(term in query_lower for term in ['api', 'service', 'endpoint']):
514
+ return VentureType.API_SERVICE
515
+ elif any(term in query_lower for term in ['marketplace', 'platform', 'network']):
516
+ return VentureType.MARKETPLACE
517
+
518
+ # Default to AI startup if unclear
519
+ return VentureType.AI_STARTUP
520
+
521
+ def _combine_results(
522
+ self,
523
+ strategy_result: Dict[str, Any],
524
+ portfolio_result: Dict[str, Any],
525
+ venture_type: VentureType
526
+ ) -> Dict[str, Any]:
527
+ """Combine strategy and portfolio results."""
528
+ return {
529
+ 'venture_type': venture_type.value,
530
+ 'strategy': strategy_result.get('strategy', {}),
531
+ 'metrics': strategy_result.get('metrics', {}),
532
+ 'portfolio_fit': portfolio_result.get('portfolio_fit', {}),
533
+ 'recommendations': strategy_result.get('recommendations', []),
534
+ 'confidence': min(
535
+ strategy_result.get('confidence', 0.0),
536
+ portfolio_result.get('confidence', 0.0)
537
+ )
538
+ }
539
+
540
+ def _format_strategy(self, result: Dict[str, Any]) -> str:
541
+ """Format venture strategy into readable text."""
542
+ sections = []
543
+
544
+ # Venture type
545
+ sections.append(f"Venture Type: {result['venture_type'].replace('_', ' ').title()}")
546
+
547
+ # Strategy overview
548
+ if 'strategy' in result:
549
+ strategy = result['strategy']
550
+ sections.append("\nStrategy Overview:")
551
+ for key, value in strategy.items():
552
+ sections.append(f"- {key.replace('_', ' ').title()}: {value}")
553
+
554
+ # Key metrics
555
+ if 'metrics' in result:
556
+ metrics = result['metrics']
557
+ sections.append("\nKey Metrics:")
558
+ for key, value in metrics.items():
559
+ if isinstance(value, (int, float)):
560
+ sections.append(f"- {key.replace('_', ' ').title()}: {value:.2f}")
561
+ else:
562
+ sections.append(f"- {key.replace('_', ' ').title()}: {value}")
563
+
564
+ # Portfolio fit
565
+ if 'portfolio_fit' in result:
566
+ fit = result['portfolio_fit']
567
+ sections.append("\nPortfolio Analysis:")
568
+ for key, value in fit.items():
569
+ sections.append(f"- {key.replace('_', ' ').title()}: {value}")
570
+
571
+ # Recommendations
572
+ if 'recommendations' in result:
573
+ recs = result['recommendations']
574
+ sections.append("\nKey Recommendations:")
575
+ for rec in recs:
576
+ sections.append(f"- {rec}")
577
+
578
+ return "\n".join(sections)