Skip to content

feat: 支持 v4 所需的 json_object 格式化输出#206

Merged
MagicalAstrogy merged 2 commits into
betafrom
mag/v4_comp
Jun 20, 2026
Merged

feat: 支持 v4 所需的 json_object 格式化输出#206
MagicalAstrogy merged 2 commits into
betafrom
mag/v4_comp

Conversation

@MagicalAstrogy

@MagicalAstrogy MagicalAstrogy commented Jun 20, 2026

Copy link
Copy Markdown
Owner
image

@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

🔍 PR Test Report

🧪 Test Results

✅ All tests passed!

Type Passed Failed Total
Test Suites 17 0 17
Tests 394 0 394

📊 Coverage Report

Metric Coverage Details
Lines 63.97% 1229/1921
Statements 63.59% 1254/1972
Functions 63.5% 134/211
Branches 62.44% 622/996

Coverage Thresholds

  • ✅ Lines: 63.97% (Passed, threshold: 50%)
  • ✅ Statements: 63.59% (Passed, threshold: 50%)
  • ✅ Functions: 63.5% (Passed, threshold: 50%)
  • ✅ Branches: 62.44% (Passed, threshold: 50%)

Generated at 2026-06-20T13:04:08.019Z

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9d5d8b7492

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +113 to +115
oai_settings.custom_include_body = buildJsonObjectCustomIncludeBody(original_body);
try {
await saveSillyTavernSettings();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid applying json_object to unrelated generations

When v4-compatible extra analysis overlaps with a normal Custom/OpenAI-compatible generation, this assignment writes response_format: json_object into global SillyTavern.chatCompletionSettings and persists it before the extra request completes. Any unrelated request started before restoreTemporaryJsonObjectResponseFormat() runs will inherit the JSON-only response format and can return JSON/error instead of the user-facing prose; keep this override scoped to the extra-model request rather than global settings.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这没办法。

}

const { had_original_body, original_body } = temporary_json_object_response_format_state;
temporary_json_object_response_format_state = null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep restore state until settings save succeeds

If saveSettings() fails while restoring after a successful temporary save, this line has already dropped the only copy of the original custom_include_body, so the persisted settings can remain stuck with response_format: json_object and later reloads keep affecting normal generations. Keep the state until the restore save succeeds (or restore it in a catch) so a failure can be retried.

Useful? React with 👍 / 👎.

@MagicalAstrogy

Copy link
Copy Markdown
Owner Author

LGFM

@MagicalAstrogy MagicalAstrogy merged commit b27de9c into beta Jun 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant