Skip to content

A Genkit-powered CLI (Node.js/TypeScript) that leverages Tavily Search to provide real-time, factual AI responses similar to Perplexity. Part of Big School's Master en Desarrollo con IA.

Notifications You must be signed in to change notification settings

candytale55/09-master-ia-cli-genkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyPerplexity CLI

An AI-powered interactive command-line interface that answers questions by combining real-time web search with advanced AI reasoning. Built with Genkit and Tavily APIs.

Learning Project: Developed as part of Big School's Master de desarrollo con IA program.

Features

  • 🔍 Real-time Web Search: Uses Tavily API to search current information from the web
  • 🤖 AI-Powered Responses: Leverages Google's Gemini AI to synthesize search results into comprehensive answers
  • 💬 Interactive CLI: User-friendly command-line interface with spinners and colored output
  • 📚 Source Citations: Automatically includes URLs and sources in responses
  • 💾 Chat History: Maintains conversation history during the session

Prerequisites

Installation

  1. Clone the repository

    git clone <repository-url>
    cd 09-master-ia-cli-genkit
  2. Install dependencies

    npm install
  3. Set up environment variables

    cp .env.example .env

    Then edit .env and add your API keys:

    TAVILY_API_KEY=your_tavily_key_here
    GOOGLE_API_KEY=your_google_api_key_here
    

Usage

Interactive Mode (CLI)

npm start

This launches the interactive CLI where you can ask questions:

💬 Ask a question (or type "exit" to quit): What is the capital of France?

🧁 Thinking...
✅ Answer Received!

Answer:
The capital of France is Paris. Paris is the largest city in France and serves as the 
political, cultural, and economic center of the country...

Sources:
[1] https://example.com/france-capital
[2] https://example.com/paris-info

Development Mode (Genkit UI)

npm run dev

This also runs the interactive CLI and starts the Genkit Developer UI on http://localhost:4000 for development and debugging.

To access the UI:

  1. Click on the http://localhost:4000 link in the terminal, or
  2. Open your browser and navigate to http://localhost:4000

The Genkit UI allows you to:

  • Test flows and prompts interactively
  • View execution traces and AI model interactions
  • Debug tool calls and API responses
  • Monitor performance metrics

Screenshot

MyPerplexity CLI Demo

Interactive CLI in action - Ask questions and get AI-powered answers with web sources

Project Structure

09-master-ia-cli-genkit/
├── index.js              # Main entry point - CLI setup and interaction loop
├── src/
│   ├── agent.js         # Chat agent with search tool configuration
│   └── search.js        # Tavily web search wrapper
├── .env.example         # Environment variables template
└── README.md            # This file

How It Works

  1. User Input: User enters a question in the CLI
  2. Search: The chat agent uses Tavily's searchWeb tool to find current information
  3. AI Processing: Google Gemini AI synthesizes search results with its knowledge
  4. Response: A comprehensive answer is formatted with citations and sources
  5. History: The exchange is stored in the chat session history

Architecture

  • index.js: Manages the CLI interface using Node.js readline module
  • agent.js: Defines the Genkit agent with the search tool and AI prompt
  • search.js: Wraps the Tavily API with proper configuration options

Tech Stack

Technology Purpose
Genkit AI framework for building agentic apps
Google Gemini AI Language model for reasoning
Tavily API Real-time web search
Zod TypeScript-first schema validation
Chalk Terminal string styling
Ora Elegant terminal spinners
dotenv Environment variable management
Readline CLI input/output (Node.js built-in)

References

Framework & AI APIs

Dependencies

  • @tavily/core - Tavily web search client
  • Chalk - Terminal styling
  • Ora - Progress spinners
  • dotenv - Environment variables
  • Zod - Schema validation

Node.js APIs

Learning Source

This project was developed as part of the Master de Desarrollo con IA by Big School, a comprehensive program covering AI development with modern tools and frameworks.

Completion Date: February 9, 2026

Possible Future Enhancements

  • Use native Node.js fetch instead of Tavily package dependency
  • Add conversation persistence (save/load chat history)
  • Implement multi-turn context awareness
  • Add support for different AI models
  • Web dashboard interface alongside CLI

About

A Genkit-powered CLI (Node.js/TypeScript) that leverages Tavily Search to provide real-time, factual AI responses similar to Perplexity. Part of Big School's Master en Desarrollo con IA.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published