Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copilot docs on REST API response format incorrect for content #14326

Open
joeduffy opened this issue Mar 9, 2025 · 1 comment
Open

Copilot docs on REST API response format incorrect for content #14326

joeduffy opened this issue Mar 9, 2025 · 1 comment
Assignees
Labels
area/docs Improvements or additions to documentation kind/bug Some behavior is incorrect or out of spec
Milestone

Comments

@joeduffy
Copy link
Member

joeduffy commented Mar 9, 2025

The Copilot REST API docs say that content is a string.

In the case of code, it is not, however. For example, I am seeing an object:

        {
            "role": "assistant",
            "kind": "program",
            "content": {
                "code": "name: aws-ec2-python-webserver\nruntime: yaml\nvariables:\n  amazonLinuxAmi:\n    fn::invoke:\n      function: aws:ec2:getAmi\n      arguments:\n        filters:\n          - name: name\n            values: [\"amzn2-ami-hvm-*-x86_64-gp2\"]\n        owners: [\"137112412989\"]\n        mostRecent: true\nresources:\n  webServerSecurityGroup:\n    type: aws:ec2:SecurityGroup\n    properties:\n      description: Enable HTTP access\n      ingress:\n        - protocol: tcp\n          fromPort: 80\n          toPort: 80\n          cidrBlocks: [\"0.0.0.0/0\"]\n      egress:\n        - protocol: -1\n          fromPort: 0\n          toPort: 0\n          cidrBlocks: [\"0.0.0.0/0\"]\n  webServerRole:\n    type: aws:iam:Role\n    properties:\n      assumeRolePolicy: |\n        {\n          \"Version\": \"2012-10-17\",\n          \"Statement\": [\n            {\n              \"Action\": \"sts:AssumeRole\",\n              \"Principal\": {\n                \"Service\": \"ec2.amazonaws.com\"\n              },\n              \"Effect\": \"Allow\",\n              \"Sid\": \"\"\n            }\n          ]\n        }\n  webServerRolePolicy:\n    type: aws:iam:RolePolicy\n    properties:\n      role: ${webServerRole.name}\n      policy: |\n        {\n          \"Version\": \"2012-10-17\",\n          \"Statement\": [\n            {\n              \"Effect\": \"Allow\",\n              \"Action\": \"ec2:Describe*\",\n              \"Resource\": \"*\"\n            }\n          ]\n        }\n  webServerInstance:\n    type: aws:ec2:Instance\n    properties:\n      ami: ${amazonLinuxAmi.id}\n      instanceType: t2.micro\n      securityGroups: [${webServerSecurityGroup.name}]\n      iamInstanceProfile: ${webServerRole.name}\n      userData: |\n        #!/bin/bash\n        yum update -y\n        yum install -y python3\n        echo \"from http.server import SimpleHTTPRequestHandler, HTTPServer\" > /home/ec2-user/webserver.py\n        echo \"class Handler(SimpleHTTPRequestHandler):\" >> /home/ec2-user/webserver.py\n        echo \"    def do_GET(self):\" >> /home/ec2-user/webserver.py\n        echo \"        self.send_response(200)\" >> /home/ec2-user/webserver.py\n        echo \"        self.send_header('Content-type', 'text/html')\" >> /home/ec2-user/webserver.py\n        echo \"        self.end_headers()\" >> /home/ec2-user/webserver.py\n        echo \"        self.wfile.write(b'Hello, World')\" >> /home/ec2-user/webserver.py\n        echo \"httpd = HTTPServer(('0.0.0.0', 80), Handler)\" >> /home/ec2-user/webserver.py\n        echo \"httpd.serve_forever()\" >> /home/ec2-user/webserver.py\n        python3 /home/ec2-user/webserver.py\noutputs:\n  instancePublicIp: ${webServerInstance.publicIp}",
                "language": "YAML",
                "plan": {
                    "instructions": "Create a Pulumi YAML program to deploy a small AWS EC2 server running the latest Amazon Linux 2 AMI. The server should run a simple Python webserver accessible over the Internet that responds with 'Hello, World.'",
                    "searchTerms": [
                        "AWS EC2 instance",
                        "Amazon Linux 2 AMI",
                        "Python webserver",
                        "Pulumi YAML",
                        "security group",
                        "IAM role",
                        "user data script"
                    ]
                },
                "programMetadata": {
                    "programId": "",
                    "validationStatus": "unknown"
                }
            }
        }

Totally makes sense why, but we should clarify this in the docs.

@pulumi-bot pulumi-bot added the needs-triage Needs attention from the triage team label Mar 9, 2025
@github-project-automation github-project-automation bot moved this to 🤔 Triage in Docs 📚 Mar 9, 2025
@joeduffy joeduffy added the kind/bug Some behavior is incorrect or out of spec label Mar 9, 2025
@interurban interurban removed the status in Docs 📚 Mar 10, 2025
@interurban interurban moved this to 🧳 Backlog in Docs 📚 Mar 10, 2025
@interurban interurban added area/docs Improvements or additions to documentation and removed needs-triage Needs attention from the triage team labels Mar 10, 2025
@arturl arturl added this to the 0.118 milestone Mar 10, 2025
@arturl
Copy link
Member

arturl commented Mar 10, 2025

Will fix this sprint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs Improvements or additions to documentation kind/bug Some behavior is incorrect or out of spec
Projects
Status: 🧳 Backlog
Development

No branches or pull requests

4 participants