Skip to content

Neolithic/voting-bot

Repository files navigation

Perplexity API Query Script

This Python script demonstrates how to interact with the Perplexity AI API to ask questions and store responses in a Supabase database.

Setup

  1. Install the required dependencies:
pip install -r requirements.txt
  1. Create a .env file in the root directory and add your API keys:
PERPLEXITY_API_KEY=your_perplexity_api_key_here
SUPABASE_URL=your_supabase_project_url
SUPABASE_KEY=your_supabase_anon_key

You can get your:

Database Schema

The script expects a table named AI_VOTES in your Supabase database with the following columns:

  • match_id (integer)
  • winner_selection (text)
  • margin_selection (text)
  • reasoning (text)

Usage

Run the script using Python:

python perplexity_query.py

The script will:

  1. Ask Perplexity AI about match predictions
  2. Process the response into structured data
  3. Store the predictions in your Supabase database

Customization

You can modify the following in the script:

  • Change the model by updating the model parameter in the payload
  • Modify the question in the main() function
  • Add additional parameters to the API call as needed

Error Handling

The script includes basic error handling for:

  • Missing API keys
  • Network request errors
  • Invalid responses
  • Database insertion errors

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages