Skip to main content

Attributes

The Direct class accepts the following attributes during initialization:
AttributeTypeDefaultDescription
modelUnion[str, Any, None]"openai/gpt-4o"Model identifier or Model instance
settingsModelSettings | NoneNoneModel-specific configuration including temperature, max_tokens, etc.
profileModelProfileSpec | NoneNoneModel profile configuration for advanced customization
providerUnion[str, Provider] | NoneNoneProvider name or Provider instance for custom provider integration

Configuration Example

from upsonic import Direct, Task
from upsonic.models.settings import ModelSettings
from pydantic import BaseModel

# Define structured output
class ExtractedData(BaseModel):
    company_name: str
    tax_number: str
    total_amount: float

# Create Direct instance with configuration
settings = ModelSettings(temperature=0.1, max_tokens=500)
direct = Direct(
    model="openai/gpt-4o",
    settings=settings
)

# Create task with PDF attachment
task = Task(
    description="Extract company name, tax number, and total amount from the invoice",
    attachments=["invoice.pdf"],
    response_format=ExtractedData
)

# Execute
result = direct.do(task)
print(f"Company: {result.company_name}")
print(f"Tax Number: {result.tax_number}")
print(f"Amount: ${result.total_amount}")