Skip to main content

SearchMind: A Python Client for Snapzion Search

PyPI Version License

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.Session for efficient connection pooling.
  • Proper error handling with custom SearchMindError exceptions.
  • 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.

Metadata

Release files for searchmind 0.1.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 searchmind 0.1.4
File Size Uploaded
searchmind-0.1.4.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for searchmind 0.1.4
File Interpreter ABI Platform
searchmind-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 8.6 kB

Release files / searchmind-0.1.4.tar.gz

Download URL searchmind-0.1.4.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ecc009507cb8fcb0acf13b62eb4c6c01495eacb13b8196a24d42b3aac5c52292
BLAKE2b-256 checksum
How to use checksums
09d8e2db65ec8dd0d50b07d531ee26cef24aafa573bf6a638f2bcb382850f3fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / searchmind-0.1.4-py3-none-any.whl

Download URL searchmind-0.1.4-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
341aa34770bf739b1078d6a243fa3ce6d073ff778e3216254f482caf4a1d17b6
BLAKE2b-256 checksum
How to use checksums
c2133f73699ed097f32f329bbb0cf6c382227ef295e65ef7ba8fd1459a8132bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.1.4 This release

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