LlamaIndex Llms Integration: Reka
This package provides integration between the Reka language model and LlamaIndex, allowing you to use Reka's powerful language models in your LlamaIndex applications. Installation To use this integration, you need to install the llama-index-llms-reka package:
pip install llama-index-llms-reka
To obtain API key, please visit https://platform.reka.ai/ Our baseline models always available for public access are:
reka-edgereka-flashreka-core
Other models may be available. The Get Models API allows you to list what models you have available to you. Using the Python SDK, it can be accessed as follows:
from reka.client import Reka
client = Reka()
print(client.models.get())
Here are some examples of how to use the Reka LLM integration with LlamaIndex:
import os
from llama_index.llms.reka import RekaLLM
api_key = os.getenv("REKA_API_KEY")
reka_llm = RekaLLM(model="reka-flash", api_key=api_key)
Initialize the Reka LLM client
api_key = os.getenv("REKA_API_KEY")
reka_llm = RekaLLM(model="reka-flash", api_key=api_key)
Chat completion
from llama_index.core.base.llms.types import ChatMessage, MessageRole
messages = [
ChatMessage(
role=MessageRole.SYSTEM, content="You are a helpful assistant."
),
ChatMessage(
role=MessageRole.USER, content="What is the capital of France?"
),
]
response = reka_llm.chat(messages)
print(response.message.content)
Text completion
prompt = "The capital of France is"
response = reka_llm.complete(prompt)
print(response.text)
Streaming Responses python
Streaming chat completion
messages = [
ChatMessage(
role=MessageRole.SYSTEM, content="You are a helpful assistant."
),
ChatMessage(
role=MessageRole.USER,
content="List the first 5 planets in the solar system.",
),
]
for chunk in reka_llm.stream_chat(messages):
print(chunk.delta, end="", flush=True)
Streaming text completion
prompt = "List the first 5 planets in the solar system:"
for chunk in reka_llm.stream_complete(prompt):
print(chunk.delta, end="", flush=True)
Asynchronous Usage
import asyncio
async def main():
# Async chat completion
messages = [
ChatMessage(role=MessageRole.SYSTEM, content="You are a helpful assistant."),
ChatMessage(role=MessageRole.USER, content="What is the largest planet in our solar system?"),
]
response = await reka_llm.achat(messages)
print(response.message.content)
# Async text completion
prompt = "The largest planet in our solar system is"
response = await reka_llm.acomplete(prompt)
print(response.text)
# Async streaming chat completion
messages = [
ChatMessage(role=MessageRole.SYSTEM, content="You are a helpful assistant."),
ChatMessage(role=MessageRole.USER, content="Name the first 5 elements in the periodic table."),
]
async for chunk in await reka_llm.astream_chat(messages):
print(chunk.delta, end="", flush=True)
# Async streaming text completion
prompt = "List the first 5 elements in the periodic table:"
async for chunk in await reka_llm.astream_complete(prompt):
print(chunk.delta, end="", flush=True)
asyncio.run(main())
Running Tests
To run the tests for this integration, you'll need to have pytest and pytest-asyncio installed. You can install them using pip:
pip install pytest pytest-asyncio
Then, set your Reka API key as an environment variable:
export REKA_API_KEY=your_api_key_here
Now you can run the tests using pytest:
pytest tests/test_reka_llm.py -v
To run only mock integration test without remote connections pytest tests/test_reka_llm.py -v -k "mock" Note: The test file should be named test_reka_llm.py and placed in the appropriate directory.
Contributing
Contributions to improve this integration are welcome. Please ensure that you add or update tests as necessary when making changes. When adding new features or modifying existing ones, please update this README to reflect those changes.
Metadata
Release files for llama-index-llms-reka 0.5.0
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 |
|---|---|---|---|---|
| llama_index_llms_reka-0.5.0.tar.gz | 6.8 kB | Without provenance | Details for llama_index_llms_reka-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llama_index_llms_reka-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for llama_index_llms_reka-0.5.0-py3-none-any.whl |
Total release size: 13.4 kB
Release files / llama_index_llms_reka-0.5.0.tar.gz
| Download URL | llama_index_llms_reka-0.5.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cfdb17f59bf29701fbe79969a681cd193b107c518a5a5473ed021e129af2c763
|
|
BLAKE2b-256 checksum How to use checksums |
89cef1e7e9dfe549d204cef813d178ed3e248133c6dd93df920a7467c307f321
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / llama_index_llms_reka-0.5.0-py3-none-any.whl
| Download URL | llama_index_llms_reka-0.5.0-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f36272956100de3b64471fea532adfa0d1c97f461dcfbd2c58a5795e36dfb780
|
|
BLAKE2b-256 checksum How to use checksums |
61ce0447338bf0cc3037ac0c983df136a22af070f5695def283daf19e282d391
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for llama-index-llms-reka 0.5.0
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.