fix: ai_data_masking add compatibility handling for non-compliant API response structures (#2130)

This commit is contained in:
007gzs
2025-04-27 14:31:02 +08:00
committed by GitHub
parent 52114b37f8
commit e381806ba0
2 changed files with 7 additions and 1 deletions

View File

@@ -202,6 +202,7 @@ pub struct AiDataMaskingConfig {
#[derive(Debug, Deserialize, Clone)]
struct Message {
#[serde(default)]
content: String,
}
#[derive(Debug, Deserialize, Clone)]
@@ -221,8 +222,11 @@ struct ResMessage {
#[derive(Default, Debug, Deserialize, Serialize, Clone)]
struct Usage {
#[serde(default)]
completion_tokens: i32,
#[serde(default)]
prompt_tokens: i32,
#[serde(default)]
total_tokens: i32,
}

View File

@@ -299,7 +299,9 @@ data: {"id":"chatcmpl-936","object":"chat.completion.chunk","created":1739872012
data: {"id":"chatcmpl-936","object":"chat.completion.chunk","created":1739872012,"model":"qwen2.5-coder:32b","system_fingerprint":"fp_ollama","choices":[{"index":0,"delta":{"role":"assistant","content":"。"},"finish_reason":null}]}
data: {"id":"chatcmpl-936","object":"chat.completion.chunk","created":1739872012,"model":"qwen2.5-coder:32b","system_fingerprint":"fp_ollama","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":"stop"}]}
data: {"id":"chatcmpl-936","object":"chat.completion.chunk","created":1739872012,"model":"qwen2.5-coder:32b","system_fingerprint":"fp_ollama","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{}}
data: {"id":"chatcmpl-936","object":"chat.completion.chunk","created":1739872012,"model":"qwen2.5-coder:32b","system_fingerprint":"fp_ollama","choices":[{"index":0,"delta":{}}],"usage":{"prompt_tokens":372,"completion_tokens":9,"total_tokens":381}}
data: [DONE]