Working on implementing batch commands for UE wingman
This commit is contained in:
@@ -57,9 +57,21 @@ def main():
|
||||
|
||||
try:
|
||||
parsed = json.loads(result)
|
||||
print(json.dumps(parsed, indent=2))
|
||||
except json.JSONDecodeError:
|
||||
print(result)
|
||||
print("Error: response is not valid JSON.")
|
||||
sys.exit(1)
|
||||
|
||||
if not isinstance(parsed, list):
|
||||
print("Error: response is not a list of content blocks.")
|
||||
sys.exit(1)
|
||||
for block in parsed:
|
||||
if not (isinstance(block, dict)
|
||||
and block.get("type") == "text"
|
||||
and isinstance(block.get("text"), str)):
|
||||
print("Error: response contains a non-text block.")
|
||||
sys.exit(1)
|
||||
|
||||
print("\n---\n".join(block["text"] for block in parsed))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user