Deploy on 2026-06-06 12:04:41
This commit is contained in:
@@ -23,24 +23,41 @@ class AiAnalyzer
|
||||
*/
|
||||
public function analyze(string $title, string $description): array
|
||||
{
|
||||
$companyProfile = '';
|
||||
$profilePath = __DIR__ . '/../../../COMPANY_PROFILE.md';
|
||||
if (file_exists($profilePath)) {
|
||||
$companyProfile = file_get_contents($profilePath);
|
||||
}
|
||||
|
||||
if (!$this->apiKey) {
|
||||
return $this->fallbackAnalysis($title, $description);
|
||||
}
|
||||
|
||||
$prompt = <<<PROMPT
|
||||
You are ScoutIQ, an investor intelligence AI. Analyze the following startup/investment content and return a JSON object with:
|
||||
- "type": one of ["grant", "competition", "demo_day", "event", "partnership", "investment", "news", "other"]
|
||||
- "opportunity_type": one of ["vc_funding", "accelerator", "incubator", "grant", "competition", "demo_day", "event", "partnership", "other"]
|
||||
- "score": integer 0-100 (relevance to startups seeking funding)
|
||||
- "tags": array of relevant tags (max 5)
|
||||
- "is_opportunity": boolean (true if it's a funding/investment opportunity)
|
||||
- "summary": 1-2 sentence summary in Arabic language of what this is, highlighting key strengths and contact/application info if present
|
||||
- "organization_name": extracted organization name if any, or null
|
||||
- "country": extracted country if any, or null
|
||||
You are ScoutIQ, an investor intelligence AI. Analyze the following startup/investment content and evaluate its fit for our startup based on the provided company profile.
|
||||
|
||||
Company Profile:
|
||||
{$companyProfile}
|
||||
|
||||
Content to Analyze:
|
||||
Title: {$title}
|
||||
Description: {$description}
|
||||
|
||||
Return a JSON object with EXACTLY these fields:
|
||||
- "type": one of ["grant", "competition", "demo_day", "event", "partnership", "investment", "news", "other"]
|
||||
- "opportunity_type": one of ["vc_funding", "accelerator", "incubator", "grant", "competition", "demo_day", "event", "partnership", "other"]
|
||||
- "fit_score": integer 0-100 (Match score based on how well this opportunity fits the Company Profile: sector, stage, country, etc.)
|
||||
- "tags": array of relevant tags (max 5)
|
||||
- "is_opportunity": boolean (true if it's a funding/investment opportunity that is relevant to our profile)
|
||||
- "summary": 1-2 sentence summary in Arabic of what this is
|
||||
- "organization_name": extracted organization name if any, or null
|
||||
- "country": extracted country if any, or null
|
||||
- "why_it_matters": array of strings in Arabic (2-3 bullet points of why this is a good fit and why we should care)
|
||||
- "requirements": array of strings in Arabic (2-3 bullet points of the most important requirements or eligibility criteria)
|
||||
- "deadline": string (extracted deadline date, or null if not found)
|
||||
- "effort": string (one of ["عالي", "متوسط", "منخفض"] depending on the effort required to apply)
|
||||
- "potential_return": string (one of ["عالي", "متوسط", "منخفض"] depending on the value it brings)
|
||||
|
||||
Respond ONLY with valid JSON, no markdown, no code fences.
|
||||
PROMPT;
|
||||
|
||||
@@ -264,12 +281,17 @@ PROMPT;
|
||||
return [
|
||||
'type' => $type,
|
||||
'opportunity_type' => $opportunityType,
|
||||
'score' => $score,
|
||||
'fit_score' => $score,
|
||||
'tags' => $tags,
|
||||
'is_opportunity' => $isOpportunity,
|
||||
'summary' => substr($description, 0, 200),
|
||||
'organization_name' => $orgName,
|
||||
'country' => $country,
|
||||
'why_it_matters' => ['فرصة عامة'],
|
||||
'requirements' => ['غير محدد'],
|
||||
'deadline' => null,
|
||||
'effort' => 'متوسط',
|
||||
'potential_return' => 'متوسط',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -250,7 +250,7 @@ class Collector
|
||||
private function createOpportunity(array $entry, array $analysis, ?int $orgId, array $source): void
|
||||
{
|
||||
try {
|
||||
$score = min(100, max(0, $analysis['score'] ?? 10));
|
||||
$score = min(100, max(0, $analysis['fit_score'] ?? $analysis['score'] ?? 10));
|
||||
|
||||
$stmt = $this->pdo->prepare(
|
||||
"INSERT INTO opportunities (title, description, type, organization_id, url, status, score, raw_data)
|
||||
@@ -293,7 +293,7 @@ class Collector
|
||||
$oppType = $analysis['opportunity_type'] ?? $analysis['type'] ?? 'other';
|
||||
$importantTypes = ['vc_funding', 'accelerator', 'incubator', 'grant', 'competition'];
|
||||
|
||||
if ($score >= $minScore && in_array($oppType, $importantTypes)) {
|
||||
if ($score >= $minScore && in_array($oppType, $importantTypes) && !empty($analysis['is_opportunity'])) {
|
||||
$orgName = '';
|
||||
if ($orgId) {
|
||||
$orgStmt = $this->pdo->prepare("SELECT name FROM organizations WHERE id = ?");
|
||||
@@ -304,10 +304,15 @@ class Collector
|
||||
$this->notifier->notifyNewOpportunity([
|
||||
'title' => $entry['title'],
|
||||
'type' => $oppType,
|
||||
'score' => $score,
|
||||
'fit_score' => $score,
|
||||
'url' => $entry['url'],
|
||||
'description' => $analysis['summary'] ?? $entry['description'],
|
||||
'org_name' => $orgName,
|
||||
'why_it_matters' => $analysis['why_it_matters'] ?? [],
|
||||
'requirements' => $analysis['requirements'] ?? [],
|
||||
'deadline' => $analysis['deadline'] ?? null,
|
||||
'effort' => $analysis['effort'] ?? 'متوسط',
|
||||
'potential_return' => $analysis['potential_return'] ?? 'متوسط',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user