Skip to main content

A powerful Python tool for performing technical searches using the Perplexity API

Project description

🔍 Perplexity Search

Python 3.x License: MIT PRs Welcome GitHub Issues GitHub Stars

A powerful Python tool for performing technical searches using the Perplexity API, optimized for retrieving precise facts, code examples, and numerical data.

Perplexity Search Demo

📋 Table of Contents

OverviewFeaturesInstallationUsageConfigurationRequirementsError HandlingContributingFAQLicense

🌟 Overview

Perplexity Search is a command-line tool and Python library that leverages the power of Perplexity AI to provide accurate, technical search results. It's designed for developers, researchers, and technical users who need quick access to precise information, code examples, and technical documentation.

✨ Features

  • Perform searches using different LLaMA models (small, large, huge)
  • Configurable API key support via environment variable or direct input
  • Customizable search queries with temperature and other parameters
  • Command-line interface for easy usage
  • Focused on retrieving technical information with code examples
  • Returns responses formatted in markdown
  • Optimized for factual and numerical data

Installation

git clone https://github.com/tom-doerr/perplexity_search.git
cd perplexity_search
pip install requests

Usage

As a Python Module

from perplexity_search import perform_search

# Using environment variable for API key
result = perform_search("What is Python's time complexity for list operations?")

# Or passing API key directly
result = perform_search("What are the differences between Python 3.11 and 3.12?", api_key="your-api-key")

# Specify a different model
result = perform_search("Show me example code for Python async/await", model="llama-3.1-sonar-huge-128k-online")

Command Line Interface

# Basic search
python perplexity_search.py "What is Python's time complexity for list operations?"

# Specify model
python perplexity_search.py --model huge "What are the differences between Python 3.11 and 3.12?"

# Use specific API key
python perplexity_search.py --api-key your-api-key "Show me example code for Python async/await"

Configuration

API Key

Set your Perplexity API key in one of these ways:

  1. Environment variable:
    export PERPLEXITY_API_KEY=your-api-key
    # Or add to your ~/.bashrc or ~/.zshrc for persistence
    echo 'export PERPLEXITY_API_KEY=your-api-key' >> ~/.bashrc
    
  2. Pass directly in code or CLI: --api-key your-api-key

Available Models

The following models can be specified using the --model parameter:

  • llama-3.1-sonar-small-128k-online (Faster, lighter model)
  • llama-3.1-sonar-large-128k-online (Default, balanced model)
  • llama-3.1-sonar-huge-128k-online (Most capable model)

Requirements

  • Python 3.x
  • requests library
  • Perplexity API key (obtain from Perplexity API)

Error Handling

The tool includes error handling for:

  • Missing API keys
  • Invalid API responses
  • Network issues
  • Invalid model selections

Contributing

We welcome contributions! Please see our CONTRIBUTING.md for more details on how to contribute to this project.

FAQ

Q: How do I get an API key for Perplexity?

A: You can obtain an API key by signing up on the Perplexity API website.

Q: What models are available for search?

A: The available models are small, large, and huge.

License

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

plexsearch-0.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

plexsearch-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file plexsearch-0.1.0.tar.gz.

File metadata

  • Download URL: plexsearch-0.1.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.10 Linux/5.15.0-126-generic

File hashes

Hashes for plexsearch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 aceb5bf48210cd2fd5f1e066e7be792be7dbc1bb030b07bf811e5e96e75f1a9b
MD5 ba5c1234c72cbe7ed5b5d0a662514bb1
BLAKE2b-256 6bea704d6fec3e70b95ed3ac0e508613322d4d0ff6827aa830a4affab6354ca6

See more details on using hashes here.

File details

Details for the file plexsearch-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: plexsearch-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.10 Linux/5.15.0-126-generic

File hashes

Hashes for plexsearch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d08fb2532637c0c05e0c98f9a590e3e084d127d4bf225ef62f9b1eee0665e7fd
MD5 a2a34faa1e90590a636e6f898e0b92dd
BLAKE2b-256 708fd50e5fc1a9d509c21cfadcd82c157ea8135de4f93b2ab2ac37ceb42c8ee7

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