Skip to content

Instantly share code, notes, and snippets.

@rjurney
Last active August 1, 2025 07:48
Show Gist options
  • Save rjurney/3034d10847d35f5aaf6070fcb0a36430 to your computer and use it in GitHub Desktop.
Save rjurney/3034d10847d35f5aaf6070fcb0a36430 to your computer and use it in GitHub Desktop.
BAML Schema for Information Extraction of Companies from News
class NewsArticle {
title string
url string?
@description("URL of the article")
summary string
@description("Summary of the article. What is it about? What are the key points?")
companies Company[]?
@description("Companies mentioned in the article. Use full name with company suffix.")
}
class Ticker {
symbol string
@description("Ticker symbol of the company if publicly traded")
exchange string?
@description("Exchange where the company is traded")
}
class Company {
name string
@description("Formal name of the company with company suffix")
ticker Ticker?
@description("Ticker symbol of the company if publicly traded")
description string?
@description("What does the company do? What is it known for?")
}
client<llm> CustomGemini25Pro {
provider google-ai
retry_policy Exponential
options {
model "gemini-2.5-pro"
api_key env.GEMINI_API_KEY
}
}
class CompanyERResponse {
match bool
@description("Do the two companies match?")
company Company?
@description("The resolved, combined company if the two companies match. If not, this is null.")
}
function CompanyEntityResolution(company_one: Company, company_two: Company) -> CompanyERResponse {
client CustomGemini25Pro
prompt #"
Examine the following two companies and determine if they are the same entity. If they are, return the resolved company with all attributes filled out. If they are not, return an empty company object.
{# special macro to print the output instructions. #}
{{ ctx.output_format }}
{{ _.role("user") }}
Company One: {{ company_one }}
Company Two: {{ company_two }}
"#
}
generator target {
output_type "python/pydantic"
output_dir ".."
version "0.202.1"
default_client_mode async
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment