Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

noahs_local_ollama_chat_agent-0.1.6.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

noahs_local_ollama_chat_agent-0.1.6-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file noahs_local_ollama_chat_agent-0.1.6.tar.gz.

File metadata

File hashes

Hashes for noahs_local_ollama_chat_agent-0.1.6.tar.gz
Algorithm Hash digest
SHA256 31c3edd91081fba0a7b535781a5e3f2c6b5e52fe4de1fc3b145e375fdd9dca80
MD5 7b3fd15c86530e30030edc0103f39c33
BLAKE2b-256 e58357fa0e73bdf89c5873065549ef176aff894ffe2f01acf1703a1737fe514d

See more details on using hashes here.

File details

Details for the file noahs_local_ollama_chat_agent-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for noahs_local_ollama_chat_agent-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 09f7e5d9f1d6eea0a936f96716173a298a7c9b3e2b5a0beb71a475a58b2581df
MD5 ebde9cdc414ffb11edd13a2d6d4349ee
BLAKE2b-256 be7e77b670f12759232c3707e060cdd985b82b8ded3b7f05f4b7ba0550fd17b1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page