Skip to content

Narendra-Rajput003/perplexity_2.0

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Perplexity 2.0 - An AI Chat Interface with Web Search

Project Banner

Next.js React TypeScript FastAPI Python LangChain

Live Demo

Introduction

Perplexity 2.0 is a sophisticated AI-powered chat application that seamlessly integrates real-time web search capabilities into its conversational flow. This allows the AI to provide answers that are not only contextually relevant but also enriched with the latest information from the internet. It's designed to be a powerful tool for anyone who needs quick, accurate, and well-supported answers.

Features

  • Real-time AI Conversations: Utilizes large language models to generate human-like responses.
  • Integrated Web Search: Fetches and incorporates up-to-date information from the web into its answers.
  • Conversation Memory: Remembers previous parts of the conversation to provide context-aware responses.
  • Search Transparency: Displays the search queries being used and the sources of information, allowing users to verify the answers.
  • Responsive Design: A clean and intuitive user interface that works on both desktop and mobile devices.

Architecture

The project is a monorepo with a client-server architecture:

  • Client: A Next.js/React application responsible for the user interface.
  • Server: A FastAPI server that uses LangGraph to create a stateful, multi-actor agent.

Prerequisites

  • Node.js (v18 or later)
  • Python (v3.11 or later)
  • An API key from Tavily AI for the search functionality.
  • An API key from a supported LLM provider (e.g., OpenAI, Anthropic, Google).

Getting Started

Installation

  1. Clone the repository:

    git clone https://github.com/Narendra-Rajput003/perplexity_2.0
    cd perplexity-2.0
  2. Set up the server:

    • Navigate to the server directory: cd server
    • Create a virtual environment: python -m venv venv
    • Activate the virtual environment:
      • On Windows: venv\Scripts\activate
      • On macOS/Linux: source venv/bin/activate
    • Install the Python dependencies: pip install -r requirements.txt
    • Create a .env file and add your API keys:
      TAVILY_API_KEY="your_tavily_api_key"
      GEMINI_API_KEY="your_gemini_api_key"
      
  3. Set up the client:

    • Navigate to the client directory: cd ../client
    • Install the Node.js dependencies: npm install

Running the Application

  1. Start the server:

    • Make sure you are in the server directory with the virtual environment activated.
    • Run the FastAPI server: uvicorn main:app --reload
    • The server will be running at http://localhost:8000.
  2. Start the client:

    • Make sure you are in the client directory.
    • Run the Next.js development server: npm run dev
    • The client will be running at http://localhost:3000.

How It Works

The application flow is as follows:

  1. The user sends a message from the client.
  2. The client sends the message to the FastAPI server.
  3. The LangGraph agent on the server receives the message and decides whether to use a tool (in this case, web search) or generate a response directly.
  4. If a web search is needed, the agent uses the Tavily AI API to perform the search.
  5. The search results are used to enrich the context for the LLM.
  6. The LLM generates a response, which is streamed back to the client.
  7. The client displays the response to the user, including any search information.

Deployment

Backend on Render

  1. Push your code to a GitHub repository.
  2. Create a new Web Service on Render and connect it to your GitHub repository.
  3. Set the Root Directory to server.
  4. Set the Build Command to pip install -r requirements.txt.
  5. Set the Start Command to uvicorn main:app --host 0.0.0.0 --port $PORT.
  6. Add your environment variables from the .env file.
  7. Deploy the service.

Frontend on Vercel

  1. Push your code to a GitHub repository.
  2. Create a new Project on Vercel and import your GitHub repository.
  3. Set the Root Directory to client.
  4. Vercel should automatically detect that it's a Next.js project and configure the build settings.
  5. Add an environment variable NEXT_PUBLIC_API_URL and set it to the URL of your Render backend.
  6. Deploy the project.

Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors