Model
What it is
- Lightweight data holders for LangChain chat models and related metadata.
- Provides a base
Modelclass and aChatModelspecialization withcontext_windowand amodel_type.
Public API
Enums
ModelTypeCHAT: Identifies chat-capable models.
Classes
-
Model- Purpose: Store a
langchain_coreBaseChatModelinstance plus identifying and descriptive metadata. - Constructor:
Model(model_id: str, provider: str, model: BaseChatModel, ..., default_parameters: Optional[dict] = None)
- Key attributes (all set directly on the instance):
- Required:
model_id,provider,model - Optional metadata:
name,owner,description,image,created_at,canonical_slug,hugging_face_id - Optional structured info:
pricing,architecture,top_provider,per_request_limits,supported_parameters,default_parameters
- Required:
- Purpose: Store a
-
ChatModel(Model)- Purpose: A
Modelwith chat-specific fields. - Class attributes:
model_type: ModelType = ModelType.CHAT
- Additional instance attributes:
context_window: Optional[int]- maximum context length in tokens
- Constructor:
ChatModel(model_id: str, provider: str, model: BaseChatModel, context_window: Optional[int] = None, ..., default_parameters: Optional[dict] = None)
- Purpose: A
Configuration/Dependencies
- Depends on:
langchain_core.language_models.chat_models.BaseChatModel(the wrapped chat model type)pydantic.Fieldandtyping.Annotated(used for type annotations/metadata only)- Standard library:
datetime,enum,typing.Optional
Usage
from datetime import datetime
from naas_abi_core.models.Model import ChatModel
# `model` must be an actual LangChain BaseChatModel instance in real usage.
# Here we use a placeholder to show construction only.
model = object() # replace with a real BaseChatModel
chat_model = ChatModel(
model_id="gpt-4.1",
provider="openai",
model=model, # should be a BaseChatModel
context_window=128000,
name="GPT-4.1",
created_at=datetime.utcnow(),
)
print(chat_model.model_id)
print(chat_model.model_type)
print(chat_model.context_window)
Caveats
- These classes are not Pydantic
BaseModels; theField(...)metadata is not automatically enforced/validated at runtime. modelis annotated asBaseChatModel, but there is no runtime type checking in__init__.