MCPcopy Create free account
hub / github.com/AsyncFuncAI/deepwiki-open / get_first_message_content

Function get_first_message_content

api/dashscope_client.py:68–88  ·  view source on GitHub ↗

When we only need the content of the first message.

(completion: ChatCompletion)

Source from the content-addressed store, hash-verified

66log = logging.getLogger(__name__)
67
68def get_first_message_content(completion: ChatCompletion) -> str:
69 """When we only need the content of the first message."""
70 log.info(f"🔍 get_first_message_content called with: {type(completion)}")
71 log.debug(f"raw completion: {completion}")
72
73 try:
74 if hasattr(completion, 'choices') and len(completion.choices) > 0:
75 choice = completion.choices[0]
76 if hasattr(choice, 'message') and hasattr(choice.message, 'content'):
77 content = choice.message.content
78 log.info(f"✅ Successfully extracted content: {type(content)}, length: {len(content) if content else 0}")
79 return content
80 else:
81 log.error("❌ Choice doesn't have message.content")
82 return str(completion)
83 else:
84 log.error("❌ Completion doesn't have choices")
85 return str(completion)
86 except Exception as e:
87 log.error(f"❌ Error in get_first_message_content: {e}")
88 return str(completion)
89
90
91def parse_stream_response(completion: ChatCompletionChunk) -> str:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected