Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

An error occurred while attempting to correct template errors via AI #2253

@Finenyaco

Description

@Finenyaco

Describe the bug

An error occurred while attempting to correct template completions via AI

Steps to reproduce

  1. Fill in the OpenAI token in the settings.
  2. Go to Operations -> Templates -> AI Draft Template
  3. Generate a template and click 'Correction'.

Result

  1. An error occurred.
image
2024-03-15T01:18:09.056Z	D	correction message is not in the format requested by the prompt. output:
{
"corrected": "
provider \"alicloud\" {
  access_key = \"your_access_key\"
  secret_key = \"your_secret_key\"
  region     = \"ap-southeast-1\"
}

resource \"alicloud_vpc\" \"my_vpc\" {
  name       = \"my-vpc\"
  cidr_block = \"10.0.0.0/16\"
}

resource \"alicloud_vswitch\" \"my_vswitch\" {
  vpc_id            = alicloud_vpc.my_vpc.id
  cidr_block        = \"10.0.1.0/24\"
  availability_zone = \"cn-hangzhou-b\"
}

resource \"alicloud_instance\" \"my_instance\" {
  image_id          = \"ubuntu_18_04_64_20G_alibase_20200319.vhd\"
  instance_type     = \"ecs.t5-lc1m1.small\"
  security_groups   = [\"default\"]
  vswitch_id        = alicloud_vswitch.my_vswitch.id
  internet_charge_type = \"PayByTraffic\"
  internet_max_bandwidth_out = 5
}
",
"explanation": "Fixed the typo in 'vswitch_id' attribute of alicloud_instance resource. Corrected 'alicloud_vswitch.my_vswicth.id' to 'alicloud_vswitch.my_vswitch.id'."
}
2024-03-15T01:18:09.056Z	E	api	error requesting POST /v1/template-completions/_/correct: 1 error occurred:
	* failed to parse correction advice


github.com/seal-io/walrus/pkg/apis/runtime.erroring
	github.com/seal-io/walrus/pkg/apis/runtime/middleware_error.go:45
github.com/gin-gonic/gin.(*Context).Next
	github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/seal-io/walrus/pkg/apis/runtime.recovering
	github.com/seal-io/walrus/pkg/apis/runtime/middleware_recovery.go:39
github.com/gin-gonic/gin.(*Context).Next
	github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/seal-io/walrus/pkg/apis/runtime.observing
	github.com/seal-io/walrus/pkg/apis/runtime/middleware_observation.go:89
github.com/gin-gonic/gin.(*Context).Next
	github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest
	github.com/gin-gonic/gin@v1.9.1/gin.go:620
github.com/gin-gonic/gin.(*Engine).ServeHTTP
	github.com/gin-gonic/gin@v1.9.1/gin.go:576
github.com/seal-io/walrus/pkg/apis/runtime.(*Router).ServeHTTP
	github.com/seal-io/walrus/pkg/apis/runtime/router.go:194
net/http.serverHandler.ServeHTTP
	net/http/server.go:2938
net/http.initALPNRequest.ServeHTTP
	net/http/server.go:3546
net/http.(*http2serverConn).runHandler
	net/http/h2_bundle.go:6193
2024-03-15T01:18:09.056Z	D	api	500 | HTTP/2.0 |      769 B |      106 B |  5.440252843s |   192.168.247.1 | POST    /v1/template-completions/_/correct

Expected behavior

Environment

  • Walrus version: v0.6.0-rc2

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working in a real release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions