MCPcopy Create free account
hub / github.com/apache/impala / FindAssistantMessageInResponse

Function FindAssistantMessageInResponse

be/src/service/query-profile-ai-analysis.cc:564–586  ·  view source on GitHub ↗

Returns the assistant message object from common response envelope shapes.

Source from the content-addressed store, hash-verified

562
563// Returns the assistant message object from common response envelope shapes.
564static const Value* FindAssistantMessageInResponse(const Document& response_doc) {
565 if (response_doc.HasMember(JSON_KEY_ROLE) && response_doc[JSON_KEY_ROLE].IsString()) {
566 return &response_doc;
567 }
568 if (response_doc.HasMember(JSON_KEY_TOOL_CALLS)
569 || response_doc.HasMember(JSON_KEY_CONTENT)) {
570 return &response_doc;
571 }
572 if (response_doc.HasMember(JSON_KEY_MESSAGE)
573 && response_doc[JSON_KEY_MESSAGE].IsObject()) {
574 return &response_doc[JSON_KEY_MESSAGE];
575 }
576 if (response_doc.HasMember(JSON_KEY_CHOICES)
577 && response_doc[JSON_KEY_CHOICES].IsArray()) {
578 const Value& choices = response_doc[JSON_KEY_CHOICES];
579 if (!choices.Empty() && choices[0].IsObject()
580 && choices[0].HasMember(JSON_KEY_MESSAGE)
581 && choices[0][JSON_KEY_MESSAGE].IsObject()) {
582 return &choices[0][JSON_KEY_MESSAGE];
583 }
584 }
585 return nullptr;
586}
587
588// Extracts assistant content text from string or content-part array formats.
589static bool TryExtractAssistantContentText(

Callers 2

TESTFunction · 0.85

Calls 1

EmptyMethod · 0.45

Tested by 1

TESTFunction · 0.68