Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,35 @@ openssl rand -base64 32
使用场景生成、Realtime、TTS、ASR 或评分能力时,还需在 `.env` 中配置对应厂商凭证。
完整变量及安全默认值见 [`deploy/env/.env.example`](deploy/env/.env.example)。

### 2.1 本地启用 JD 图片 OCR

Web 的“上传图片”入口以服务端探测结果为准,不需要手动设置浏览器端的开关。后端本地运行时,先准备 Python 3.11、PaddleOCR 依赖和模型:

```bash
./scripts/prepare-local-ocr.sh
```

然后从 `backend/unispeaking-server` 启动后端,并把 OCR 路径指向仓库内的本地目录:

```bash
cd backend/unispeaking-server
OCR_ENABLED=true \
OCR_PYTHON_EXECUTABLE="$PWD/../../.local/ocr/venv/bin/python" \
OCR_RUNNER_PATH="$PWD/src/main/resources/ocr/paddle_ocr_runner.py" \
OCR_MODEL_DIRECTORY="$PWD/../../.local/ocr/models" \
MAVEN_REPO_URL=https://maven.aliyun.com/repository/public \
./mvnw --settings docker/maven/settings.xml spring-boot:run
```

启动后用浏览器访问 Web,在模拟面试页面选择“上传图片”。也可以用登录后的 JWT 进行接口实测:

```bash
OCR_ACCESS_TOKEN='登录后 localStorage 中的 unispeaking.accessToken' \
./scripts/check-local-ocr.sh /absolute/path/to/jd.png
```

脚本先验证 `/api/interview-scenes/ocr/availability`,再提交图片到 `/prepare-materials`;这样可以区分“服务端未装好 OCR”和“图片上传/材料整理链路失败”。

注意:

- 不要提交真实 `.env`。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,14 @@ private String buildLlmPrompt(
- VOCABULARY_EXPRESSION (0-100)

Produce an overall_score (0-100) as your comprehensive judgment across all five
dimensions, and a short summary narrative of the candidate's spoken English.
dimensions.

LANGUAGE REQUIREMENT: Write the natural-language values of ALL "evaluation",
"advice", and "summary" fields in Simplified Chinese. Do not return those
fields in English. Keep standard English linguistic terms, quoted candidate
English, and short English examples only when they are necessary as evidence;
these exceptions must be embedded in an otherwise Chinese explanation. The JSON
property names and score values must remain exactly as specified below.

Return exactly one JSON object and no Markdown or explanatory prose.
The JSON shape must be:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.unispeaking.common.exception.BusinessException;
import com.unispeaking.provider.AiProviderRegistry;
import com.unispeaking.provider.LlmProvider;
import com.unispeaking.provider.LlmResponseFormat;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URI;
Expand All @@ -13,6 +14,7 @@
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.List;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -82,26 +84,40 @@ public QwenLlmProvider(

@Override
public String executeLlmTask(String prompt, String token) {
return executeLlmTask(prompt, token, LlmResponseFormat.TEXT);
}

@Override
public String executeLlmTask(
String prompt,
String token,
LlmResponseFormat responseFormat) {
if (apiKey.isBlank()) {
throw retryableFailure(
"QWEN_LLM_CREDENTIAL_MISSING",
"Set DASHSCOPE_API_KEY before calling Qwen LLM");
}
return callForContent(prompt, apiKey);
return callForContent(prompt, apiKey, responseFormat);
}

private String callForContent(String promptValue, String credential) {
private String callForContent(
String promptValue,
String credential,
LlmResponseFormat responseFormat) {
String prompt = trim(promptValue);
if (prompt.isBlank()) {
throw nonRetryableFailure("INVALID_LLM_PROMPT", "LLM task prompt is required");
}
requireHttpsEndpoint();

try {
Map<String, Object> body = Map.of(
"model", model,
"messages", List.of(Map.of("role", "user", "content", prompt)),
"enable_thinking", false);
Map<String, Object> body = new LinkedHashMap<>();
body.put("model", model);
body.put("messages", List.of(Map.of("role", "user", "content", prompt)));
body.put("enable_thinking", false);
if (responseFormat == LlmResponseFormat.JSON_OBJECT) {
body.put("response_format", Map.of("type", "json_object"));
}
HttpRequest httpRequest = HttpRequest.newBuilder()
.uri(endpoint)
.timeout(readTimeout)
Expand Down
Loading
Loading