markitdown icon indicating copy to clipboard operation
markitdown copied to clipboard

CLI: add LLM support

Open casperdcl opened this issue 1 year ago • 1 comments

  • [ ] please merge #84 first
  • [x] add --llm-model
  • [x] add --llm-client-url
  • [x] add --llm-client-header

Tested successfully using https://ollama.com/library/llava-phi3:

OPENAI_API_KEY=ollama \
markitdown tests/test_files/test.jpg --llm-client-url=http://localhost:11434/v1 --llm-model=llava-phi3

Note that:

  • --llm-client-header is needed for e.g. authori[sz]ation headers in-production
  • I didn't add --llm-client=OpenAI because there are no other options yet
  • I hope MS will merge this despite it being a free alternative to its paid LLMs ;)

casperdcl avatar Dec 20 '24 16:12 casperdcl

New:

usage: markitdown [-h] [-v] [-o OUTFILENAME] [-d] [-e ENDPOINT] [-p] [--list-plugins]
                  [--llm-model MODEL] [--llm-client-url URL] [-H [HEADER ...]]
                  [FILENAME]

options:
  -h, --help            show this help message and exit
  -v, --version         show the version number and exit
  -o OUTFILENAME, --output OUTFILENAME
                        if unspecified, defaults to stdout
  -d, --use-docintel    use online Document Intelligence to extract text (requires a valid
                        `--endpoint`)
  -e ENDPOINT, --endpoint ENDPOINT
                        required for `--use-docintel`
  -p, --use-plugins     use 3rd-party plugins to convert files (see `--list-plugins`)
  --list-plugins        list installed 3rd-party plugins (loaded with `--use-plugin`)
  --llm-model MODEL     e.g. gpt-4o
  --llm-client-url URL  base URL for OpenAI LLM client
  -H [HEADER ...], --llm-client-header [HEADER ...]
                        may be specified multiple times

Old:

usage: markitdown [-h] [-v] [-o OUTFILENAME] [-d] [-e ENDPOINT] [-p] [--list-plugins] [FILENAME]

options:
  -h, --help            show this help message and exit
  -v, --version         show the version number and exit
  -o OUTFILENAME, --output OUTFILENAME
                        if unspecified, defaults to stdout
  -d, --use-docintel    use online Document Intelligence to extract text (requires a valid
                        `--endpoint`)
  -e ENDPOINT, --endpoint ENDPOINT
                        required for `--use-docintel`
  -p, --use-plugins     use 3rd-party plugins to convert files (see `--list-plugins`)
  --list-plugins        list installed 3rd-party plugins (loaded with `--use-plugin`)

casperdcl avatar Mar 06 '25 14:03 casperdcl