add safe_print
This commit is contained in:
parent
b8dcccbb1d
commit
de72321875
@ -279,6 +279,8 @@ async def create_agent_and_generate_response(
|
||||
messages: 消息列表
|
||||
config: AgentConfig 对象,包含所有参数
|
||||
"""
|
||||
config.safe_print()
|
||||
logger.info(f"messages={json.dumps(messages, ensure_ascii=False)}")
|
||||
config.preamble_text, config.system_prompt = get_preamble_text(config.language, config.system_prompt)
|
||||
|
||||
# 如果是流式模式,使用增强的流式响应生成器
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
"""Agent配置类,用于管理所有Agent相关的参数"""
|
||||
|
||||
from typing import Optional, List, Dict, Any
|
||||
from pydantic import BaseModel, Field
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
import json
|
||||
|
||||
logger = logging.getLogger('app')
|
||||
|
||||
@dataclass
|
||||
class AgentConfig:
|
||||
@ -53,6 +55,13 @@ class AgentConfig:
|
||||
'tool_response': self.tool_response,
|
||||
'preamble_text': self.preamble_text
|
||||
}
|
||||
|
||||
def safe_print(self):
|
||||
"""安全打印配置,避免打印敏感信息"""
|
||||
safe_dict = self.to_dict().copy()
|
||||
if 'api_key' in safe_dict and isinstance(safe_dict['api_key'], str) and safe_dict['api_key'].startswith('sk-'):
|
||||
safe_dict['api_key'] = safe_dict['api_key'][:8] + '***' + safe_dict['api_key'][-6:]
|
||||
logger.info(f"config={json.dumps(safe_dict, ensure_ascii=False)}")
|
||||
|
||||
@classmethod
|
||||
def from_v1_request(cls, request, api_key: str, project_dir: Optional[str] = None, generate_cfg: Optional[Dict] = None):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user