123456789101112131415161718192021222324252627282930313233343536 |
- # For prerequisites running the following sample, visit https://help.aliyun.com/document_detail/611472.html
- import dashscope
- from dashscope import Generation
- from http import HTTPStatus
- import api
- dashscope.api_key=api.api_key
- response = Generation.call(
- model='dolly-12b-v2',
- prompt='翻一下:今天星期几拉拉。'
- )
- # The response status_code is HTTPStatus.OK indicate success,
- # otherwise indicate request is failed, you can get error code
- # and message from code and message.
- if response.status_code == HTTPStatus.OK:
- print(response.output) # The output text
- print(response.usage) # The usage information
- else:
- print(response.code) # The error code.
- print(response.message) # The error message.
- # {
- # "status_code": 200,
- # "request_id": "39a41abe-1bed-430a-b9b5-277130c7eb82",
- # "code": "",
- # "message": "",
- # "output": {
- # "text": "Spring has come, flowers blossomed."
- # },
- # "usage": {
- # "input_tokens": 0,
- # "output_tokens": 0
- # }
- # }
|