Skip to content

chigwell/passgen-llm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

passgen-llm

PyPI version License: MIT Downloads LinkedIn

passgen_llm is a Python package that leverages a Language Model (LLM) to generate structured, formatted pass content for Apple Wallet. It takes user-provided text input, such as event details, membership information, or coupon data, and ensures the output adheres to Apple's pass requirements by validating the response with pattern matching. This makes it easy for users to create custom, scannable passes without manual formatting.

Features

  • Automated Pass Generation: Automatically generate Apple Wallet passes from user-provided text input.
  • Pattern Matching: Ensures the generated pass content adheres to Apple's pass requirements.
  • Flexible LLM Integration: Supports custom LLM instances, including OpenAI, Anthropic, and Google Generative AI.
  • Easy Installation: Simple installation process with pip.

Installation

You can install passgen_llm using pip:

pip install passgen_llm

Usage

Here's a basic example of how to use passgen-llm:

from passgen_llm import passgen_llm

user_input = "Event: Tech Conference, Date: 2023-10-15, Location: San Francisco"
response = passgen_llm(user_input)
print(response)

Input Parameters

  • user_input (str): The user input text to process.
  • llm (Optional[BaseChatModel]): The LangChain LLM instance to use. If not provided, the default ChatLLM7 will be used.
  • api_key (Optional[str]): The API key for LLM7. If not provided, the environment variable LLM7_API_KEY will be used.

Custom LLM Instances

You can use custom LLM instances by passing them to the passgen_llm function. Here are examples using different LLMs:

OpenAI

from langchain_openai import ChatOpenAI
from passgen_llm import passgen_llm

llm = ChatOpenAI()
response = passgen_llm(user_input, llm=llm)
print(response)

Anthropic

from langchain_anthropic import ChatAnthropic
from passgen_llm import passgen_llm

llm = ChatAnthropic()
response = passgen_llm(user_input, llm=llm)
print(response)

Google Generative AI

from langchain_google_genai import ChatGoogleGenerativeAI
from passgen_llm import passgen_llm

llm = ChatGoogleGenerativeAI()
response = passgen_llm(user_input, llm=llm)
print(response)

API Key

The default rate limits for LLM7 free tier are sufficient for most use cases of this package. If you need higher rate limits, you can pass your own API key via the environment variable LLM7_API_KEY or directly in the function call:

response = passgen_llm(user_input, api_key="your_api_key")

You can get a free API key by registering at LLM7.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License.

Author

Releases

No releases published

Packages

 
 
 

Contributors

Languages