-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/gcr-custom' into xuhan/gcr-custom
- Loading branch information
Showing
9 changed files
with
115 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...lambda/online/common_logic/langchain_integration/models/chat_models/siliconflow_models.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import os | ||
import boto3 | ||
from common_logic.common_utils.constant import ( | ||
ModelProvider | ||
) | ||
from common_logic.common_utils.logger_utils import get_logger, llm_messages_print_decorator | ||
from . import Model | ||
from langchain_deepseek import ChatDeepSeek as _ChatDeepSeek | ||
from ..model_config import SILICONFLOW_DEEPSEEK_MODEL_CONFIGS | ||
|
||
logger = get_logger("siliconflow_models") | ||
|
||
class ChatDeepSeek(_ChatDeepSeek): | ||
enable_any_tool_choice: bool = False | ||
any_tool_choice_value: str = 'required' | ||
enable_prefill: bool = False | ||
|
||
|
||
class DeepSeekBaseModel(Model): | ||
default_model_kwargs = {"max_tokens": 2000, | ||
"temperature": 0.6, "top_p": 0.9} | ||
enable_any_tool_choice: bool = False | ||
enable_prefill: bool = False | ||
model_provider = ModelProvider.SILICONFLOW | ||
|
||
@classmethod | ||
def create_model(cls, model_kwargs=None, **kwargs): | ||
model_kwargs = model_kwargs or {} | ||
model_kwargs = {**cls.default_model_kwargs, **model_kwargs} | ||
# base_url = kwargs.get("base_url", None) or os.environ.get( | ||
# "OPENAI_BASE_URL", None) | ||
api_key = kwargs.get('siliconflow_api_key', None) or os.environ.get( | ||
"SILICONFLOW_API_KEY", None) | ||
return ChatDeepSeek( | ||
enable_any_tool_choice=cls.enable_any_tool_choice, | ||
enable_prefill=cls.enable_prefill, | ||
base_url="https://api.siliconflow.cn/v1", | ||
api_key=api_key, | ||
model=cls.model_id, | ||
**model_kwargs | ||
) | ||
|
||
|
||
DeepSeekBaseModel.create_for_models(SILICONFLOW_DEEPSEEK_MODEL_CONFIGS) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters