16 lines
769 B
Python
16 lines
769 B
Python
import os
|
||
from http import HTTPStatus
|
||
from dashscope import Application
|
||
response = Application.call(
|
||
# 若没有配置环境变量,可用百炼API Key将下行替换为:api_key="sk-xxx"。但不建议在生产环境中直接将API Key硬编码到代码中,以减少API Key泄露风险。
|
||
api_key="sk-bf61ff61d4fc496a8e97b165e8f1b4d3",
|
||
app_id='1718ca5a4fb740a289bc5487ab96a11b',
|
||
prompt='你们公司的常用箱变的容量是多少')
|
||
|
||
if response.status_code != HTTPStatus.OK:
|
||
print(f'request_id={response.request_id}')
|
||
print(f'code={response.status_code}')
|
||
print(f'message={response.message}')
|
||
print(f'请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code')
|
||
else:
|
||
print(response.output.text) |