Skip to content

Commit a211df0

Browse files
authored
Update qwen.php
1 parent 4ebca47 commit a211df0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

trunk/web/aiapi/qwen.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
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
// 关注所用模型的剩余免费额度
88
require_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];
@@ -50,7 +54,7 @@
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,
@@ -61,7 +65,7 @@
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 = [

0 commit comments

Comments
 (0)