Skip to content

fix: restore LocalLLM for OpenAI-compatible local servers (fixes #1888)#1889

Open
octo-patch wants to merge 1 commit into
sinaptik-ai:mainfrom
octo-patch:fix/issue-1888-restore-local-llm
Open

fix: restore LocalLLM for OpenAI-compatible local servers (fixes #1888)#1889
octo-patch wants to merge 1 commit into
sinaptik-ai:mainfrom
octo-patch:fix/issue-1888-restore-local-llm

Conversation

@octo-patch

Copy link
Copy Markdown

Fixes #1888

Problem

pandasai.llm.local_llm.LocalLLM was removed when local LLMs were refactored into a separate extension in a prior commit. The extension was never published as a standalone package, which left users with a ModuleNotFoundError when importing LocalLLM — either by following the existing documentation or upgrading from v2.

Solution

Restores LocalLLM directly in pandasai/llm/local_llm.py so that Ollama and LM Studio users can import it without installing any additional package:

from pandasai.llm.local_llm import LocalLLM

# Ollama
ollama_llm = LocalLLM(api_base="http://localhost:11434/v1", model="codellama")

# LM Studio
lm_studio_llm = LocalLLM(api_base="http://localhost:1234/v1")

The implementation is updated to match the v3 LLM interface (AgentState context, BasePrompt, prepend_system_prompt).

Testing

  • Added tests/unit_tests/llms/test_local_llm.py with 5 unit tests covering: type property, default/custom API key, call return value, and extra parameter forwarding.
  • All 5 tests pass.

…ptik-ai#1888)

`pandasai.llm.local_llm.LocalLLM` was removed when local LLMs were
refactored into a separate extension, but the extension was never
published, leaving users with a ModuleNotFoundError when following the
existing docs or upgrading from v2.

Restores LocalLLM directly in pandasai/llm/ so that Ollama and LM
Studio users can import it without installing an extra package.
The implementation is updated to match the v3 LLM interface
(AgentState context, BasePrompt, prepend_system_prompt).

Co-Authored-By: Octopus <liyuan851277048@icloud.com>
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.

Issue on Ollama Models

1 participant