A lightweight interface for calling LLMs with strategy.
Project description
Llyra
Lightweight LLaMA Reasoning Assistant
✨ Features
-
Hybrid Backend Support
Use localllama-cpp-pythonor connect to a remote Ollama endpoint via the same interface. -
Minimal, Configurable Inference
Load prompts, model parameters, and tools from external files. -
Prompt Engineering Friendly
Easily manage system prompts, roles, and chat formats through external.txtfiles. -
Optional RAG Integration (Coming Soon)
Native support for Weaviate-based retrieval-augmented generation. -
Tool Support (Planned)
Enable LLMs to use JSON-defined tools (function-calling style) with one argument.
⚙️ Dependencies
Llyra does not bundle any backend inference engines. You must install them manually according to your needs:
Required (choose one):
- For local models: llama-cpp-python
- For remote inference: any Ollama-compatible API
📦 Installation
pip install llyra
🚀 Quickstart
- Make directary
configs/in your project root. - Add
config.tomlandstategy.tomltoconfigs/directory. - Make your first iterative chat inference with follwing example:
from llyra import Llyra
model = Llyra(mode='local')
response = model.chat('Evening!',keep=True)
print(response)
🧩 Function APIs
Initialize Instance
A simple unified interface provides through the Llyra class.
-
modeargument is necessary to decide inference locally or remotely when initialize instance.It's the only chance you can choose the backend, bachend can't be changed in runtime.
-
pathargument is optional to override default path to config file when initialize instance.The default path is
./configs/config.toml. Be noticed thattomlis the only valid config file format.
Here provide simple demo showing how to initialize Llyra instance:
Inference Locally
from llyra import Llyra
model = Llyra(mode='local')
Inference Remotely
from llyra import Llyra
model = Llyra(mode='remote')
Execute Inference
Llyra provides two method to execute single call inference and iterative chat inference.
call() method
call() method provides a simple interface to execute single call inference.
inputargument will take a string as the prompt content for model inference.
It will return a string as the response of model inference.
Here provide a simple demo showing how to execute single call inference:
response = model.call('Evening!')
print(response)
chat() method
chat() method provides a simple interface to execute iterative chat inference.
messageargument will take a string as the current input content for model inference.keepargument will take a boolean as the choice of whether keeping current section's content.- Set
keepto True to keep the current section's content. - Set
keepto False to start a new section from this call.
Yes, you don't need to handle the content,
Llyracan do that.- Set
It will return a string as the response of the inference's model reply.
Here provide a simple demo showing how to execute iterative chat inference:
response = model.chat('Evening!',True)
print(response)
Get log
Llyra record inference log internally with a custome format which isn't read-friendly for user.
To get readable log record, please using get_log() method.
get_log() method provides a simple interface to extract log record and convert it into readable format without affecting internal log records.
-
idargument will take a integer as the index of log record.- Set
idto a positive value to get specific log record.It will raise
IndexErrorwhenidvalue out of range. - Set
idto a negative value to get all log records.
It will return a dictionary when getting a specific log record, and a list of dictionaries when getting all log records.
- Set
Llyrastarts its log's id from 0.
Here provide a simple demo showing how to get a specific log record in readable format:
log = model.get_log(1)
print(log)
And, the individual log record should be looked like as:
{
'id': 1,
'type': 'call',
'model': 'llama-2',
'addition': 'You are a kind assistant.',
'role': {
'prompt': 'system',
'input': 'user',
'output': 'assistant'
},
'iteration': [
{'query': 'Evening!','response': 'Evening, how can I help you today?'}
],
'temperature': 0.6,
'create_at': 1750742992.32208
}
🛠 Configuration Example
config.toml
[global]
strategy = "configs/strategy.toml"
[local]
format = "llama-2"
gpu = true
ram = false
[local.model]
name = "Distill-Llama-8B"
directory = "models/"
suffix = ".gguf"
[remote]
model = "llama-2"
[remote.server]
url = "http://localhost"
port = 11434
endpoint = "api/"
strategy.toml
[call]
stop = "<EOF>"
temperature = 0.6
[chat]
prompt = "prompts/prompt.txt"
stop = "<EOF>"
temperature = 0.6
[chat.role]
prompt = "system"
input = "user"
output = "assistant"
🧭 Roadmap
| Phase | Feature | Status |
|---|---|---|
| 1 | Minimal llama-cpp-python local chat |
✅ Finished |
| 2 | Predefined prompts via .txt / .json |
✅ Finished |
| 3 | Ollama remote API support | ✅ Finished |
| 4 | Section & Branch control. | ⏳ Planned |
| 5 | Weaviate RAG support | ⏳ Planned |
| 6 | Tool/function-calling via JSON | ⏳ Planned |
🪪 License
This project is licensed under the MIT License.
📚 Attribution
Currently, this package is built on top of the following open-source libraries:
- llama-cpp-python — licensed under the MIT License
Python bindings for llama.cpp
This package does not include or redistribute any third-party source code.
All dependencies are installed via standard Python packaging tools (e.g. pip).
We gratefully acknowledge the authors and maintainers of these libraries for their excellent work.
🌐 About the Name
Llyra is inspired by the constellation Lyra, often associated with harmony and simplicity.
In the same way, this package aims to bring harmony between developers and language models.
Designed with care. Built for clarity.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llyra-0.2.0.tar.gz.
File metadata
- Download URL: llyra-0.2.0.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7049fa577b2bc796a2b6eb3929a303bee8456b3a4cc46a54430b6078e7796068
|
|
| MD5 |
d7d7fca2c9b306ea1328f21390247d97
|
|
| BLAKE2b-256 |
d83c687a866bfbbbc641e7f5f2102dc93ab5f730c7df5beeb5450f6115a3e822
|
File details
Details for the file llyra-0.2.0-py3-none-any.whl.
File metadata
- Download URL: llyra-0.2.0-py3-none-any.whl
- Upload date:
- Size: 27.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdccc4deb8dca2d484e7180bd07a7014af7e975db9185130ecbab9f83b117dd4
|
|
| MD5 |
1131dfa039aa6e0233d63f09fa74fb10
|
|
| BLAKE2b-256 |
2c74c33b5985408dc90794c8659422fe2d2aa0d5ec871d6d4853d305148c40b6
|