feat: Add industry column to ProjectTable and update related schemas and query filters

This commit is contained in:
2025-10-23 12:52:52 +00:00
parent 483c2cc114
commit 1ac755b2d7
6 changed files with 89 additions and 3 deletions
+1
View File
@@ -296,6 +296,7 @@ class ProjectTable(Base, TimestampMixin):
stage = Column(Enum(InvestmentStage), nullable=True)
location = Column(String, nullable=True)
industry = Column(String, nullable=True)
description = Column(Text, nullable=True)
start_date = Column(DateTime, nullable=True)
end_date = Column(DateTime, nullable=True)
+4
View File
@@ -182,6 +182,7 @@ def filter_projects(
min_valuation: Optional[int] = Query(None, description="Minimum valuation"),
max_valuation: Optional[int] = Query(None, description="Maximum valuation"),
location: Optional[str] = Query(None, description="Location (partial match)"),
industry: Optional[str] = Query(None, description="Industry (partial match)"),
sector: Optional[str] = Query(None, description="Sector name (partial match)"),
investor_name: Optional[str] = Query(
None, description="Investor name (partial match)"
@@ -215,6 +216,9 @@ def filter_projects(
if location:
query = query.filter(ProjectTable.location.ilike(f"%{location}%"))
if industry:
query = query.filter(ProjectTable.industry.ilike(f"%{industry}%"))
if sector:
query = query.join(ProjectTable.sector).filter(
SectorTable.name.ilike(f"%{sector}%")
+3
View File
@@ -60,6 +60,7 @@ class ProjectSchema(BaseModel):
valuation: int | None
stage: InvestmentStage | None
location: str | None
industry: str | None
description: Optional[str]
start_date: Optional[datetime]
end_date: Optional[datetime]
@@ -75,6 +76,7 @@ class ProjectCreate(BaseModel):
valuation: Optional[int] = None
stage: Optional[InvestmentStage] = None
location: Optional[str] = None
industry: Optional[str] = None
description: Optional[str] = None
start_date: Optional[datetime] = None
end_date: Optional[datetime] = None
@@ -85,6 +87,7 @@ class ProjectUpdate(BaseModel):
valuation: Optional[int] = None
stage: Optional[InvestmentStage] = None
location: Optional[str] = None
industry: Optional[str] = None
description: Optional[str] = None
start_date: Optional[datetime] = None
end_date: Optional[datetime] = None
+14 -3
View File
@@ -37,7 +37,7 @@ class QueryProcessor:
self.toolkit = SQLDatabaseToolkit(db=db, llm=self.llm)
# Update system message to specifically request only fund IDs
system_message_updated = (
prompt_template.format(dialect="SQLite", top_k=5)
prompt_template.format(dialect="SQLite", top_k=100)
+ "\n\n=== IMPORTANT TERMINOLOGY ==="
+ "\n- When users say 'investors' or 'find me investors', they mean FUNDS"
+ "\n- Always query the 'funds' table for investment opportunities"
@@ -51,8 +51,19 @@ class QueryProcessor:
+ "\n1. For geographic searches: use funds.geographic_focus"
+ "\n2. For sector searches: JOIN with fund_sectors table"
+ "\n3. For stage searches: JOIN with fund_investment_stages table"
+ "\n4. If no results: respond with 'NO_RESULTS'"
+ "\n5. Never repeat the same failed query"
+ "\n4. Return ALL matching fund IDs, not just the first few"
+ "\n5. If no results: respond with 'NO_RESULTS'"
+ "\n6. Never repeat the same failed query"
+ "\n\n=== GEOGRAPHIC SEARCH RULES (VERY IMPORTANT) ==="
+ "\n- ALWAYS use LIKE '%keyword%' for geographic searches, NEVER use exact equality (=)"
+ "\n- When user says 'Europe', match ANY location containing 'Europe' (e.g., 'Northern Europe', 'Western Europe', 'Europe', 'Central Europe')"
+ "\n- When user says 'America', match locations like 'North America', 'South America', 'Latin America', 'United States'"
+ "\n- When user says 'Asia', match 'Asia', 'Southeast Asia', 'East Asia', etc."
+ "\n- Examples:"
+ "\n * User: 'Europe' → SQL: WHERE geographic_focus LIKE '%Europe%'"
+ "\n * User: 'America' → SQL: WHERE geographic_focus LIKE '%America%'"
+ "\n * User: 'UK' → SQL: WHERE geographic_focus LIKE '%UK%' OR geographic_focus LIKE '%United Kingdom%'"
+ "\n- Be INCLUSIVE: capture all relevant regional variations"
)
self.agent = create_react_agent(
model=self.llm,