61 lines
1.4 KiB
Markdown
61 lines
1.4 KiB
Markdown
# Tavily Compare
|
||
|
||
This Node.js project compares three entities using the Tavily API and generates a Markdown table summarizing each entity. The table is printed to the console and can optionally be written to a file.
|
||
|
||
## Prerequisites
|
||
|
||
- Node.js v18 or newer (for native ES modules support)
|
||
- A Tavily API key
|
||
|
||
## Setup
|
||
|
||
1. **Clone the repository** (or copy the files into a new directory):
|
||
|
||
```bash
|
||
git clone https://github.com/your-username/tavily-compare.git
|
||
cd tavily-compare
|
||
```
|
||
|
||
2. **Install dependencies**:
|
||
|
||
```bash
|
||
npm install
|
||
```
|
||
|
||
3. **Create a `.env` file** in the project root and add your Tavily API key:
|
||
|
||
```env
|
||
TAVILY_API_KEY=your_api_key_here
|
||
```
|
||
|
||
## Usage
|
||
|
||
Run the script with three entity names:
|
||
|
||
```bash
|
||
node src/index.js "Entity One" "Entity Two" "Entity Three"
|
||
```
|
||
|
||
The script will output a Markdown table to the console.
|
||
|
||
### Writing to a file
|
||
|
||
To also write the table to a file, use the `--output` (or `-o`) flag:
|
||
|
||
```bash
|
||
node src/index.js "Entity One" "Entity Two" "Entity Three" --output comparison.md
|
||
```
|
||
|
||
The file `comparison.md` will contain the same table.
|
||
|
||
## Project Structure
|
||
|
||
- `src/index.js` – Entry point; orchestrates argument parsing, API calls, and output.
|
||
- `src/compare.js` – Handles API requests to Tavily and returns summaries.
|
||
- `src/markdown.js` – Builds the Markdown table string.
|
||
- `package.json` – Project metadata and dependencies.
|
||
- `README.md` – Documentation.
|
||
|
||
## License
|
||
|
||
MIT License |