Skip to content

LLM cannot be configured using langchain.Databricks.v1  #493

@jstammers

Description

@jstammers

It is not possible to configure spacy_llm to instantiate an LLM agent using langchain.Databricks.

For example, here is my initial config

[components.llm.model]
@llm_models = "langchain.Databricks.v1"
name = "databricks-meta-llama-3-70b-instruct"
query = {"@llm_queries": "spacy.CallLangChain.v1"}

This gives me the following error indicating that the endpoint_name must be set in the config

File ~/****/.venv/lib/python3.11/site-packages/pydantic/main.py:214, in BaseModel.__init__(self, **data)
    212 # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    213 __tracebackhide__ = True
--> 214 validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
    215 if self is not validated_self:
    216     warnings.warn(
    217         'A custom validator is returning a value other than `self`.\n'
    218         "Returning anything other than `self` from a top level model validator isn't supported when validating via `__init__`.\n"
    219         'See the `model_validator` docs (https://docs.pydantic.dev/latest/concepts/validators/#model-validators) for more details.',
    220         stacklevel=2,
    221     )

ValidationError: 1 validation error for Databricks
  Value error, Neither endpoint_name nor cluster_id was set. And the cluster_id cannot be automatically determined. Received error: Cannot access dbruntime, not running inside a Databricks notebook. [type=value_error, input_value={'model': 'databricks-meta-llama-3-70b-instruct'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.10/v/value_error

Modifying the config to include an endpoint name then raises a different validation error because lanchain_community.llm.databricks.Databricks does not accept a name argument

[components.llm.model]
@llm_models = "langchain.Databricks.v1"
name = "databricks-meta-llama-3-70b-instruct"
query = {"@llm_queries": "spacy.CallLangChain.v1"}
config = {"endpoint_name": "databricks-meta-llama-3-70b-instruct"}

raises

ValidationError: 1 validation error for Databricks
model
  Extra inputs are not permitted [type=extra_forbidden, input_value='databricks-meta-llama-3-70b-instruct', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/extra_forbidden

This API has been deprecated in favour of langchain_databricks.ChatDatabricks, so is there a recommended way to interface with LLMs using spacy_llm and the Databricks platform?

For reference, these are the packages I am using:

spacy-llm==0.7.3
langchain==0.3.14
langchain-community==0.3.14
langchain-databricks==0.1.2
databricks-connect==15.4.3
databricks-langchain==0.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions