fix: add --base_url CLI option for custom LLM endpoints#229
Open
octo-patch wants to merge 1 commit intoVectifyAI:mainfrom
Open
fix: add --base_url CLI option for custom LLM endpoints#229octo-patch wants to merge 1 commit intoVectifyAI:mainfrom
octo-patch wants to merge 1 commit intoVectifyAI:mainfrom
Conversation
…yAI#224) Expose OPENAI_API_BASE through a --base_url CLI argument so users can point PageIndex at Ollama, vLLM, LM Studio, or any other OpenAI-compatible local server without manually setting environment variables. - run_pageindex.py: add --base_url argument that sets OPENAI_API_BASE - utils.py: read OPENAI_API_BASE in llm_completion / llm_acompletion and pass as api_base to litellm, enabling custom endpoints for all LLM calls Usage: python run_pageindex.py --pdf_path doc.pdf \ --model ollama/llama3 \ --base_url http://localhost:11434
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #224
Problem
Users running local LLM servers (Ollama, vLLM, LM Studio, etc.) have no way to specify a custom API base URL through the CLI. The
OPENAI_API_BASEenvironment variable works when set manually, but there is no--base_urlargument, making the workflow unnecessarily awkward.Solution
run_pageindex.py: Added--base_urlargument that setsos.environ["OPENAI_API_BASE"]before any LLM calls are made.pageindex/utils.py: Updatedllm_completionandllm_acompletionto readOPENAI_API_BASEfrom the environment and forward it to litellm asapi_base, so all LLM calls in the pipeline respect the custom endpoint.The change is fully backward-compatible: if
--base_urlis not provided andOPENAI_API_BASEis not set, behaviour is identical to before.Usage
Testing
Verified that the argument is parsed correctly and
OPENAI_API_BASEis set before any LLM call. Theapi_basekwarg is only injected into litellm when the env var is present, so there is no overhead for standard OpenAI usage.