Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

my-ai-cli

A production-grade CLI for interacting with OpenAI's API, with optional RAG (Retrieval-Augmented Generation) support for document-grounded answers.

Features

  • Single-question modemyai ask "What is Python?"
  • Interactive chatmyai chat
  • File-aware answersmyai ask --file doc.txt "Summarise this"
  • RAG support — ingest documents and query them semantically
  • Streaming responses — tokens appear as they are generated
  • Retry with backoff — handles rate limits gracefully
  • Model selection--model gpt-4o

Quick Start

# 1. Clone and install
git clone <repo-url>
cd my-ai-cli
python -m venv venv && source venv/bin/activate
pip install -e .

# 2. Set your API key
cp .env.example .env
# Edit .env and add your OPENAI_API_KEY

# 3. Ask a question
myai ask "Explain async/await in Python"

# 4. Start a chat session
myai chat

# 5. Ingest documents and query with RAG
myai ingest report.pdf notes.txt
myai ask --rag "What did the report say about Q3?"

Commands

myai ask

myai ask [OPTIONS] QUESTION

Options:
  -f, --file PATH      Append file contents to the question
  -m, --model TEXT     OpenAI model (default: gpt-4o-mini)
  --no-stream          Disable streaming output
  --rag                Use local RAG vector store
  --rag-dir PATH       Vector store directory (default: ~/.myai/store)
  -v, --verbose        Show retrieved RAG context

myai chat

myai chat [OPTIONS]

Options:
  -m, --model TEXT     OpenAI model
  --rag                Use RAG context for each turn
  --rag-dir PATH       Vector store directory
  -v, --verbose        Show retrieved context

Special commands (inside chat):
  /quit | /exit        End the session
  /clear               Reset conversation history
  /help                Show available commands

myai ingest

myai ingest [OPTIONS] PATHS...

Options:
  --store-dir PATH     Where to save the FAISS index (default: ~/.myai/store)
  --chunk-size INT     Characters per chunk (default: 1000)
  --overlap INT        Overlap between chunks (default: 200)

Supported formats: .txt, .md, .markdown, .pdf

Configuration

Priority: environment variables > ~/.myai/config.yaml > defaults.

Variable Default Description
OPENAI_API_KEY Required
OPENAI_MODEL gpt-4o-mini Chat model
OPENAI_EMBEDDING_MODEL text-embedding-3-small Embedding model
OPENAI_MAX_TOKENS 2048 Max response tokens
OPENAI_TEMPERATURE 0.7 Sampling temperature
LOG_LEVEL INFO Logging verbosity

Example ~/.myai/config.yaml:

model: gpt-4o
temperature: 0.3
max_tokens: 4096

Development

pip install -r requirements-dev.txt
pytest --cov=src tests/
black src/ tests/
ruff check src/ tests/

About

An AI Agent with RAG using OpenAI API Embeddings And FAISS local vector store

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages