LLM Tools
This package wraps the OpenAI API and other LLM models that share the completion endpoint feature. It provides a simple interface to generate text from a prompt.
Installation
pip install llm-tools
Usage
from llm_tools.openai import prompt
from pathlib import Path
# Create a prompt object that will be logged to the `my-task` directory under the
# current working directory.
# The PromptZeros class will use arguments that will maximize the determinism of the outputs.
pz = prompt.PromptZeros(Path("./"), "my-task")
# Send a prompt to the API and return the response.
w = pz.send_prompt("What is the WDI code for GDP?", return_data=True)
# Print the response.
print(w)
# Output:
# {'message': [{'role': 'system', 'content': ''}, {'role': 'user', 'content': 'What is the WDI code for GDP?'}], 'response': {'id': 'chatcmpl-8V0IN0VbeYTrsBAohs309DHJQLJL8', 'choices': [{'finish_reason': 'stop', 'index': 0, 'message': {'content': 'The WDI code for GDP (Gross Domestic Product) is "NY.GDP.MKTP.CD".', 'role': 'assistant', 'function_call': None, 'tool_calls': None}}], 'created': 1702399995, 'model': 'gpt-3.5-turbo-0613', 'object': 'chat.completion', 'system_fingerprint': None, 'usage': {'completion_tokens': 23, 'prompt_tokens': 20, 'total_tokens': 43}}, 'content': 'The WDI code for GDP (Gross Domestic Product) is "NY.GDP.MKTP.CD".', 'api_kwargs': {'temperature': 0, 'top_p': 0, 'n': 1, 'stream': False, 'frequency_penalty': 0, 'presence_penalty': 0, 'model': 'gpt-3.5-turbo', 'max_tokens': 4029}, 'metadata': {}, 'message_hash': '1a5816095c232f29428d4cec70498391'}
NOTE: The output is also logged to the my-task directory under the current working directory.
Metadata
Release files for llm-commons 0.0.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 | Provenance | Actions |
|---|---|---|---|---|
| llm_commons-0.0.1.tar.gz | 5.5 kB | Without provenance | Details for llm_commons-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llm_commons-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for llm_commons-0.0.1-py3-none-any.whl |
Total release size: 12.2 kB
Release files / llm_commons-0.0.1.tar.gz
| Download URL | llm_commons-0.0.1.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3c1b0335e8e39d430d9a226d9e1bc6b4183fc3246590f2b29830dc8c9f784cd2
|
|
BLAKE2b-256 checksum How to use checksums |
75f0920a367508400b2bc279ef3d630d23a3bf287e5534bf8662ee3f58d24f29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.10.6 Darwin/23.1.0
|
Release files / llm_commons-0.0.1-py3-none-any.whl
| Download URL | llm_commons-0.0.1-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2ebe9bc2560b76ab3a7f1652824629fb21e6811f4ffc3ae8ce62b003834686ed
|
|
BLAKE2b-256 checksum How to use checksums |
e469a4caefa7e3c8079eb17cd29b1fc8289a7bcf5197508443901daaf6a97b58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.10.6 Darwin/23.1.0
|
Security for llm-commons 0.0.1
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.