A local agent module with semantic DB, SQL, and web scraping tools.
Project description
Usage: noahs_local_ollama_chat_agent
This library wraps interactions with a local Ollama server and provides tools for:
- Maintaining a conversation history
- Calling a local LLM via the Ollama REST API
- Performing semantic text splitting and search
- Running local SQL-style lookups
- Extracting and analyzing URLs from text
Getting Started
First, install the library (after uploading to PyPI):
pip install noahs_local_ollama_chat_agent
from noahs_local_ollama_chat_agent import ollama_chat_agent
# Analyze a document without having to upload entire document into context window
# 1. create agent, ollama api must be running in background and provided model must be installed
agent = ollama_chat_agent(name="Tomatio", model="llama3.2")
# 2. (optional) purge semantic database for fresh start
agent.semantic_db.purge_collection();
# 3. upload txt file of your choosing in chunks of 5 sentences to the semantic database
agent.upload_document("docs/AliceInWonderland.txt", max_sentences_per_chunk=5)
# 4. do a semantic search for 5 relevent passages to a semantic_query and add it to the context window of the agent
semantic_query = "Interactions between Alice and the Mad Hatter"
agent.discuss_document(semantic_query, doc_name="AliceInWonderland.txt", semantic_top_k=5)
# 5. start the chat with a question about the uploaded content.
message = "Tell me about the relationship between Alice and the Mad Hatter. Use examples from the provided passages"
response_stream = agent.chat(message)
print("\n")
print(f"You: {message}")
agent.print_stream(response_stream)
print("\n")
print("Continue to chat...")
print("\n")
while message not in ["bye","goodbye","exit","quit"]:
message = input("You: ")
response_stream = agent.chat(message)
agent.print_stream(response_stream)
Check out Source Code
https://github.com/jonesnoah45010/local_ollama_chat_agent
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 noahs_local_ollama_chat_agent-0.1.3.tar.gz.
File metadata
- Download URL: noahs_local_ollama_chat_agent-0.1.3.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b25b300b5edcd643713bb9c83331df3c91cecdc694a46c045d82f09338cb9a97
|
|
| MD5 |
af166a8d3c649ca9aa06cadf6459b6d1
|
|
| BLAKE2b-256 |
a2cbfdcdd397a4739c6ff77a70dc1d4c05b097b5e8e197dfc31f320a25ebbb48
|
File details
Details for the file noahs_local_ollama_chat_agent-0.1.3-py3-none-any.whl.
File metadata
- Download URL: noahs_local_ollama_chat_agent-0.1.3-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bf285fb71d32d647033ec531655204ca6dba147f333b4ac0625ced0d1d6b96f
|
|
| MD5 |
8ae3a2cf474e053bf3f55b8404b4240a
|
|
| BLAKE2b-256 |
da11bac1da19f7ef28a1be723df59a55501c7236acee800b0fa0cbdda2ebc64f
|