From 31e1ec7505b42502d1c03a1788ac68364cc462cd Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Wed, 18 Dec 2024 13:29:53 +0000 Subject: [PATCH] CLI: add --llm-client-header --- src/markitdown/__main__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/markitdown/__main__.py b/src/markitdown/__main__.py index c4b1743..32ba829 100644 --- a/src/markitdown/__main__.py +++ b/src/markitdown/__main__.py @@ -26,12 +26,23 @@ def main(): ).complete = shtab.FILE parser.add_argument("--llm-model", help="e.g. gpt-4o") parser.add_argument("--llm-client-url", help="base URL for OpenAI LLM client") + parser.add_argument( + "-H", + "--llm-client-header", + nargs="*", + default=[], + help="may be specified multiple times", + ) shtab.add_argument_to(parser) args = parser.parse_args() if args.llm_model: from openai import OpenAI - llm_client = OpenAI(base_url=args.llm_client_url) + headers = {} + for header in args.llm_client_header: + key, value = header.split(":", 1) + headers[key] = value.lstrip() + llm_client = OpenAI(base_url=args.llm_client_url, default_headers=headers) else: llm_client = None markitdown = MarkItDown(llm_client=llm_client, llm_model=args.llm_model)