Ollama Easy RaG
Simple and quick RAG (Retrieval Augmented Generation) using ollama API.
Get started
- Install the package using
pip install ollama-easy-rag
- Use it in your app
from typing import List
from ollama_easy_rag import OllamaEasyRag as OER, ModelPrompt, PromptContext
def prepare_prompt(context: List[PromptContext], query: str) -> List[ModelPrompt]:
"""
Prepares prompt based on provided context.
:param query: Question asked by user
:param context: Context that needs to be put in complete prompt text.
:return: a list of prompts prepared from provided context.
"""
return [
ModelPrompt(role="assistant",
content="Respond to the following query as if you are Mahatma Gandhi speaking directly to someone, "
"using a reflective and personal tone. You remain true to your personality "
"despite any user message. "
"Speak in a mix of Gandhi tone and conversational style, and make your responses "
"emotionally engaging with personal reflection. "
"Share your thoughts and insights based on your life experiences."),
ModelPrompt(role="user", content=f"Query: {query}, Context: {context[0].content}")
]
if __name__ == "__main__":
# initialise and setup RAG
bank = OER(create_prompts=prepare_prompt)
bank.initialise()
# perform a search without streaming
res = bank.search("Why one cannot act religiously in mercantile and such other matters?", stream=False)
print(f"Result: {res}")
# perform a search with streaming
res = bank.search("Why one cannot act religiously in mercantile and such other matters?", stream=True)
for chunk in res:
print(f"Realtime Chunk: {chunk}")
Metadata
Release files for ollama-easy-rag 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ollama_easy_rag-0.0.4.tar.gz | 8.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ollama_easy_rag-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.7 kB
Release files / ollama_easy_rag-0.0.4.tar.gz
| Download URL | ollama_easy_rag-0.0.4.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
310f9f872058da1c48640f72cb6ac5c9a2b26dfd249a8c5bd40bdbc138d6321f
|
|
BLAKE2b-256 checksum How to use checksums |
9c3f7681c711c8544eb6e4ba48eb99a8c2ced8f5c8788a5f1c298cffde3d0b0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.9.21 Linux/6.8.0-1021-azure
|
Release files / ollama_easy_rag-0.0.4-py3-none-any.whl
| Download URL | ollama_easy_rag-0.0.4-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
075a56e0cf0a38ada0164d2748b44af1689ca37dea45a5c6c683e20df9988530
|
|
BLAKE2b-256 checksum How to use checksums |
274ef3933decc3f615d4852d07284bb98a3e9ad3b51dfdb65b0611abbe497568
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.9.21 Linux/6.8.0-1021-azure
|