dolphinium
extend field metadata for poc(field_metadata injection to prompt improves accuracy of query generation)
83ba6f2
""" | |
Stores the detailed metadata for the Solr index fields. | |
This information is crucial for the LLM to understand the data schema, | |
enabling it to construct accurate and efficient Solr queries. Separating it | |
into its own module keeps the main application logic cleaner. | |
""" | |
field_metadata = [ | |
{ | |
"core_name": "news", | |
"field_name": "business_model", | |
"type": "string (categorical)", | |
"example_values": ["pharma/bio", "drug delivery", "pharma services"], | |
"definition": "The primary business category of the company involved in the news. Use for filtering by high-level industry segments." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "news_type", | |
"type": "string (categorical)", | |
"example_values": ["financial news", "product news", "other company news", "regulatory news", "people news", "funding news", "pharma services deals", "product approvals", "product deals", "technology news", "company acquisitions", "product filings", "legal news", "discovery technology deals", "company divestitures", "latest dds patents", "dd technology deals", "product acquisitions", "option agreement", "joint venture deal", "technology acquisitions"], | |
"definition": "The category of the news article itself (e.g., financial, regulatory, acquisition). Use for filtering by the type of event being reported." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "event_type", | |
"type": "string (categorical)", | |
"example_values": ["phase 1", "phase 2", "pre clinical", "phase 3", "marketed", "approved", "registration", "research", "phase 0", "tentative approval", "bioequivalency", "undisclosed", "approvable"], | |
"definition": "The clinical or developmental stage of a product or event discussed in the article. Essential for queries about clinical trial phases." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "source", | |
"type": "string (categorical)", | |
"example_values": ["Press Release", "PR Newswire", "Business Wire"], | |
"definition": "The original source of the news article, such as a newswire or official report." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "company_name", | |
"type": "string (exact match, for faceting)", | |
"example_values": ["pfizer inc.", "astrazeneca plc", "roche"], | |
"definition": "The canonical, standardized name of a company. **Crucially, you MUST use this field for `terms` faceting** to group results by a unique company. Do NOT use this for searching." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "company_name_s", | |
"type": "string (multi-valued, for searching)", | |
"example_values": ["pfizer inc.", "roche", "f. hoffmann-la roche ag", "nih"], | |
"definition": "A field containing all known names and synonyms for a company. **You MUST use this field for all `query` parameter searches involving a company name** to ensure comprehensive results. Do NOT use for `terms` faceting." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "territory_hq_s", | |
"type": "string (multi-valued, hierarchical)", | |
"example_values": ["united states of america", "europe", "europe western"], | |
"definition": "The geographic location (country and continent) of a company's headquarters. It is hierarchical. Use for filtering by location." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "therapeutic_category", | |
"type": "string (specific)", | |
"example_values": ["cancer, other", "cancer, nsclc metastatic", "alzheimer's"], | |
"definition": "The specific disease or therapeutic area being targeted. Use for very specific disease queries." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "therapeutic_category_s", | |
"type": "string (multi-valued, for searching)", | |
"example_values": ["cancer", "oncology", "infections", "cns"], | |
"definition": "Broader, multi-valued therapeutic categories and their synonyms. **Use this field for broad category searches** in the `query` parameter." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "compound_name", | |
"type": "string (exact match, for faceting)", | |
"example_values": ["opdivo injection solution", "keytruda injection solution"], | |
"definition": "The specific, full trade name of a drug. **Use this field for `terms` faceting** on compounds." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "compound_name_s", | |
"type": "string (multi-valued, for searching)", | |
"example_values": ["nivolumab injection solution", "opdivo injection solution", "ono-4538 injection solution"], | |
"definition": "A field with all known trade names and synonyms for a drug. **Use this field for all `query` parameter searches** involving a compound name." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "molecule_name", | |
"type": "string (exact match, for faceting)", | |
"example_values": ["cannabidiol", "paclitaxel", "pembrolizumab"], | |
"definition": "The generic, non-proprietary name of the active molecule. **Use this field for `terms` faceting** on molecules." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "molecule_name_s", | |
"type": "string (multi-valued, for searching)", | |
"example_values": ["cbd", "s1-220", "a1002n5s"], | |
"definition": "A field with all known generic names and synonyms for a molecule. **Use this field for all `query` parameter searches** involving a molecule name." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "highest_phase", | |
"type": "string (categorical)", | |
"example_values": ["marketed", "phase 2", "phase 1"], | |
"definition": "The highest stage of development a drug has ever reached." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "drug_delivery_branch_s", | |
"type": "string (multi-valued, for searching)", | |
"example_values": ["injection", "parenteral", "oral", "injection, other", "oral, other"], | |
"definition": "The method of drug administration. **Use this for `query` parameter searches about route of administration** as it contains broader, search-friendly terms." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "drug_delivery_branch", | |
"type": "string (categorical, specific, for faceting)", | |
"example_values": ["injection, other", "prefilled syringes", "np liposome", "oral enteric/delayed release"], | |
"definition": "The most specific category of drug delivery technology. **Use this field for `terms` faceting** on specific delivery technologies." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "route_branch", | |
"type": "string (categorical)", | |
"example_values": ["injection", "oral", "topical", "inhalation"], | |
"definition": "The primary route of drug administration. Good for faceting on exact routes." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "molecule_api_group", | |
"type": "string (categorical)", | |
"example_values": ["small molecules", "biologics", "nucleic acids"], | |
"definition": "High-level classification of the drug's molecular type." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "content", | |
"type": "text (full-text search)", | |
"example_values": ["The largest study to date...", "balstilimab..."], | |
"definition": "The full text content of the news article. Use for keyword searches on topics not covered by other specific fields." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "date", | |
"type": "date", | |
"example_values": ["2020-10-22T00:00:00Z"], | |
"definition": "The full publication date and time in ISO 8601 format. Use for precise date range queries." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "date_year", | |
"type": "number (year)", | |
"example_values": [2020, 2021, 2022], | |
"definition": "The 4-digit year of publication. **Use this for queries involving whole years** (e.g., 'in 2023', 'last year', 'since 2020')." | |
}, | |
{ | |
"core_name": "news", | |
"field_name": "total_deal_value_in_million", | |
"type": "number (metric)", | |
"example_values": [50, 120.5, 176.157, 1000], | |
"definition": "The total value of a financial deal, in millions of USD. This is the primary numeric field for financial aggregations (sum, avg, etc.). To use this, you must also filter for news that has a deal value, e.g., 'total_deal_value_in_million:[0 TO *]'." | |
}, | |
# NEW 'deal' CORE METADATA | |
{ | |
"core_name": "deal", | |
"field_name": "id", | |
"type": "string", | |
"example_values": ["275302", "275306", "275307"], | |
"definition": "Unique identifier for the deal document." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "date", | |
"type": "date", | |
"example_values": ["2018-01-08T00:00:00Z"], | |
"definition": "The full publication date and time of the deal in ISO 8601 format. Use for precise date range queries." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "date_year", | |
"type": "number (year)", | |
"example_values": [2018, 2017, 2016], | |
"definition": "The 4-digit year of the deal. Use for queries involving whole years." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "type", | |
"type": "string (multi-valued, categorical)", | |
"example_values": ["drug delivery", "medical device", "pharma/bio", "pharma services"], | |
"definition": "The primary business categories associated with the deal (e.g., drug delivery, pharma/bio). Use for filtering by high-level industry segments." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "news_branch", | |
"type": "string (categorical)", | |
"example_values": ["DD Technology Deals", "Company Acquisitions", "Product Deals", "Pharma Services Deals", "Discovery Technology Deals"], | |
"definition": "The category of the deal itself (e.g., technology deal, acquisition). Use for filtering by the type of deal." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "news_header", | |
"type": "text", | |
"example_values": ["Intec Pharma Announces Development Collaboration With Global Pharmaceutical Company", "Alcyone Lifesciences Announces Research Collaboration..."], | |
"definition": "The headline or title of the news article announcing the deal. Use for keyword searches on the deal's title." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "total_deal_value_in_million", | |
"type": "number (metric)", | |
"example_values": [68.9968, 260.0, 100.0, 12.0], | |
"definition": "The total value of a financial deal, in millions of USD. This is the primary numeric field for financial aggregations (sum, avg, etc.)." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "deal_upfront", | |
"type": "number (metric)", | |
"example_values": [23.6042, 80.0, 12.0], | |
"definition": "The upfront payment value of the deal, in millions of USD." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "milestones", | |
"type": "number (metric)", | |
"example_values": [120.0], | |
"definition": "The value of milestone payments associated with the deal, in millions of USD." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "company_name", | |
"type": "string (exact match, for faceting, multi-valued)", | |
"example_values": ["Novartis AG", "Intec Pharma Ltd.", "Guerbet SA", "REGENXBIO, Inc."], | |
"definition": "The canonical, standardized names of companies involved in the deal. **Crucially, you MUST use this field for `terms` faceting** to group results by unique companies." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "company_name_s", | |
"type": "string (multi-valued, for searching)", | |
"example_values": ["Novartis AG", "Intec Pharma Ltd.", "Orly Guy Ltd.", "AveXis, Inc."], | |
"definition": "A field containing all known names and synonyms for companies in a deal. **You MUST use this field for all `query` parameter searches involving a company name**." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "company_name_investor", | |
"type": "string (multi-valued, for faceting)", | |
"example_values": ["Novartis AG", "Undisclosed Co.", "Merck KGaA", "Surface Oncology, Inc."], | |
"definition": "The canonical name(s) of the investor or acquiring company in the deal. Use for faceting on investors." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "company_name_investor_s", | |
"type": "string (multi-valued, for searching)", | |
"example_values": ["Novartis AG", "Undisclosed Co.", "AveXis, Inc.", "Surface Oncology, Inc."], | |
"definition": "A field with all known names and synonyms for the investor company. **Use this field for `query` parameter searches for investors.**" | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "company_name_invested", | |
"type": "string (multi-valued, for faceting)", | |
"example_values": ["Intec Pharma Ltd.", "Alcyone Therapeutics, Inc.", "Juniper Pharmaceuticals, Inc.", "Vaccinex, Inc."], | |
"definition": "The canonical name(s) of the company receiving investment or being acquired. Use for faceting on investees." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "company_name_invested_s", | |
"type": "string (multi-valued, for searching)", | |
"example_values": ["Intec Pharma Ltd.", "Orly Guy Ltd.", "Alcyone Lifesciences, Inc.", "Vaccinex, Inc."], | |
"definition": "A field with all known names and synonyms for the company receiving investment. **Use this field for `query` parameter searches for investees.**" | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "territory_name", | |
"type": "string (multi-valued, hierarchical)", | |
"example_values": ["Israel", "Asia Middle East", "Switzerland", "Europe Western", "United States of America"], | |
"definition": "The geographic locations (country, continent) of the companies involved in the deal. It is hierarchical. Use for filtering by location." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "therapeutic_category", | |
"type": "string (multi-valued, specific)", | |
"example_values": ["Duodenal Ulcer", "CNS, Other", "Infertility, Other", "Spinal Muscular Atrophy, Other"], | |
"definition": "The specific disease or therapeutic area being targeted by the deal. Use for very specific disease queries." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "therapeutic_category_s", | |
"type": "string (multi-valued, for searching)", | |
"example_values": ["gastrointestinal diseases", "peptic ulcer", "cns", "central nervous system", "musculoskeletal diseases"], | |
"definition": "Broader, multi-valued therapeutic categories and their synonyms related to the deal. **Use this field for broad category searches** in the `query` parameter." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "drug_delivery_branch", | |
"type": "string (multi-valued, for faceting)", | |
"example_values": ["Gastro Retentive", "Catheter Delivery Systems", "Bioadhesion", "Adeno-Associated Virus Vectors"], | |
"definition": "Specific categories of drug delivery technology involved in the deal. **Use this field for `terms` faceting** on specific delivery technologies." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "drug_delivery_branch_s", | |
"type": "string (multi-valued, for searching)", | |
"example_values": ["oral", "oral modified release", "gastro retentive", "medical devices", "viral vectors"], | |
"definition": "The method of drug administration and its broader search-friendly terms. **Use this for `query` parameter searches about route of administration**." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "route_branch", | |
"type": "string (multi-valued, categorical)", | |
"example_values": ["ORAL", "INJECTION", "SURGICAL INSERTION", "VAGINAL"], | |
"definition": "The primary route of drug administration related to the deal. Good for faceting on exact routes." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "product_name", | |
"type": "string (multi-valued, for searching and faceting)", | |
"example_values": ["Accordion Oral Capsule, Intec/Novartis", "Zolgensma Injection Suspension", "Crinone Vaginal Gel"], | |
"definition": "The name(s) of the product(s) central to the deal. Can be used for searching and faceting." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "phase", | |
"type": "string (multi-valued, categorical)", | |
"example_values": ["Phase 1", "Research", "Marketed", "Phase 3", "Pre Clinical"], | |
"definition": "The clinical or developmental stage(s) of a product or event discussed in the deal. Essential for queries about clinical trial phases." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "highest_phase", | |
"type": "string (multi-valued, categorical)", | |
"example_values": ["Phase 1", "Research", "Marketed", "Phase 3"], | |
"definition": "The highest stage of development a drug involved in the deal has ever reached." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "technology", | |
"type": "string (multi-valued, for searching and faceting)", | |
"example_values": ["Accordion GR Pill", "Alcyone Pulsar", "NAV Vectors", "Qb VLP Platform"], | |
"definition": "The specific named technologies that are part of the deal (e.g., a platform or a device)." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "mechanism_type_s", | |
"type": "string (multi-valued, for searching)", | |
"example_values": ["antiulcerative agents", "cns modulators", "hormone related", "progestogens", "gene replacements"], | |
"definition": "A field with all known mechanisms of action and their synonyms. **Use this field for all `query` parameter searches** involving mechanism of action." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "molecule_name_s", | |
"type": "string (multi-valued, for searching)", | |
"example_values": ["Accordion Pill Program Oral Capsule, Intec/Novartis", "progesterone", "onasemnogene abeparvovec-xioi", "apabetalone"], | |
"definition": "A field with all known generic names and synonyms for a molecule involved in the deal. **Use this field for all `query` parameter searches** involving a molecule name." | |
}, | |
{ | |
"core_name": "deal", | |
"field_name": "molecule_api_group", | |
"type": "string (multi-valued, categorical)", | |
"example_values": ["Small Molecules", "Biologics", "Nucleic Acids", "Peptides"], | |
"definition": "High-level classification of the drug's molecular type involved in the deal." | |
} | |
] | |
def format_metadata_for_prompt(core_name="news"): | |
"""Formats the field metadata for a specific core into a string for the LLM prompt.""" | |
formatted_string = "" | |
# Filter fields by the provided core name | |
for field in field_metadata: | |
if field.get("core_name") == core_name: | |
formatted_string += f"- **{field['field_name']}**\n" | |
formatted_string += f" - **Type**: {field['type']}\n" | |
formatted_string += f" - **Definition**: {field['definition']}\n" | |
formatted_string += f" - **Examples**: {', '.join(map(str, field['example_values']))}\n\n" | |
return formatted_string |