Skip to content

Commit

Permalink
CLI: add --llm-client-header
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Dec 20, 2024
1 parent 452f8e7 commit 31e1ec7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/markitdown/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 31e1ec7

Please sign in to comment.