Skip to main content

Ollama Easy RaG

Simple and quick RAG (Retrieval Augmented Generation) using ollama API.

Get started

  1. Install the package using
pip install ollama-easy-rag
  1. 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)

Source distribution for ollama-easy-rag 0.0.4
File Size Uploaded
ollama_easy_rag-0.0.4.tar.gz 8.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ollama-easy-rag 0.0.4
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page