import json
import pandas as pd
from chatlas import ChatOllama
from pydantic import BaseModel, Field12 Chatlas: Structural Data
chat = ChatOllama(model="llama3.1:8b") class Person(BaseModel):
name: str
age: int
chat.extract_data(
"My name is Susan and I'm 13 years old",
data_model=Person,
){'name': 'Susan', 'age': 13}
class Person2(BaseModel):
"""A person"""
name: str = Field(description="Name")
age: int = Field(description="Age, in years")
hobbies: list[str] = Field(
description="List of hobbies. Should be exclusive and brief."
)chat.extract_data(
"My name is Susan and I'm 13 years old. I like swimmming.",
data_model=Person2,
){'name': 'Susan', 'age': 13, 'hobbies': ['swimming']}