Skip to main content

No project description provided

Project description

LLFn

TBD

How to use

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))
$ poetry run python example.py                                                                                [16:15:28]

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

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

llfn-0.1.0.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

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

llfn-0.1.0-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llfn-0.1.0.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0

File hashes

Hashes for llfn-0.1.0.tar.gz
Algorithm Hash digest
SHA256 889471ab03826f8a14af72c18521fcde84132520d5681a07d8d85fbf7e28d672
MD5 5cce5aa6f804634d74f4812a92f784cd
BLAKE2b-256 e0aca4ab1101eff01931b37d870665a5f7b1a31567af31483b766d5100ea1655

See more details on using hashes here.

File details

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

File metadata

  • Download URL: llfn-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0

File hashes

Hashes for llfn-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4205044138c646ee5e914b967a106919625d7f2166443d6834806f9894dae3bf
MD5 170dd62d8477f216d0db019ff7097825
BLAKE2b-256 f0422596206ef8303e0473f16079c224d7bcc469c8b85a675ccd8c85a84c69f5

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