llamacpp_client
llamacpp_client is a Python client library designed to simplify communication with the LlamaCpp HTTP server (as provided by the official Docker image). It provides both synchronous and asynchronous interfaces for interacting with LlamaCpp's completion and chat endpoints.
Features
- Synchronous and Asynchronous API:
LlamaCppClient.completion: Synchronous API for blocking calls to/completionendpoint on LlamaCpp server.LlamaCppClient.v1_chat_completions: Synchronous API for synchronous, blocking calls, to OpenAI/v1/chat/completionsendpoint on LlamaCpp server (or any other OpenAI compatible server).LlamaCppClient.async_completion: Asynchronous API for non-blocking, streaming responses to/completionendpoint on LlamaCpp server.LlamaCppClient.async_v1_chat_completions: Asynchronous API for non-blocking, streaming responses to OpenAI/v1/chat/completionsendpoint on LlamaCpp server (or any other OpenAI compatible server).
- Multiple Endpoints Support: Load-balance requests across multiple LlamaCpp server endpoints.
- Easy Configuration:
Use
LlamaCppServerAddressto specify server host and port.
Installation
pip install .
Or add to your pyproject.toml dependencies:
llamacpp_client = { path = "path/to/llamacpp_client" }
Usage
Synchronous example:
from llamacpp_client import LlamaCppClient, LlamaCppServerAddress
endpoints = [
LlamaCppServerAddress(host="localhost", port=8080)
]
client = LlamaCppClient(endpoints)
response = client.completion(prompt="Hello, world!")
print(response)
Asynchronous example:
import asyncio
from llamacpp_client import LlamaCppClient, LlamaCppServerAddress
async def main():
endpoints = [
LlamaCppServerAddress(host="localhost", port=8080)
]
client = LlamaCppClient(endpoints)
async for chunk in client.async_completion(prompt="Hello, world!"):
print(chunk.decode(), end="")
asyncio.run(main())
Requirements
License
MIT
-- Developed by Luís Gomes luismsgomes@gmail.com.
Metadata
Release files for llamacpp-client 0.2.3
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 |
|---|---|---|---|---|
| llamacpp_client-0.2.3.tar.gz | 5.7 kB | Without provenance | Details for llamacpp_client-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llamacpp_client-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for llamacpp_client-0.2.3-py3-none-any.whl |
Total release size: 11.5 kB
Release files / llamacpp_client-0.2.3.tar.gz
| Download URL | llamacpp_client-0.2.3.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
57c004099fd4e72aa021ab00cf1823975ccaddff2d69dcc6c85f6f12b5bee803
|
|
BLAKE2b-256 checksum How to use checksums |
3bbdc344781ab0441c41a583cb8f28f4f9f04232bcb06b9e666d5cbc9615fc24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.2
|
Release files / llamacpp_client-0.2.3-py3-none-any.whl
| Download URL | llamacpp_client-0.2.3-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f86076b8e0386a507dbc36c991614df9bb18a9f69958a72db772a545583e5ff
|
|
BLAKE2b-256 checksum How to use checksums |
3cfc42d54decde675e0ad9ef0d4d31d0d8f1118135ff4bf9604914171cb62630
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.2
|
Security for llamacpp-client 0.2.3
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.