from pydantic import BaseModel
from devtools import pprint
class CompanyData(BaseModel):
company_name: str
page_link: str
reason: str
class CompaniesData(BaseModel):
companies: list[CompanyData]
o1_response = client.chat.completions.create(
model="o1-preview",
messages=[
{
"role": "user",
"content": f"""
You are a business analyst designed to understand how AI technology could be used across large corporations.
- Read the following html and return which companies would benefit from using AI technology: {html_content}.
- Rank these propects by opportunity by comparing them and show me the top 3. Return each with {CompanyData.__fields__.keys()}
"""
}
]
)
o1_response_content = o1_response.choices[0].message.content
response = client.beta.chat.completions.parse(
model="gpt-4o-mini",
messages=[
{
"role": "user",
"content": f"""
Given the following data, format it with the given response format: {o1_response_content}
"""
}
],
response_format=CompaniesData,
)
pprint(response.choices[0].message.parsed)