Skip to main content

No project description provided

Project description

SynapseAI

SynapseAI is a Python package for semantic search in PDF documents and web pages. It allows users to extract relevant information from PDFs and websites based on natural language queries.

Installation

You can install SynapseAI using pip:

pip install synapseai

Usage

synapseai provides two main functions: process_pdf for analyzing PDF documents and crawl_and_query for searching web pages.

Processing a PDF

To search within a PDF document:

from synapseai import process_pdf

pdf_path = "path/to/your/document.pdf"
query = "What is the main topic of this document?"

results = process_pdf(pdf_path, query)

for chunk, similarity in results:
    print(f"Similarity: {similarity:.4f}")
    print(f"Chunk: {chunk[:200]}...")
    print("-" * 50)

Crawling and Querying a Web Page

To search the content of a web page:

from synapseai import crawl_and_query

url = "https://example.com"
query = "What services does this website offer?"

results = crawl_and_query(url, query)

for chunk, similarity in results:
    print(f"Similarity: {similarity:.4f}")
    print(f"Chunk: {chunk[:200]}...")
    print("-" * 50)

Both functions return a list of tuples, where each tuple contains a relevant text chunk and its similarity score to the query.

Configuration

synapseai can be customized by modifying the config.py file in the package directory. Here are the available configuration options:

Embedding Model

  • Variable: EMBEDDING_MODEL
  • Default: "sentence-transformers/all-MiniLM-L6-v2"
  • Description: The name of the Hugging Face model used for text embeddings.

Text Chunking

  • Variables: CHUNK_SIZE and CHUNK_OVERLAP
  • Defaults: CHUNK_SIZE = 1024, CHUNK_OVERLAP = 80
  • Description: Control how the text is split into chunks for processing.
    • CHUNK_SIZE: Maximum number of characters in each chunk.
    • CHUNK_OVERLAP: Number of characters that overlap between consecutive chunks.

Search Results

  • Variable: TOP_K_RESULTS
  • Default: 5
  • Description: The number of top results to return from the semantic search.

How to Modify Configuration

To change these settings, locate the config.py file in your synapseai installation directory and edit the values. For example:

# config.py

EMBEDDING_MODEL = "sentence-transformers/all-mpnet-base-v2"
CHUNK_SIZE = 2048
CHUNK_OVERLAP = 100
TOP_K_RESULTS = 10

After modifying the config file, restart your Python environment or reload the synapseai package for the changes to take effect.

Viewing Current Configuration

You can view the current configuration settings in your Python script or interactive session:

import synapseai

synapseai.print_config()

This will display the current values of all configuration options.

Examples

Analyzing a Research Paper

from synapseai import process_pdf

pdf_path = "research_paper.pdf"
query = "What are the key findings of this research?"

results = process_pdf(pdf_path, query)

print("Key findings from the research paper:")
for chunk, similarity in results:
    print(f"Relevance: {similarity:.2f}")
    print(chunk)
    print("-" * 50)

Extracting Information from a Company Website

from synapseai import crawl_and_query

url = "https://www.company.com/about"
query = "What is the company's mission statement?"

results = crawl_and_query(url, query)

print("Company mission statement:")
for chunk, similarity in results:
    if similarity > 0.8:  # Only print highly relevant results
        print(chunk)
        break

Troubleshooting

If you encounter any issues:

  • Ensure you have the latest version of synapseai installed.
  • Check that all dependencies are correctly installed.
  • Verify that the PDF file or URL you're trying to access is valid and accessible.
  • If you've modified the configuration, try reverting to default settings.

For persistent issues, please open an issue on our GitHub repository. https://github.com/FastianAbdullah/Synapse-AI

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

synapseai-0.5.5.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

SynapseAI-0.5.5-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file synapseai-0.5.5.tar.gz.

File metadata

  • Download URL: synapseai-0.5.5.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for synapseai-0.5.5.tar.gz
Algorithm Hash digest
SHA256 e015df07b0fd2cd0efe88374f120265c3c1ec747d63fff16a553f8123925ab2b
MD5 26da825129aeab2b2e9faedbd3dd919a
BLAKE2b-256 4a08e943bace365deb93b202f6d1b27fade69252a5e2a1fc2f798f828561a911

See more details on using hashes here.

File details

Details for the file SynapseAI-0.5.5-py3-none-any.whl.

File metadata

  • Download URL: SynapseAI-0.5.5-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for SynapseAI-0.5.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5b9cbb20fa9ad90cecaf3c39f7acd64c525b487c8db48c872070d5164105f780
MD5 4761e02e98acf8acc7894a344068cd78
BLAKE2b-256 f22888df2e5114924ea4777ca0467ae46bfab0a3af3fd4d1d4f37d1b332e615a

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