千帆sdk安全认证AK/SK内置函数报警解决
大模型开发/技术交流
- 文心大模型
2023.11.291136看过
报警:setting config via specific function is deprecated, please get config with get_config() and set attributes directly
qianfan
1、官方的说明
通过内置函数初始化
# 通过内置函数传递(作用于全局,优先级大于环境变量)import qianfanqianfan.AccessKey("你的AccessKey") //我使用文件导入Conf.AccessKey ,这句引起报警qianfan.SecretKey("你的SecretKey") //我使用文件导入Conf.SecretKey,这句引起报警chat_comp = qianfan.ChatCompletion()resp = chat_comp.do(messages=[{"role": "user","content": "你好"}])print(resp)
执行后报警:
DeprecationWarning: setting config via specific function is deprecated, please get config with get_config() and set attributes directly
qianfan.AccessKey(Conf.AccessKey)
DeprecationWarning: setting config via specific function is deprecated, please get config with get_config() and set attributes directly
qianfan.SecretKey(Conf.SecretKey)
解决方法:
import qianfanfrom conf import Conf# qianfan.AccessKey(Conf.AccessKey)# qianfan.SecretKey(Conf.SecretKey)qianfan.config.get_config().ACCESS_KEY = Conf.AccessKey //get_config()解决方法qianfan.config.get_config().SECRET_KEY = Conf.SecretKey //get_config()解决方法chat_comp = qianfan.ChatCompletion()resp = chat_comp.do(messages=[{"role": "user","content": "你好"}])print(resp)
执行:
#千帆sdk #安全认证AK/SK
评论