Skip to content

feat(api): add support for custom API base URL in configuration#152

Open
mohammadmaso wants to merge 1 commit into
VectifyAI:mainfrom
mohammadmaso:main
Open

feat(api): add support for custom API base URL in configuration#152
mohammadmaso wants to merge 1 commit into
VectifyAI:mainfrom
mohammadmaso:main

Conversation

@mohammadmaso

Copy link
Copy Markdown
  • Introduced resolve_api_base function to extract the api_base key from the configuration, ensuring it is a valid URL string.
  • Updated _setup_llm_key to utilize the custom API base URL, falling back to the LLM_API_BASE environment variable if not set in the config.
  • Enhanced LLM call functions to include the API base in request parameters.
  • Modified build_query_agent to pass the API base as part of extra arguments.

This change allows users to configure a custom API endpoint for LLM requests, improving flexibility and integration with different environments.

- Introduced `resolve_api_base` function to extract the `api_base` key from the configuration, ensuring it is a valid URL string.
- Updated `_setup_llm_key` to utilize the custom API base URL, falling back to the `LLM_API_BASE` environment variable if not set in the config.
- Enhanced LLM call functions to include the API base in request parameters.
- Modified `build_query_agent` to pass the API base as part of extra arguments.

This change allows users to configure a custom API endpoint for LLM requests, improving flexibility and integration with different environments.
@KylinMountain

Copy link
Copy Markdown
Collaborator

Thanks for the PR!

I think a custom api_base may already be configurable without code changes. OpenKB exposes LiteLLM's module settings verbatim through the litellm: passthrough block in .openkb/config.yaml (added in #137). LiteLLM has a module-level api_base global that litellm.completion() falls back to, so you can set it directly:

# .openkb/config.yaml
litellm:
  api_base: https://your-endpoint/v1

That routes both the compile path (_llm_calllitellm.completion) and the PageIndex calls through your custom endpoint. LiteLLM also picks up provider-native env vars automatically (OPENAI_API_BASE, AZURE_API_BASE, OLLAMA_API_BASE, …).

Could you give that a try and see whether it already covers your use case? If it does, we may not need the extra plumbing; and if there's a path it doesn't reach, that'd be useful to know so we can scope the change to just that gap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants