Lumen Brain Python Client
A Python client library for interacting with the Lumen Brain API. GitHub: https://github.com/Lumen-Labs/lumen-brain
Features
On-demand memory/context driver to interact with the Lumen Brain API and improve the context and responses of LLMs without finetuning.
Installation
pip install lumen-brain
Usage
Async Client
from lumen_brain import AsyncLumenBrainDriver
# Initialize the client
client = AsyncLumenBrainDriver(api_key="your-api-key")
# Save a message
await client.save_message(
memory_uuid="your-memory-uuid", # the unique identifier provided by your app, if not provided, a new memory will be created
type="message",
content="Your message content",
role="user",
# Optional Fields
conversation_id="your-conversation-id", # If not provided, a new conversation will be created
metadata={"key": "value"}
)
# Query memory
# The result will be a MemoryUpdateResponse object with a context field
# the context field can be appended to the message that will be sent to the agent to improve the agent's response
# allowing the agent to have a more accurate and relevant context around the user's message
result = await client.query_memory(
text="Your query",
memory_uuid="your-memory-uuid", # the unique identifier provided by your app, if not provided, a new memory will be created
conversation_id="your-conversation-id"
)
# Inject knowledge
# additional knowledge can be injected into the memory, for example if you are synking the user's emails, files etc.
# works also if you want the agent to answer better arount a specific topic like documents etc.
await client.inject_knowledge(
memory_uuid="your-memory-uuid", # the unique identifier provided by your app, if not provided, a new memory will be created
type="message",
content="Your message content",
resource_type="file",
# Optional Fields
metadata={"key": "value"}
)
Sync Client
from lumen_brain import LumenBrainDriver
# Initialize the client
client = LumenBrainDriver(api_key="your-api-key")
# Save a message
client.save_message(
memory_uuid="your-memory-uuid",
type="message",
content="Your message content",
role="user"
)
# Query memory
result = client.query_memory(
text="Your query",
memory_uuid="your-memory-uuid",
conversation_id="your-conversation-id"
)
Fetch info
result = client.fetch_info(
memory_uuid="your-memory-uuid", # the unique identifier provided by your app, if not provided, a new memory will be created
entities=["john"], # the entities that are related to the information to be retrieved
info="wedding date", # the information to be retrieved
depth=2 # the higher relation depth that will be looked for
)
result.nodes # the nodes that are related to the information to be retrieved
result.most_relevant_relation # the most relevant relation between the entities and the information to be retrieved
result.most_relevant_confidence # the confidence of the most relevant relation (0-1)
License
This project is licensed under the MIT License.
Metadata
Release files for lumen_brain 0.3.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 |
|---|---|---|---|---|
| lumen_brain-0.3.3.tar.gz | 6.4 kB | Without provenance | Details for lumen_brain-0.3.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lumen_brain-0.3.3-py3-none-any.whl | Python 3 | none | any | Details for lumen_brain-0.3.3-py3-none-any.whl |
Total release size: 16.8 kB
Release files / lumen_brain-0.3.3.tar.gz
| Download URL | lumen_brain-0.3.3.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20c852c34256f5fbd98ecbb981b74408dd9515f92f35e261e969c8986bcb59d8
|
|
BLAKE2b-256 checksum How to use checksums |
6ebfc6e4c93085722ca736386825943861d2c6dd08db357d96cf9430bb4315e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.12.4 Darwin/24.6.0
|
Release files / lumen_brain-0.3.3-py3-none-any.whl
| Download URL | lumen_brain-0.3.3-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c1120ee2b14e515bbb5a040cc8fff29e6ccee4b0f6987cf084d612f3a4ea6406
|
|
BLAKE2b-256 checksum How to use checksums |
51b731a01adde58cbf508c90473424cacce585387703905680d35f05b45aa173
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.12.4 Darwin/24.6.0
|
Security for lumen_brain 0.3.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.