Skip to main content

A minimalist LLM modeling library

Project description

ModeLLM

A minimalist LLM modeling library.

Installation

pip install modellm

Usage

from modellm import add_llm

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(model="gpt-4o-mini")
claude_llm = ChatAnthropic(model="claude-3-5-sonnet-20240620")

@add_llm(llm)
class Story(BaseModel):
    """
    A story.
    """

    title: str
    content: str

# LLM model is inherited from the base model (Story)
class ThreeSentenceStory(Story):
    """
    Story written in 3 sentences.
    """
    pass

@add_llm(claude_llm) # We can pick a different llm for a specific model
class StoryForChildren(Story):
    """
    Story for children.
    """
    pass

# story: Story = "A story about a boy who wanted to be a hero" | Story
# story_for_children: StoryForChildren = story | StoryForChildren

text: str = "A story about a boy who wanted to be a hero"
short_children_story: Story = text | StoryForChildren | ThreeSentenceStory

print(short_children_story)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modellm-0.1.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modellm-0.1.0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file modellm-0.1.0.tar.gz.

File metadata

  • Download URL: modellm-0.1.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for modellm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 93e4969c2b68acfd116cc2aa2119cc43507d86826bb3200125e6a5659ad9c020
MD5 9bf6f7fa4ecc2ddeb447c7b169dde1e5
BLAKE2b-256 d585f21fdd59c3214b6a028504e3260db4dee6b26655d7b687ac7dcc8f6b9954

See more details on using hashes here.

File details

Details for the file modellm-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: modellm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for modellm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 35e9cf67c03328221282720abd397e2a3bb0f4e531386a0ed19a2d93b0f9078f
MD5 c09bf1da686c230c49254cd2ef3de653
BLAKE2b-256 928a3682b8422322833f4aa6c693b6cd4cbeb67fa8e91ae8ce19472ac0f1098c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page