mirror of
https://github.com/modelscope/modelscope.git
synced 2025-12-16 16:27:45 +01:00
* 1. add a challenge in chapter 2 as challenge 9 2. add a check_challenge.py script to makesure a challenge actually has answer 3. add blank lines to the file README_CN.md to look better * delete redundant function * code style check * code style check * style checkout change --------- Co-authored-by: DuskSwan <aquark@foxmail.com>
29 lines
912 B
Python
29 lines
912 B
Python
from app import challenges, generate_response
|
|
|
|
|
|
def check_answer(chap_idx,
|
|
challenge_idx,
|
|
input='input',
|
|
model_name='qwen-max'):
|
|
print('第{}章 第{}题'.format(chap_idx + 1, challenge_idx + 1))
|
|
challenge = challenges[chap_idx]['problems'][challenge_idx]
|
|
print(challenge['description'])
|
|
val_fn = challenge['validator']
|
|
response = generate_response(input, model_name)
|
|
try:
|
|
res = val_fn(response, input)
|
|
print('input:\n', input)
|
|
print('response:\n', response)
|
|
print('validation result: ', res)
|
|
except Exception:
|
|
import traceback
|
|
traceback.print_exc()
|
|
print('failed')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
chap = 5
|
|
ques = 1
|
|
input = '请使用“盛 夏”、“蝉 鸣”、“少 年”、“橘 子味汽水”这几个词造句'
|
|
check_answer(chap - 1, ques - 1, input)
|