feat: Add LICENSE file and refactor MITM response handling and tracing.
This commit is contained in:
@@ -133,7 +133,8 @@ impl StreamingAccumulator {
|
||||
let args = fc["args"].clone();
|
||||
// thoughtSignature is a SIBLING of functionCall in the part,
|
||||
// not nested inside functionCall
|
||||
let thought_signature = part.get("thoughtSignature")
|
||||
let thought_signature = part
|
||||
.get("thoughtSignature")
|
||||
.and_then(|v| v.as_str())
|
||||
.map(|s| s.to_string());
|
||||
info!(
|
||||
@@ -155,7 +156,9 @@ impl StreamingAccumulator {
|
||||
// Capture non-thinking response text
|
||||
else {
|
||||
// Capture thoughtSignature from response parts (not function call parts)
|
||||
if let Some(sig) = part.get("thoughtSignature").and_then(|v| v.as_str()) {
|
||||
if let Some(sig) =
|
||||
part.get("thoughtSignature").and_then(|v| v.as_str())
|
||||
{
|
||||
self.thinking_signature = Some(sig.to_string());
|
||||
}
|
||||
if let Some(text) = part["text"].as_str() {
|
||||
@@ -619,7 +622,10 @@ data: {"response": {"candidates": [{"content": {"role": "model","parts": [{"text
|
||||
let event = "data: {\"response\": {\"candidates\": [{\"content\": {\"role\": \"model\", \"parts\": [{\"functionCall\": {\"name\": \"read_file\", \"args\": {\"path\": \"/foo\"}}}]}, \"finishReason\": \"FUNCTION_CALL\"}], \"usageMetadata\": {\"promptTokenCount\": 50, \"candidatesTokenCount\": 5, \"totalTokenCount\": 55}, \"modelVersion\": \"gemini-3-flash\"}}\n";
|
||||
parse_streaming_chunk(event, &mut acc);
|
||||
|
||||
assert!(acc.is_complete, "FUNCTION_CALL finishReason should set is_complete");
|
||||
assert!(
|
||||
acc.is_complete,
|
||||
"FUNCTION_CALL finishReason should set is_complete"
|
||||
);
|
||||
assert_eq!(acc.stop_reason, Some("FUNCTION_CALL".to_string()));
|
||||
assert_eq!(acc.function_calls.len(), 1);
|
||||
assert_eq!(acc.function_calls[0].name, "read_file");
|
||||
@@ -633,7 +639,10 @@ data: {"response": {"candidates": [{"content": {"role": "model","parts": [{"text
|
||||
let event = "data: {\"response\": {\"candidates\": [{\"content\": {\"role\": \"model\", \"parts\": [{\"text\": \"truncated...\"}]}, \"finishReason\": \"MAX_TOKENS\"}], \"usageMetadata\": {\"promptTokenCount\": 50, \"candidatesTokenCount\": 100, \"totalTokenCount\": 150}}}\n";
|
||||
parse_streaming_chunk(event, &mut acc);
|
||||
|
||||
assert!(acc.is_complete, "MAX_TOKENS finishReason should set is_complete");
|
||||
assert!(
|
||||
acc.is_complete,
|
||||
"MAX_TOKENS finishReason should set is_complete"
|
||||
);
|
||||
assert_eq!(acc.stop_reason, Some("MAX_TOKENS".to_string()));
|
||||
assert_eq!(acc.response_text, "truncated...");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user