# Create a detailed prompt with JSON schema instructions
company_prompt = """
Create a company profile and return it as JSON with this exact structure:
{
"name": "string",
"founded_year": integer,
"employees": [
{
"name": "string",
"age": integer,
"email": "string or null",
"addresses": [
{
"street": "string",
"city": "string",
"state": "string",
"zip_code": "string"
}
],
"is_employed": boolean
}
],
"headquarters": {
"street": "string",
"city": "string",
"state": "string",
"zip_code": "string"
}
}
Company details:
- Name: TechCorp
- Founded in 2020
- Headquarters: 123 Tech St, San Francisco, CA 94105
- Employees: Alice Johnson (age 30, [email protected], employed) and Bob Smith (age 25, no email, employed)
- Alice lives at 456 Oak Ave, Palo Alto, CA 94301
Return only the JSON object:
"""
# Initialize client for complex example
client = TinfoilAI(
api_key=os.getenv("TINFOIL_API_KEY")
)
# Extract complex structured data
response = client.chat.completions.create(
model="<MODEL_NAME>",
messages=[{"role": "user", "content": company_prompt}],
temperature=0.1
)
company = json.loads(response.choices[0].message.content)
print(f"Company: {company['name']}")
print(f"Founded: {company['founded_year']}")
print(f"HQ: {company['headquarters']['city']}, {company['headquarters']['state']}")
print(f"Employees: {len(company['employees'])}")