llm-loop
Overview
llm-loop is a Python package designed to simplify the process of querying language models (like GPT or similar models) until a response matching a specified pattern is obtained or a maximum number of attempts is reached. This is particularly useful when working with AI models in scenarios where a specific format of response is required.
Installation
pip install llm-loop
This will install the necessary Python packages, including ctransformers and any other dependencies.
Usage
Here's a basic example of how to use llm-loop:
-
Import the necessary modules:
import os from ctransformers import AutoModelForCausalLM, AutoTokenizer from llm_loop.main import LLMLoop
-
Initialize the model with custom parameters:
model_name = "YourModelName" model_file = "YourModelFileName" start_dir = '/path/to/your/model' model_path = f"{start_dir}/{model_file}" llm = AutoModelForCausalLM.from_pretrained(model_name, model_file=model_path, model_type='YourModelType', gpu_layers=YourGPULayers)
-
Create an instance of LLMLoop and query the model:
loop = LLMLoop(llm, 10) # 10 is the maximum number of attempts prompt = "Your prompt here" pattern = r'Your regex pattern here' response = loop.query_llm(prompt=prompt, pattern=pattern) print("Response:", response)
Contributing
Contributions to llm-loop are welcome! Please feel free to submit pull requests or open issues to suggest improvements or add new features.
License
MIT.
Metadata
Release files for llm-loop 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llm-loop-0.2.tar.gz | 1.9 kB | Without provenance | Details for llm-loop-0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llm_loop-0.2-py3-none-any.whl | Python 3 | none | any | Details for llm_loop-0.2-py3-none-any.whl |
Total release size: 3.7 kB
Release files / llm-loop-0.2.tar.gz
| Download URL | llm-loop-0.2.tar.gz |
|---|---|
| Size | 1.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
02eadb0b7ed176210ad6cccf3b32864a0b65eef4e4a541386c10c9076d1bd9fd
|
|
BLAKE2b-256 checksum How to use checksums |
4792147b3760a05e28f00d715425f5dcbff0b815212507746ff324078ad3ae6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / llm_loop-0.2-py3-none-any.whl
| Download URL | llm_loop-0.2-py3-none-any.whl |
|---|---|
| Size | 1.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f33cf89d7d08f0cbf13c4b020126ed1ac50f32c408fa78d3fc3be411045fe3e
|
|
BLAKE2b-256 checksum How to use checksums |
d8fa75c25eaa96461f9483f884fcd4e38c652a5d6de452aa35ca523664d2e317
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Security for llm-loop 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.