Metadata-Version: 2.1
Name: llfn
Version: 0.1.0
Summary: 
Author: Sorawit Suriyakarn
Author-email: thepsint@gmail.com
Requires-Python: >=3.8.1,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: langchain (>=0.0.235,<0.0.236)
Requires-Dist: openai (>=0.27.8,<0.28.0)
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
Description-Content-Type: text/markdown

# LLFn

TBD

## How to use

````py
import dotenv
import os
from llfn import prompt_function, global_bind
from langchain.chat_models import ChatOpenAI

@prompt_function
def translate(text: str, to_language: str) -> str:
    return f"""
You must automatically detect the language of the following text and tranlate it to {to_language}
```
{text}
```
"""

@prompt_function
def summarize(text: str, length: int) -> str:
    return f"""
You must summarize the following text to a smaller text approximately {length} words long
```
{text}
```
"""

if __name__ == "__main__":
    dotenv.load_dotenv()
    llm = ChatOpenAI(
        temperature=0.8,
        model=os.getenv("OPENAI_MODEL"),
        openai_api_key=os.getenv("OPENAI_API_KEY"),
    )  # type: ignore
    global_bind(llm)
    print(translate("สวัสดีตอนเช้าครับ อยากรับประทานอะไรดีครับเช้าวันนี้", "english"))
    print(summarize("I love my dogs. They are corgis. They love nuggets", 4))
````

```sh
$ poetry run python example.py                                                                                [16:15:28]

# Good morning, what would you like to have for breakfast today?
# I love corgi dogs
```
