File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 11<?php
22// 这个文件用于对接阿里千问,解析编译报错和运行错误信息。
3- // 需要在db_info.inc.php中配置 $QWEN_API_KEY;
3+ // 需要在db_info.inc.php中配置 $OJ_AI_API_URL指向本文件;
44// 登录阿里云,打开 https://bailian.console.aliyun.com/?tab=model#/api-key 创建新的API KEY
55// 注意这个功能可能会导致阿里云付费账单,
66// 访问类似 https://bailian.console.aliyun.com/?tab=model#/model-market/detail/qwen3-coder-480b-a35b-instruct
77// 关注所用模型的剩余免费额度
88require_once ("../include/db_info.inc.php " );
9+ $ apiKey = "设置为阿里云的API-KEY " ; //https://bailian.console.aliyun.com/?tab=model#/api-key 创建新的API KEY
10+ $ models =array ("qwen-turbo " ,"qwen3-coder-480b-a35b-instruct " ,"qwen3-max " ,"qwen3-coder-30b-a3b-instruct " );
11+
12+
913$ sid =intval ($ _GET ['sid ' ]);
1014$ solution =pdo_query ("select user_id,problem_id from solution where solution_id=? " ,$ sid )[0 ];
1115$ user_id =$ solution [0 ];
5054// 设置请求的URL
5155$ url = 'https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions ' ;
5256// 若没有配置环境变量,请用百炼API Key将下行替换为:$apiKey = "sk-xxx";
53- $ apiKey = $ QWEN_API_KEY ;
57+
5458// 设置请求头
5559$ headers = [
5660 'Authorization: Bearer ' .$ apiKey ,
6165}else {
6266 $ code_suggestion ="不要直接给出完整代码,只给出问题原因,让我自己学习修改。分析我可能薄弱的知识点,问我一个提示性的相关问题。 " ;
6367}
64- $ models = array ( " qwen-turbo " , " qwen3-coder-480b-a35b-instruct " , " qwen3-max " , " qwen3-coder-30b-a3b-instruct " );
68+
6569$ model = $ models [array_rand ($ models )];
6670// 设置请求体
6771$ data = [
You can’t perform that action at this time.
0 commit comments