mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
feat(model-profiles): distribute data across packages (#34024)
This commit is contained in:
@@ -18,7 +18,11 @@ from langchain_core.callbacks import (
|
||||
AsyncCallbackManagerForLLMRun,
|
||||
CallbackManagerForLLMRun,
|
||||
)
|
||||
from langchain_core.language_models import LanguageModelInput
|
||||
from langchain_core.language_models import (
|
||||
LanguageModelInput,
|
||||
ModelProfile,
|
||||
ModelProfileRegistry,
|
||||
)
|
||||
from langchain_core.language_models.chat_models import (
|
||||
BaseChatModel,
|
||||
LangSmithParams,
|
||||
@@ -79,10 +83,19 @@ from pydantic import (
|
||||
from typing_extensions import Self
|
||||
|
||||
from langchain_fireworks._compat import _convert_from_v1_to_chat_completions
|
||||
from langchain_fireworks.data._profiles import _PROFILES
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
_MODEL_PROFILES = cast("ModelProfileRegistry", _PROFILES)
|
||||
|
||||
|
||||
def _get_default_model_profile(model_name: str) -> ModelProfile:
|
||||
default = _MODEL_PROFILES.get(model_name) or {}
|
||||
return default.copy()
|
||||
|
||||
|
||||
def _convert_dict_to_message(_dict: Mapping[str, Any]) -> BaseMessage:
|
||||
"""Convert a dictionary to a LangChain message.
|
||||
|
||||
@@ -404,6 +417,13 @@ class ChatFireworks(BaseChatModel):
|
||||
self.async_client._max_retries = self.max_retries
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def _set_model_profile(self) -> Self:
|
||||
"""Set model profile if not overridden."""
|
||||
if self.profile is None:
|
||||
self.profile = _get_default_model_profile(self.model_name)
|
||||
return self
|
||||
|
||||
@property
|
||||
def _default_params(self) -> dict[str, Any]:
|
||||
"""Get the default parameters for calling Fireworks API."""
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
"""Model profile data. All edits should be made in profile_augmentations.toml."""
|
||||
151
libs/partners/fireworks/langchain_fireworks/data/_profiles.py
Normal file
151
libs/partners/fireworks/langchain_fireworks/data/_profiles.py
Normal file
@@ -0,0 +1,151 @@
|
||||
"""Auto-generated model profiles.
|
||||
|
||||
DO NOT EDIT THIS FILE MANUALLY.
|
||||
This file is generated by the langchain-profiles CLI tool.
|
||||
|
||||
It contains data derived from the models.dev project.
|
||||
|
||||
Source: https://github.com/sst/models.dev
|
||||
License: MIT License
|
||||
|
||||
To update these data, refer to the instructions here:
|
||||
|
||||
https://docs.langchain.com/oss/python/langchain/models#updating-or-overwriting-profile-data
|
||||
"""
|
||||
|
||||
from typing import Any
|
||||
|
||||
_PROFILES: dict[str, dict[str, Any]] = {
|
||||
"accounts/fireworks/models/deepseek-r1-0528": {
|
||||
"max_input_tokens": 160000,
|
||||
"max_output_tokens": 16384,
|
||||
"image_inputs": False,
|
||||
"audio_inputs": False,
|
||||
"video_inputs": False,
|
||||
"image_outputs": False,
|
||||
"audio_outputs": False,
|
||||
"video_outputs": False,
|
||||
"reasoning_output": True,
|
||||
"tool_calling": True,
|
||||
},
|
||||
"accounts/fireworks/models/deepseek-v3p1": {
|
||||
"max_input_tokens": 163840,
|
||||
"max_output_tokens": 163840,
|
||||
"image_inputs": False,
|
||||
"audio_inputs": False,
|
||||
"video_inputs": False,
|
||||
"image_outputs": False,
|
||||
"audio_outputs": False,
|
||||
"video_outputs": False,
|
||||
"reasoning_output": True,
|
||||
"tool_calling": True,
|
||||
},
|
||||
"accounts/fireworks/models/minimax-m2": {
|
||||
"max_input_tokens": 128000,
|
||||
"max_output_tokens": 16384,
|
||||
"image_inputs": False,
|
||||
"audio_inputs": False,
|
||||
"video_inputs": False,
|
||||
"image_outputs": False,
|
||||
"audio_outputs": False,
|
||||
"video_outputs": False,
|
||||
"reasoning_output": True,
|
||||
"tool_calling": True,
|
||||
},
|
||||
"accounts/fireworks/models/deepseek-v3-0324": {
|
||||
"max_input_tokens": 160000,
|
||||
"max_output_tokens": 16384,
|
||||
"image_inputs": False,
|
||||
"audio_inputs": False,
|
||||
"video_inputs": False,
|
||||
"image_outputs": False,
|
||||
"audio_outputs": False,
|
||||
"video_outputs": False,
|
||||
"reasoning_output": False,
|
||||
"tool_calling": True,
|
||||
},
|
||||
"accounts/fireworks/models/kimi-k2-instruct": {
|
||||
"max_input_tokens": 128000,
|
||||
"max_output_tokens": 16384,
|
||||
"image_inputs": False,
|
||||
"audio_inputs": False,
|
||||
"video_inputs": False,
|
||||
"image_outputs": False,
|
||||
"audio_outputs": False,
|
||||
"video_outputs": False,
|
||||
"reasoning_output": False,
|
||||
"tool_calling": True,
|
||||
},
|
||||
"accounts/fireworks/models/qwen3-235b-a22b": {
|
||||
"max_input_tokens": 128000,
|
||||
"max_output_tokens": 16384,
|
||||
"image_inputs": False,
|
||||
"audio_inputs": False,
|
||||
"video_inputs": False,
|
||||
"image_outputs": False,
|
||||
"audio_outputs": False,
|
||||
"video_outputs": False,
|
||||
"reasoning_output": True,
|
||||
"tool_calling": True,
|
||||
},
|
||||
"accounts/fireworks/models/gpt-oss-20b": {
|
||||
"max_input_tokens": 131072,
|
||||
"max_output_tokens": 32768,
|
||||
"image_inputs": False,
|
||||
"audio_inputs": False,
|
||||
"video_inputs": False,
|
||||
"image_outputs": False,
|
||||
"audio_outputs": False,
|
||||
"video_outputs": False,
|
||||
"reasoning_output": True,
|
||||
"tool_calling": True,
|
||||
},
|
||||
"accounts/fireworks/models/gpt-oss-120b": {
|
||||
"max_input_tokens": 131072,
|
||||
"max_output_tokens": 32768,
|
||||
"image_inputs": False,
|
||||
"audio_inputs": False,
|
||||
"video_inputs": False,
|
||||
"image_outputs": False,
|
||||
"audio_outputs": False,
|
||||
"video_outputs": False,
|
||||
"reasoning_output": True,
|
||||
"tool_calling": True,
|
||||
},
|
||||
"accounts/fireworks/models/glm-4p5-air": {
|
||||
"max_input_tokens": 131072,
|
||||
"max_output_tokens": 131072,
|
||||
"image_inputs": False,
|
||||
"audio_inputs": False,
|
||||
"video_inputs": False,
|
||||
"image_outputs": False,
|
||||
"audio_outputs": False,
|
||||
"video_outputs": False,
|
||||
"reasoning_output": True,
|
||||
"tool_calling": True,
|
||||
},
|
||||
"accounts/fireworks/models/qwen3-coder-480b-a35b-instruct": {
|
||||
"max_input_tokens": 256000,
|
||||
"max_output_tokens": 32768,
|
||||
"image_inputs": False,
|
||||
"audio_inputs": False,
|
||||
"video_inputs": False,
|
||||
"image_outputs": False,
|
||||
"audio_outputs": False,
|
||||
"video_outputs": False,
|
||||
"reasoning_output": False,
|
||||
"tool_calling": True,
|
||||
},
|
||||
"accounts/fireworks/models/glm-4p5": {
|
||||
"max_input_tokens": 131072,
|
||||
"max_output_tokens": 131072,
|
||||
"image_inputs": False,
|
||||
"audio_inputs": False,
|
||||
"video_inputs": False,
|
||||
"image_outputs": False,
|
||||
"audio_outputs": False,
|
||||
"video_outputs": False,
|
||||
"reasoning_output": True,
|
||||
"tool_calling": True,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user