Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

L1M Python SDK

Python SDK for the l1m API, enabling you to extract structured, typed data from text and images using LLMs.

By default, the managed l1m service is used, self-hosting details are available here.

Installation

pip install l1m-dot-io

Usage

from pydantic import BaseModel
from l1m import L1M, ClientOptions, ProviderOptions

class ContactDetails(BaseModel):
  email: str
  phone: str

class UserProfile(BaseModel):
  name: str
  company: str
  contactInfo: ContactDetails


client = L1M(
  options=ClientOptions(
    #base_url: "http://localhost:10337", Optional if self-hosting l1m server
    provider=ProviderOptions(
      model="gpt-4",
      url="https://api.openai.com/v1/chat/completions",
      key="your-openai-key"
    )
  )
)

# Generate a structured response
user_profile = client.structured(
  input="John Smith was born on January 15, 1980. He works at Acme Inc. as a Senior Engineer and can be reached at john.smith@example.com or by phone at (555) 123-4567.",
  # OR   input="<BASE64_ENCODED_IMAGE>",
  schema=UserProfile,
  instructions="Extract details from the provided text.", # Optional
  options=RequestOptions(cache_ttl=100) # Optional
)

Development

# Run tests
pytest