Metadata-Version: 2.1
Name: llmgen
Version: 0.1.3
Summary: Effortlessly generate LLM APIs by simply defining input and output schemas.
Author: koswu
Author-email: koswu@outlook.com
Requires-Python: >=3.8.1,<4.0.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: langchain (>=0.2.11,<0.3.0)
Requires-Dist: langchain-openai (>=0.1.19,<0.2.0)
Requires-Dist: pydantic (>=2.8.2,<3.0.0)
Requires-Dist: typing-extensions (>=4.12.2,<5.0.0)
Description-Content-Type: text/markdown

# llmgen

[![PyPI](https://img.shields.io/pypi/v/llmgen?label=pypi%20package)](https://pypi.org/project/llmgen/)

Effortlessly generate LLM APIs by simply defining input and output schemas (by pydantic).


## Quick Start

Example:

```python
from pydantic import BaseModel, Field
from llmgen import OpenAiApiFactory

# describe your input
class _JokeRequest(BaseModel):
    """Request for a joke"""

    theme: str = Field(description="The theme of the joke")


# describe your output
class _JokeResponse(BaseModel):
    """A joke response"""

    setup: str = Field(description="The setup of the joke")
    punchline: str = Field(description="The punchline of the joke (the funny part)")
    description: str = Field(description="Description of why the joke is funny")
    level: int = Field(description="Funny level of the joke (1-5)", le=5, ge=1)



factory = OpenAiApiFactory(
    api_key="your api key here",
)

# Create an API
api = factory.make_api(_JokeRequest, _JokeResponse)

# Call the API
res = api.call(_JokeRequest(theme="cat"))

print(res.model_dump())
"""
A joke response like:
{
'setup': 'Why was the cat sitting on the computer?', 
'punchline': 'Because it wanted to keep an eye on the mouse!', 
'description': "This joke is funny because it plays on the double meaning of 'mouse'—the computer accessory and the animal that cats typically chase. The image of a cat being so tech-savvy is also amusing.", 
'level': 4
}
"""

```


