Simple and quick RAG (Retrieval Augmented Generation) using ollama API.
Project description
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}")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ollama_easy_rag-0.0.4.tar.gz
(8.0 kB
view details)
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 ollama_easy_rag-0.0.4.tar.gz.
File metadata
- Download URL: ollama_easy_rag-0.0.4.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.9.21 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
310f9f872058da1c48640f72cb6ac5c9a2b26dfd249a8c5bd40bdbc138d6321f
|
|
| MD5 |
fb675ea528af621394de8ef23b8cfd41
|
|
| BLAKE2b-256 |
9c3f7681c711c8544eb6e4ba48eb99a8c2ced8f5c8788a5f1c298cffde3d0b0b
|
File details
Details for the file ollama_easy_rag-0.0.4-py3-none-any.whl.
File metadata
- Download URL: ollama_easy_rag-0.0.4-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.9.21 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
075a56e0cf0a38ada0164d2748b44af1689ca37dea45a5c6c683e20df9988530
|
|
| MD5 |
9d033245873cda8ce995544d499dfc31
|
|
| BLAKE2b-256 |
274ef3933decc3f615d4852d07284bb98a3e9ad3b51dfdb65b0611abbe497568
|