|
| 1 | +import json |
| 2 | +import os |
| 3 | +import sys |
| 4 | + |
| 5 | +print("Checking quickstart agent output...") |
| 6 | + |
| 7 | +# Check NuGet package |
| 8 | +uipath_dir = ".uipath" |
| 9 | +if not os.path.exists(uipath_dir): |
| 10 | + print("NuGet package directory (.uipath) not found") |
| 11 | + sys.exit(1) |
| 12 | + |
| 13 | +nupkg_files = [f for f in os.listdir(uipath_dir) if f.endswith(".nupkg")] |
| 14 | +if not nupkg_files: |
| 15 | + print("NuGet package file (.nupkg) not found in .uipath directory") |
| 16 | + sys.exit(1) |
| 17 | + |
| 18 | +print(f"NuGet package found: {nupkg_files[0]}") |
| 19 | + |
| 20 | +# Check agent output file |
| 21 | +output_file = "__uipath/output.json" |
| 22 | +if not os.path.isfile(output_file): |
| 23 | + print("Agent output file not found") |
| 24 | + sys.exit(1) |
| 25 | + |
| 26 | +print("Agent output file found") |
| 27 | + |
| 28 | +# Check status and required fields |
| 29 | +try: |
| 30 | + with open(output_file, "r", encoding="utf-8") as f: |
| 31 | + output_data = json.load(f) |
| 32 | + |
| 33 | + # Check status |
| 34 | + status = output_data.get("status") |
| 35 | + if status != "successful": |
| 36 | + print(f"Agent execution failed with status: {status}") |
| 37 | + sys.exit(1) |
| 38 | + |
| 39 | + print("Agent execution status: successful") |
| 40 | + |
| 41 | + # Check required fields for quickstart agent |
| 42 | + if "output" not in output_data: |
| 43 | + print("Missing 'output' field in agent response") |
| 44 | + sys.exit(1) |
| 45 | + |
| 46 | + output_content = output_data["output"] |
| 47 | + if "joke" not in output_content: |
| 48 | + print("Missing 'joke' field in output") |
| 49 | + sys.exit(1) |
| 50 | + |
| 51 | + joke = output_content["joke"] |
| 52 | + if not joke or joke.strip() == "": |
| 53 | + print("Joke field is empty") |
| 54 | + sys.exit(1) |
| 55 | + |
| 56 | + if "critique" not in output_content: |
| 57 | + print("Missing 'critique' field in output") |
| 58 | + sys.exit(1) |
| 59 | + |
| 60 | + critique = output_content["critique"] |
| 61 | + if not critique or critique.strip() == "": |
| 62 | + print("Critique field is empty") |
| 63 | + sys.exit(1) |
| 64 | + |
| 65 | + print(f"Joke: {joke}") |
| 66 | + print(f"Critique: {critique}") |
| 67 | + |
| 68 | + print("Required fields validation passed") |
| 69 | + print("Quickstart agent working correctly.") |
| 70 | + |
| 71 | +except Exception as e: |
| 72 | + print(f"Error checking output: {e}") |
| 73 | + sys.exit(1) |
0 commit comments