Tavily Comparative Review Utility

This project provides a simple Node.js utility to fetch a comparative review of three entities using the Tavily API.

Features

  • Compare three entities: Generate a concise comparative review for any three items.
  • Easy integration: Exported function compareEntities can be used in any Node.js project.
  • Environmentbased configuration: API key is loaded from a .env file.
  • Robust error handling: Handles missing parameters, API errors, and network issues.

Prerequisites

Setup

  1. Clone the repository

    git clone https://git.brojs.ru/kuzakhmetovartur/povtornyy-ekzamen-2-sravnitelnyy-obzor-3.git
    cd povtornyy-ekzamen-2-sravnitelnyy-obzor-3
    
  2. Install dependencies

    npm install
    
  3. Configure environment variables

    Copy the example file and set your API key:

    cp .env.example .env
    # Edit .env and replace YOUR_TAVILY_API_KEY_HERE with your actual key
    

Usage

const { compareEntities } = require('./src/index');

(async () => {
  try {
    const result = await compareEntities('Apple', 'Samsung', 'Google');
    console.log(JSON.stringify(result, null, 2));
  } catch (err) {
    console.error('Error:', err.message);
  }
})();

Run the script:

node src/index.js

Testing

The project uses Jest for unit tests.

npm test

Project Structure

├── src
│   └── index.js          # Main utility
├── tests
│   └── compare.test.js   # Unit tests
├── .env.example          # Environment variable template
├── .gitignore
├── package.json
└── README.md

License

MIT © Your Name


Feel free to open issues or pull requests if you encounter any problems or have suggestions for improvement.

S
Description
BroJS: Повторный экзамен #2: Сравнительный обзор 3 сущностей (Tavily)
Readme 98 KiB
Languages
JavaScript 50.2%
Python 46.2%
CSS 2.8%
HTML 0.8%