Ask Document Tool#

The Ask Document Tool enables interactive chat with document content using large language models.

Description#

This tool creates a conversational interface to various document types (PDF, TXT, LaTeX, and URLs), allowing users to ask questions about the content and receive natural language responses. It leverages large language models to interpret document content while maintaining conversation context.

Supported Document Types#

  • Text files (.txt, .md, etc.)

  • Source code files (.py, .js, .c, etc.)

  • LaTeX documents (.tex)

  • PDF documents (requires PyPDF2)

  • Web URLs (requires requests and beautifulsoup4)

Usage#

ml_research_tools ask-document [options] document_path
Usage: ml_research_tools ask-document [-h] [-q QUESTION]
                                      [--max-context MAX_CONTEXT] [--no-cache]
                                      document_path

Interactive chat with document content using LLMs

Positional Arguments:
  document_path         Path to the document file or URL to chat with

Options:
  -h, --help            show this help message and exit
  -q, --question QUESTION
                        Initial question to ask (optional)
  --max-context MAX_CONTEXT
                        Maximum number of messages to keep in context
                        (default: 20)
  --no-cache            Disable Redis caching for URL content (local files are
                        not cached by default)

Examples#

Interactive chat with a PDF document:

ml_research_tools ask-document paper.pdf

Ask a specific question about a LaTeX file:

ml_research_tools ask-document thesis.tex --query "What is the main contribution in this paper?"

Chat with content from a website:

ml_research_tools ask-document https://example.com/article

Requirements#

For full functionality, the following optional dependencies are recommended:

  • PyPDF2 - For PDF document support

  • requests and beautifulsoup4 - For web URL support

Install these dependencies with:

pip install PyPDF2 requests beautifulsoup4