mirror of
https://github.com/alibaba/higress.git
synced 2026-03-15 22:30:47 +08:00
fix: ai_data_masking add compatibility handling for non-compliant API response structures (#2130)
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user