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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93e4969c2b68acfd116cc2aa2119cc43507d86826bb3200125e6a5659ad9c020
|
|
| MD5 |
9bf6f7fa4ecc2ddeb447c7b169dde1e5
|
|
| BLAKE2b-256 |
d585f21fdd59c3214b6a028504e3260db4dee6b26655d7b687ac7dcc8f6b9954
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35e9cf67c03328221282720abd397e2a3bb0f4e531386a0ed19a2d93b0f9078f
|
|
| MD5 |
c09bf1da686c230c49254cd2ef3de653
|
|
| BLAKE2b-256 |
928a3682b8422322833f4aa6c693b6cd4cbeb67fa8e91ae8ce19472ac0f1098c
|