Spaces:
Sleeping
Sleeping
David Prince
fix: add all missing local module stubs (remote_mcp_registry, mcp_auth, mcp_transport, etc)
cce8120 | #!/usr/bin/env python3 | |
| import json | |
| import sys | |
| RAW_RESPONSE = { | |
| "id": "Root=test-contract", | |
| "object": "chat.completion", | |
| "model": "accounts/fireworks/models/deepseek-v4-flash-0731", | |
| "choices": [ | |
| { | |
| "index": 0, | |
| "message": { | |
| "role": "assistant", | |
| "content": "APPLICATION PROVIDER OK", | |
| "reasoning_content": ( | |
| 'We need to respond with exactly ' | |
| '"APPLICATION PROVIDER OK". No other text.' | |
| ), | |
| "tools": None, | |
| }, | |
| "finish_reason": "stop", | |
| } | |
| ], | |
| } | |
| def extract_assistant_content(payload: dict) -> str: | |
| choices = payload.get("choices") | |
| if not isinstance(choices, list) or not choices: | |
| raise ValueError("Provider returned no choices") | |
| choice = choices[0] | |
| if not isinstance(choice, dict): | |
| raise ValueError("Invalid provider choice") | |
| message = choice.get("message") | |
| if not isinstance(message, dict): | |
| raise ValueError("Provider response has no message object") | |
| content = message.get("content") | |
| if not isinstance(content, str): | |
| raise ValueError("Provider message.content is not a string") | |
| content = content.strip() | |
| if not content: | |
| raise ValueError("Provider message.content is empty") | |
| return content | |
| def main() -> int: | |
| content = extract_assistant_content(RAW_RESPONSE) | |
| assert content == "APPLICATION PROVIDER OK" | |
| assert content != RAW_RESPONSE["choices"][0]["message"]["reasoning_content"] | |
| print("[PASS] message.content extraction") | |
| print("[PASS] reasoning_content isolation") | |
| print("[PASS] non-empty assistant content") | |
| print(json.dumps({"assistant_content": content}, indent=2)) | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |