Skip to content

feat(llm, ui): Add native keyless Local LLM model support (Ollama, vLLM, LM Studio, LocalAI) and Office UI Settings - #30

Open
AhmadHassan-BTed wants to merge 8 commits into
HKUDS:mainfrom
AhmadHassan-BTed:main
Open

feat(llm, ui): Add native keyless Local LLM model support (Ollama, vLLM, LM Studio, LocalAI) and Office UI Settings#30
AhmadHassan-BTed wants to merge 8 commits into
HKUDS:mainfrom
AhmadHassan-BTed:main

Conversation

@AhmadHassan-BTed

Copy link
Copy Markdown

Overview

This PR adds support for using local/self-hosted LLM providers with OpenOPC without requiring a remote API key.

Supported local providers include Ollama, vLLM, LM Studio, LocalAI, Llama.cpp, and TGI. It also adds an LLM settings modal to the Office UI so the provider, model, API base, and API key can be configured directly from the UI.

The existing cloud providers are still supported.

Changes

1. Local LLM provider support

Updated opc/llm/provider.py to handle local/self-hosted providers.

  • has_credentials() now considers supported local providers valid without requiring an API key.

  • Added automatic api_base defaults for local providers when no endpoint is configured:

    • ollama/http://localhost:11434
    • vllm/http://localhost:8000/v1
    • localai/http://localhost:8080/v1
    • lmstudio/http://localhost:1234/v1
  • Added the api_key = "local" fallback for keyless OpenAI-compatible local endpoints. This prevents the underlying client from failing because of a missing API key/header.

  • Updated get_capabilities() to expose local provider information, including is_local and the provider family.

2. Office UI LLM settings

Added LLMModelSettingsModal.tsx and integrated it into App.tsx.

The Office UI now has an LLM settings button in the top navigation header.

The provider selector includes:

  • Ollama (Local)
  • vLLM (Local)
  • LM Studio (Local)
  • LocalAI / Llama.cpp (Local)
  • OpenAI (Cloud)
  • Anthropic Claude (Cloud)
  • OpenRouter (Cloud)
  • Custom Self-Hosted / Proxy

The settings UI also handles local and cloud providers differently:

  • Local provider endpoints are pre-filled with their default api_base.

  • API keys are optional for local providers.

  • API keys remain required for providers that need them.

  • A local-mode indicator is shown when a keyless local provider is selected.

  • Added quick-select model options for commonly used local models, including:

    • ollama/llama3.3
    • vllm/meta-llama-3.1-8b-instruct
    • lmstudio/deepseek-r1-distill-qwen-14b

3. LLM configuration schema

Updated opc/core/config.py and extended LLMConfig with:

provider: str = ""
is_local: bool = False

This allows the configuration to keep track of the selected provider and whether it is running in local mode.

4. Tests

Added:

tests/test_local_llm_provider.py

The new tests cover the local provider handling and keyless configuration behavior.

Also verified the existing LLM and CLI-related tests.

5. Documentation

Added:

docs/LOCAL_MODELS.md

and updated:

README.md
README.zh-CN.md

to document the local model setup and supported providers.

Verification

Ran the backend test suite with:

pytest tests/test_local_llm_provider.py tests/test_llm_provider_context_window.py tests/test_cli_app.py

Result:

115/115 tests passed

Ran the TypeScript check in the Office UI frontend:

tsc --noEmit

Result:

0 errors

Also rebuilt the Office UI production bundle:

npm run build

The Vite production build completed successfully and updated:

opc/plugins/office_ui/frontend_dist/

Upstream sync

Before pushing the final changes, I fetched and merged the latest upstream/main changes.

The merge introduced a conflict in the frontend bundle, which was resolved and rebuilt.

The merged changes were committed and pushed to origin/main.

I also removed the openopc-shadow-adapter directory reference from the core git index and pushed that fix.

The branch is now up to date with upstream/main and has no remaining merge conflicts.

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.

1 participant