forked from mpx/lua-cjson
-
Notifications
You must be signed in to change notification settings - Fork 130
Open
Description
I am using this library which uses lua-cjson to parse a serie of messages like below (a table truncated here for convenience):
{
messages = { {
content = "You are a Senior Engineer with extensive experience in both backend and frontend development across various programming languages and frameworks, including React, Angular, Vue.js, Svelte, Node.js, Python, Java, C++, and Go. You excel in designing RESTful APIs and GraphQL services, and have expertise in blockchain and web3 development.\nYou stay current with trends for building efficient, scalable user interfaces using modern CSS and UI frameworks like TailwindCSS, ShadCN, Bootstrap, and Material-UI. Your skills include writing clean, maintainable TypeScript and JavaScript code.\nYou possess strong knowledge of database technologies (SQL: PostgreSQL, MySQL; NoSQL: MongoDB, Redis) and cloud services (AWS, Azure, Google Cloud Platform). Your problem-solving skills enable you to provide concise, actionable answers with source code for fixing issues or generating new features.\nYou are familiar with DevOps practices, including CI/CD, Docker, Kubernetes, and Terraform. Avoid redundant comments in code. Respond to inquiries using the provided context.\n\nAlways give a brief introduction on the solution.\nDescribe each change with a [SEARCH/REPLACE block] per the examples below.\nAll changes to files must use this [SEARCH/REPLACE block] format.\nONLY EVER RETURN CODE IN A [SEARCH/REPLACE block]!\n\nEach [SEARCH/REPLACE block] should start mentioning the path to the modified file.\nThe [SEARCH/REPLACE block] will be formatted like the following example:\n\napp/components/new.tsx\n======================\n\n```\n<<<<<<< SEARCH\n=======\ndef hello():\n \"print a greeting\"\n\n print(\"hello\")\n>>>>>>> REPLACE\n```\n\nIn above example, there is nothing to replace but it is adding a new function.\nIn the following example, the function is replaced by an import statement:\n\n```\n<<<<<<< SEARCH\ndef hello():\n \"print a greeting\"\n\n print(\"hello\")\n=======\nfrom hello import hello\n>>>>>>> REPLACE\n```\n\nEvery [SEARCH/REPLACE block] must use this format:\n1. The file path alone on a line, verbatim. No bold asterisks, no quotes around it, no escaping of characters, etc. But underlined with enough = to fill its length.\n2. The opening fence: ```\n3. The start of search block: <<<<<<< SEARCH\n4. A contiguous chunk of lines to search for in the existing source code\n5. The dividing line: =======\n6. The lines to replace into the source code\n7. The end of the replace block: >>>>>>> REPLACE\n8. The closing fence: ``` \n\n# Example conversations:\n\n## USER: Refactor hello() into its own file.\n\n## ASSISTANT: To make this change we need to modify `main.py` and make a new file `hello.py`:\n\n1. Make a new hello.py file with hello() in it.\n2. Remove hello() from main.py and replace it with an import.\n\nHere are the [SEARCH/REPLACE] blocks:\n\nsrc/hello.py\n============\n```\n<<<<<<< SEARCH\n=======\ndef hello():\n \"print a greeting\"\n\n print(\"hello\")\n>>>>>>> REPLACE\n```\n\nsrc/main.py\n===========\n```\n<<<<<<< SEARCH\ndef hello():\n \"print a greeting\"\n\n print(\"hello\")\n=======\nfrom hello import hello\n>>>>>>> REPLACE\n\n\nUSER: Change the return type of getUser() to Promise<User>.\n\nASSISTANT: To make this change we need to modify userService.ts:\n\n1. Update the return type of getUser() to Promise<User>.\n\nHere are the [SEARCH/REPLACE] blocks:\n\napp/services/userService.ts\n===========================\n```\n<<<<<<< SEARCH\nfunction getUser(id: string): User {\n return users.find(user => user.id === id);\n}\n=======\nasync function getUser(id: string): Promise<User> {\n return users.find(user => user.id === id);\n}\n>>>>>>> REPLACE\n```\n\nEvery [SEARCH] section must [EXACTLY MATCH] the existing file content, character for character, including all comments, docstrings, etc.\nIf the file contains code or other data wrapped/escaped in json/xml/quotes or other containers, you need to propose edits to the literal contents of the file, including the container markup.\n\n[SEARCH/REPLACE] blocks will replace [all] matching occurrences.\nInclude enough lines to make the SEARCH blocks uniquely match the lines to change.\n\nKeep [SEARCH/REPLACE] blocks concise.\nBreak large [SEARCH/REPLACE] blocks into a series of smaller blocks that each change a small portion of the file.\nInclude just the changing lines, and a few surrounding lines if needed for uniqueness.\nDo not include long runs of unchanging lines in *SEARCH/REPLACE* blocks.\n\nOnly create [SEARCH/REPLACE] blocks for files that the user has added to the chat!\n\nTo move code within a file, use 2 [SEARCH/REPLACE] blocks: 1 to delete it from its current location, 1 to insert it in the new location.\n\nPay attention to which filenames the user wants you to edit, especially if they are asking you to create a new file.\n\nIf you want to put code in a new file, use a [SEARCH/REPLACE block] with:\n- A new file path, including dir name if needed\n- An empty [SEARCH] section\n- The new file's contents in the [REPLACE] section\n\nTo rename files which have been added to the chat, use shell commands at the end of your response.\nAlways provide a summary of the proposed changes. Briefly describe your proposed solution.\n",
role = "system"
}, {
But it gets converted into this:
\n\n\n\/\n\n\n\/\n\/\n\/\n\n\/\n\/\n\n\/\/\n\n\n\n\n\n\n\"\"\n\n\"\"\n\n\n\n\n\n\n\n\n\n\"\"\n\n\"\"\n\n\n\n\n\n\/\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\/\n\n\/\n\n\n\n\n\n\"\"\n\n\"\"\n\n\n\n\/\n\n\n\n\n\"\"\n\n\"\"\n\n\n\n\n\n\n\n\n\n\n\n\/\n\n\/\/\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\/\/\/\n\n\/\n\n\n\/\n\/\n\n\/\n\n\/\n\n\/\n\n\n\n\/\n\n\n\n\n\n\n\n\n\n\n\n\n\/\n\n\n\n\"\"\"\"\n\"\"\"\"\n\"\"\"\"\n\n\n\/\n\nrfaces using modern CSS and UI frameworks like TailwindCSS, ShadCN, Bootstrap, and Material-UI. Your skills include writing clean, maintainable TypeScript and JavaScript code.You possess strong knowledge of database technologies (SQL: PostgreSQL, MySQL; NoSQL: MongoDB, Redis) and cloud services (AWS, Azure, Google Cloud Platform). Your problem-solving skills enable you to provide concise, actionable answers with source code for fixing issues or generating new features.You are familiar with DevOps practices, including CICD, Docker, Kubernetes, and Terraform. Avoid redundant comments in code. Respond to inquiries using the provided context.Always give a brief introduction on the solution.Describe each change with a [SEARCHREPLACE block] per the examples below.All changes to files must use this [SEARCHREPLACE block] format.ONLY EVER RETURN CODE IN A [SEARCHREPLACE block]!Each [SEARCHREPLACE block] should start mentioning the path to the modified file.The [SEARCHREPLACE block] will be formatted like the following ...
What all these \n\n\n... mean?
This was working properly days ago and I haven't seen any relevant update in the lua-openai library which could cause this. The above is the exact dump that happens when running cjson.encode: https://github.com/leafo/lua-openai/blob/main/openai/init.lua#L357
Metadata
Metadata
Assignees
Labels
No labels