LLFn
TBD
How to use
import dotenv
import os
from llfn import LLFn
from langchain.chat_models import ChatOpenAI
prompt_function = LLFn()
@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
prompt_function.bind(llm)
print(translate("สวัสดีตอนเช้าครับ อยากรับประทานอะไรดีครับเช้าวันนี้", "english"))
print(summarize("I love my dogs. They are corgis. They love nuggets", 4))
$ poetry run python example.py
# Good morning, what would you like to have for breakfast today?
# I love corgi dogs
Release files for llfn 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| llfn-0.1.1.tar.gz | 2.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llfn-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.5 kB
Release files / llfn-0.1.1.tar.gz
| Download URL | llfn-0.1.1.tar.gz |
|---|---|
| Size | 2.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
64f2e2c0aa0af441f9fd3cf95b07c3b2076304ce0ef822c9c48283f52edaafe8
|
|
BLAKE2b-256 checksum How to use checksums |
94db4a30ada50d1d542403c15fb4b31deb17902b0b511298fc369e3a1b771bcf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0
|
Release files / llfn-0.1.1-py3-none-any.whl
| Download URL | llfn-0.1.1-py3-none-any.whl |
|---|---|
| Size | 2.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8df578fb55c40454dc893e2a628fb028e80968479f9f3fa3e77622e00d6c00b5
|
|
BLAKE2b-256 checksum How to use checksums |
0615172b00c3d750cc4c71153369c8bff9dd1a55a7eda9f6d547e5e9beda924b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0
|