Closed eladb closed 1 month ago
The issue here is some unescaped {
s and }
s on the second to last line. Using the newish uninterpolated string, this parsed correctly with the addition of a #
bring "./namer.w" as n;
bring cloud;
bring openai;
let oaik = new cloud.Secret(name: "OPENAI_KEY") as "openai_key";
let model = new openai.OpenAI(apiKeySecret: oaik) as "gpt_4o";
let namer = new n.Namer(model: model);
let examples = [
"this is the content i want to use to create a file name",
"this is another content i want to use to create a file name",
"this is a third content i want to use to create a file name",
"a poem about the ocean",
"a poem about the sky",
"some big string: 1234567890!@#$%^&*()_+",
];
new cloud.Function(inflight () => {
for e in examples {
let name = namer.makeFileName(e);
log(name);
}
});
bring expect;
test "create a file name" {
let response = namer.makeFileName("this is the content i want to use to create a file name");
expect.equal(response, {
"mock":{
"max_tokens":2048,
"model":"gpt-4o","messages":[{"role":"user","content":#"{\"make_filename\":{\"content\":\"this is the content i want to use to create a file name\",\"all_lowercase\":true,\"word_delimiter\":\"-\",\"ext\":\".txt\",\"output_min_length\":5,\"output_max_length\":20,\"output_allowed_chars\":\"a-z0-9-\"},\"output_instructions\":\"output only the file name itself with the .txt extension without any surrounding quotes or other characters\"}"}]}});
}
Unfortunetly since we use tree-sitter for parsing we are limited in what kind of auto-detection of this issue we can feasibly have. For this example specifically it may be useful to create Json literal and stringify it as needed.
I tried this:
This happened:
I expected this:
No response
Is there a workaround?
No response
Anything else?
No response
Wing Version
No response
Node.js Version
No response
Platform(s)
No response
Community Notes