A simple Python client for the Snapzion Search API, packaged as SearchMind.
Project description
SearchMind: A Python Client for Snapzion Search
A simple Python client for the Snapzion Search API.
SearchMind is a lightweight wrapper that makes it easy to fetch search results and format them for use in other applications, especially for providing real-time web context to Large Language Models (LLMs) like those from OpenAI.
Features
- Simple and intuitive API:
client.search("your query"). - Built-in helper to format results into a clean string for LLM prompts.
- Uses
requests.Sessionfor efficient connection pooling. - Proper error handling with custom
SearchMindErrorexceptions. - Fully type-hinted for better editor support and code quality.
Installation
pip install searchmind
Quick Start
Getting search results is straightforward.
from searchmind import SearchMindClient, SearchMindError
# 1. Initialize the client
client = SearchMindClient()
# 2. Perform a search
try:
results = client.search("latest trends in renewable energy")
# The result is a list of dictionaries
for item in results:
print(f"[{item['position']}] {item['title']}")
print(f" Link: {item['link']}\n")
except SearchMindError as e:
print(f"An error occurred: {e}")
Usage with LLMs (e.g., OpenAI API)
The primary goal of this library is to act as a web search tool for LLMs. The format_for_llm utility creates a perfectly formatted context string.
from searchmind import SearchMindClient, format_for_llm, APIError
# from openai import OpenAI # Hypothetical usage
# 1. Initialize the SearchMind client
search_client = SearchMindClient()
# 2. Define your query
user_query = "What are the main AI trends for 2025 according to recent articles?"
# 3. Get search results
try:
print(f"Searching for: '{user_query}'...")
search_results = search_client.search(user_query)
# 4. Format the results into a single string for the LLM
search_context = format_for_llm(search_results)
print("\n--- Formatted Context for LLM ---\n")
print(search_context)
# 5. Use the context in a prompt to an LLM
# client = OpenAI(api_key="your-openai-key")
#
# response = client.chat.completions.create(
# model="gpt-4o",
# messages=[
# {"role": "system", "content": "You are a helpful assistant. Answer the user's question based *only* on the provided search context. Cite your sources using the [number] and URL."},
# {"role": "user", "content": f"Question: {user_query}\n\nSearch Context:\n---\n{search_context}\n---"}
# ]
# )
#
# print("\n--- LLM Response ---\n")
# print(response.choices[0].message.content)
except APIError as e:
print(f"An error occurred while searching: {e}")
Contributing
Contributions are welcome! Please open an issue or submit a pull request on our GitHub repository.
License
This project is licensed under the MIT License.
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 searchmind-0.1.4.tar.gz.
File metadata
- Download URL: searchmind-0.1.4.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecc009507cb8fcb0acf13b62eb4c6c01495eacb13b8196a24d42b3aac5c52292
|
|
| MD5 |
2bfeb7fcf7253b685ad4144ae8aef0d7
|
|
| BLAKE2b-256 |
09d8e2db65ec8dd0d50b07d531ee26cef24aafa573bf6a638f2bcb382850f3fe
|
File details
Details for the file searchmind-0.1.4-py3-none-any.whl.
File metadata
- Download URL: searchmind-0.1.4-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
341aa34770bf739b1078d6a243fa3ce6d073ff778e3216254f482caf4a1d17b6
|
|
| MD5 |
a87f326a1b14d1f05767e379dd6c3a38
|
|
| BLAKE2b-256 |
c2133f73699ed097f32f329bbb0cf6c382227ef295e65ef7ba8fd1459a8132bd
|