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
2 changes: 1 addition & 1 deletion docs/palm-rust-unit-test-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ utgen/res/api.json
export PALM_CONFIG="$(pwd)/utgen/res/api.json"
```

当前 PALM 请求固定使用非流式输出、单个回答,并设置 `max_tokens=10000`、`temperature=1.0`、`top_p=0`。这些参数来自现有实现,整合时保持原样。
当前 PALM 请求固定使用非流式输出、单个回答,并设置 `max_tokens=10000`。采样使用所选模型的默认设置,不再发送写死的 `temperature=1.0` 和 `top_p=0`,以兼容拒绝这些可选参数的服务。

### 8.3 Prompt 构建

Expand Down
2 changes: 2 additions & 0 deletions utgen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Changing configuration takes effect on the next invocation without rebuilding. T

Generation and repair share one non-streaming request path. `--request-timeout <SECONDS>` defaults to 180 and covers each attempt, including its response body. Transport failures, HTTP 429 (except `insufficient_quota`), and 5xx responses get at most three attempts, with 1- and 2-second delays. Other HTTP errors and malformed/empty answers are returned without network retries. SDK retries are not layered underneath this policy; the existing request/response types are retained while the existing reqwest dependency executes HTTP requests.

Requests use the selected model's default sampling settings: PALM omits `temperature` and `top_p`, since some compatible services reject these optional parameters. The request still asks for one non-streaming answer with `max_tokens=10000`.

A valid answer without `usage` remains usable. Numeric token fields contain reported usage only; missing usage contributes no known tokens, which must not be interpreted as zero actual usage. The command writes `utgen/generation/gen-requests.json` or `fix-requests.json` with attempt/failure counts, missing-usage counts, reported token totals, and `usage_complete`. That flag is false after any failed attempt or response without usage. These files also cover requests whose answers failed later parsing. They are written after workers finish, including request failures; successful cached runs record zero attempts. Validation failures before any request leave the target untouched.

Formatting retries and compiler-guided repair rounds remain separate from transport retries. A final request failure, including during oracle generation or repair, fails the command and skips subsequent statistics. The request deadline does not terminate Cargo processes or impose a whole-function deadline.
Expand Down
14 changes: 6 additions & 8 deletions utgen/src/gene/llm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ impl LLM {
let request = CreateChatCompletionRequestArgs::default()
.model(&self.config.model)
.max_tokens(10000_u32)
.temperature(1.0)
.top_p(0_f32)
.n(1)
.stream(false)
.messages(messages)
Expand Down Expand Up @@ -335,8 +333,8 @@ mod tests {
fn check_request(request: &serde_json::Value) {
assert_eq!(request["model"], "local-model");
assert_eq!(request["max_tokens"], 10000);
assert_eq!(request["temperature"], 1.0);
assert_eq!(request["top_p"], 0.0);
assert!(request.get("temperature").is_none());
assert!(request.get("top_p").is_none());
assert_eq!(request["n"], 1);
assert_eq!(request["stream"], false);
}
Expand All @@ -346,8 +344,8 @@ mod tests {
// Set proxy variables only in child processes: changing the current
// process environment would race with parallel Rust tests.
for name in [
"gene::llm::tests::generation_uses_runtime_config_and_preserves_request_parameters",
"gene::llm::tests::repair_uses_runtime_config_and_preserves_request_parameters",
"gene::llm::tests::generation_uses_runtime_config_and_model_sampling_defaults",
"gene::llm::tests::repair_uses_runtime_config_and_model_sampling_defaults",
] {
let mut command = std::process::Command::new(std::env::current_exe().unwrap());
command.args([name, "--exact"]);
Expand All @@ -373,7 +371,7 @@ mod tests {
}

#[tokio::test]
async fn generation_uses_runtime_config_and_preserves_request_parameters() {
async fn generation_uses_runtime_config_and_model_sampling_defaults() {
let (llm, server) = mock_model().await;
let (answers, completion, prompt) = timeout(
Duration::from_secs(10),
Expand All @@ -391,7 +389,7 @@ mod tests {
}

#[tokio::test]
async fn repair_uses_runtime_config_and_preserves_request_parameters() {
async fn repair_uses_runtime_config_and_model_sampling_defaults() {
let (llm, server) = mock_model().await;
let (answers, completion, prompt) = timeout(
Duration::from_secs(10),
Expand Down
Loading