-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 支持下国产大模型
- Loading branch information
Showing
13 changed files
with
90 additions
and
18 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 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
|
||
from typing import Any, List, Optional | ||
from langchain_openai import ChatOpenAI | ||
from langchain_core.utils.function_calling import convert_to_openai_tool | ||
|
||
from agent.llm import register_llm_client | ||
from agent.llm.base import BaseLLMClient | ||
|
||
from petercat_utils.data_class import MessageContent | ||
from petercat_utils import get_env_variable | ||
|
||
DEEPSEEK_API_KEY = get_env_variable("DEEPSEEK_API_KEY") | ||
|
||
|
||
@register_llm_client("deepseek") | ||
class DeepSeekClient(BaseLLMClient): | ||
_client: ChatOpenAI | ||
|
||
def __init__( | ||
self, | ||
temperature: Optional[float] = 0.2, | ||
n: Optional[int] = 1, | ||
top_p: Optional[float] = None, | ||
max_tokens: Optional[int] = 1500, | ||
streaming: Optional[bool] = False, | ||
api_key: Optional[str] = DEEPSEEK_API_KEY, | ||
): | ||
self._client = ChatOpenAI( | ||
model_name="deepseek-chat", | ||
temperature=temperature, | ||
n=n, | ||
top_p=top_p, | ||
streaming=streaming, | ||
max_tokens=max_tokens, | ||
openai_api_key=api_key, | ||
stream_usage=True, | ||
openai_api_base="https://api.deepseek.com" | ||
) | ||
|
||
def get_client(self): | ||
return self._client | ||
|
||
def get_tools(self, tools: List[Any]): | ||
return [convert_to_openai_tool(tool) for tool in tools] | ||
|
||
def parse_content(self, content: List[MessageContent]): | ||
print(f"parse_conent, content={content}") | ||
return content |
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