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

bug of org-ai-refactor-code about utf8 encoding #132

Open
jixiuf opened this issue Oct 15, 2024 · 0 comments
Open

bug of org-ai-refactor-code about utf8 encoding #132

jixiuf opened this issue Oct 15, 2024 · 0 comments

Comments

@jixiuf
Copy link

jixiuf commented Oct 15, 2024

package demo

type StructDemo struct {
	A int // 字段A
}

I select struct StructDemo and M-x: org-ai-refactor-code with prompt:"add json tag"

then generated code become:

type StructDemo struct {
	A int `json:"A"` // \345\255\227\346\256\265A
}

If I replace (encode-coding-string (buffer-substring-no-properties start end) 'utf-8) with (buffer-substring-no-properties start end) in function org-ai--output-to-buffer
the bug gone .

another related bug:
when I apply the patch (after answer y or n ),would got

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
  org-ai--url-request-on-change-function(7699 8766 0)
  url-http-generic-filter(#<process api.openai.com> "424\15\ndata: {\"id\":\"chatcmpl-AITOdss8RF45QBj7dKT0u1RGSJ60k\",\"object\":\"chat.completion.chunk\",\"created\":1728966267,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_e2bde53e6e\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"a\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AITOdss8RF45QBj7dKT0u1RGSJ60k\",\"object\":\"chat.completion.chunk\",\"created\":1728966267,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_e2bde53e6e\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"\\n\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AITOdss8RF45QBj7dKT0u1RGSJ60k\",\"object\":\"chat.completion.chunk\",\"created\":1728966267,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_e2bde53e6e\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"}\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AITOdss8RF45QBj7dKT0u1RGSJ60k\",\"object\":\"chat.completion.chunk\",\"created\":1728966267,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_e2bde53e6e\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}]}\n\ndata: [DONE]\n\n\15\n")

GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, cairo version 1.18.0) of
2024-10-12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant