Skip to content

mkantwala/CoNavic-CLI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CoNavic

An autonomous search assistant built for the command-line interface (CLI), designed to provide intelligent, up-to-date answers to user queries by leveraging web search and content extraction tools.

Features

  • Intelligent Agent: Uses LangChain agents with custom tools for web search and content fetching.
  • Rich CLI Interface: Beautiful terminal UI with spinners, panels, and Markdown rendering using the Rich library.
  • Real-time Feedback: Live updates during search and reading phases.
  • Markdown Support: Answers rendered in Markdown format with proper citations.
  • Source Tracking: Displays sources used for answers in an unordered list.
  • Extensible Tools: Modular tool system for web operations.

Architecture

CoNavic is built using a modular architecture with the following key components:

Core Components

  • agent.py: Defines the Agent class that orchestrates the conversation using LangChain's agent framework.
  • cli.py: The main entry point providing the CLI interface with Rich-based UI elements.
  • llm.py: Handles LLM interactions, supporting multiple providers (Cerebras, OpenAI).
  • prompts.py: Contains system prompts and instructions for the agent and content extraction.
  • utilis/tools.py: Implements custom tools for web search (web_search) and content fetching (web_fetch).

Data Flow

  1. User inputs a query via CLI.
  2. The agent processes the query, calling tools iteratively to gather information.
  3. Tools perform web searches or fetch content from URLs.
  4. Agent synthesizes information and generates a Markdown-formatted answer.
  5. CLI renders the answer with sources.

Tools

  • web_search: Uses DuckDuckGo search API to find relevant web results.
  • web_fetch: Extracts content from specified URLs using LLM-based summarization.

Installation

Prerequisites

  • Python 3.11 or higher
  • uv package manager (recommended) or pip

Setup

  1. Clone the repository:

    git clone https://github.com/mkantwala/CoNavic-CLI.git
    cd conavic
  2. Install dependencies:

    uv sync

    or

    pip install -e .
  3. Activate the virtual environment:

    uv run python

    or

    source .venv/bin/activate  # On Unix
    .venv\Scripts\activate     # On Windows

Configuration

Create a .env file in the project root with the following environment variables:

CEREBAS_API_KEY=your_cerebras_api_key
CEREBAS_BASE_URL=https://api.cerebras.ai/v1
OPENAI_API_KEY=your_openai_api_key
OPENAI_API_BASE=https://api.openai.com/v1
  • CEREBAS_API_KEY and CEREBAS_BASE_URL: For the primary Reasonong LLM (Cerebras).
  • OPENAI_API_KEY and OPENAI_API_BASE: For fallback or alternative LLM usage.

Usage

Run the CLI application:

python -m conavic.cli

Or if using uv:

uv run python -m conavic.cli

Example Interaction

Welcome to CoNavic
 ██████╗ ██████╗ ███╗   ██╗ █████╗ ██╗   ██╗██╗ ██████╗
██╔════╝██╔═══██╗████╗  ██║██╔══██╗██║   ██║██║██╔════╝
██║     ██║   ██║██╔██╗ ██║███████║██║   ██║██║██║     
██║     ██║   ██║██║╚██╗██║██╔══██║╚██╗ ██╔╝██║██║     
╚██████╗╚██████╔╝██║ ╚████║██║  ██║ ╚████╔╝ ██║╚██████╗
 ╚═════╝ ╚═════╝ ╚═╝  ╚═══╝╚═╝  ╚═╝  ╚═══╝  ╚═╝ ╚═════╝

Your Autonomous search Assistant in your CLI

Ask Anything to search (or 'quit' to exit): current US president

🔍 Searching: current US president

⠸ Reading: En.wikipedia.org
⠸ Reading: Whitehouse.gov

ANSWER:
Donald J. Trump is the current President of the United States[Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States).

Sources:
- https://en.wikipedia.org/wiki/President_of_the_United_States
- https://www.whitehouse.gov/

Project Structure

conavic/
├── __init__.py
├── agent.py          # Agent orchestration
├── cli.py            # CLI interface
├── llm.py            # LLM utilities
├── prompts.py        # System prompts
└── utilis/
    ├── __init__.py
    └── tools.py      # Custom tools

Dependencies

Key dependencies include:

  • langchain: For agent and tool orchestration
  • langchain-openai: OpenAI LLM integration
  • rich: Terminal UI and formatting
  • ddgs: DuckDuckGo search API
  • markitdown: Document processing
  • python-dotenv: Environment variable management

Adding New Tools

  1. Define the tool function in utilis/tools.py using the @tool decorator.
  2. Import and add it to the agent's tools list in agent.py.

Extending the LLM

Modify llm.py to support additional providers or configurations.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

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

About

An autonomous search assistant built for the CLI. A perplexity in CLI

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages