import logging as logging
logging.basicConfig(
level=logging.INFO, # 修改日志级别
format='%(asctime)s %(name)s [%(pathname)s line:%(lineno)d] %(levelname)s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S', # 日期时间格式
filename='log.txt', # 日志文件名
filemode='a+', # 日志模式,如:w:写、a+:追加写 等
encoding='utf-8' # 编码格式
)
# 禁用 httpx 的 INFO 级别日志
logging.getLogger('httpx').setLevel(logging.WARNING)
logging.getLogger('openai').setLevel(logging.WARNING)
d=self.agent_extract.get_prompts()[0]
p=d.format(** {"text": text})
logging.info(json.dumps({"模型输入": str( p), "模型输出": str(result)},ensure_ascii=False,indent=2))