-
Notifications
You must be signed in to change notification settings - Fork 9
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
🎨Unlossy AI translation #479
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,29 +15,33 @@ | |
"Answer the prompt in markdown format. Return JSON: " | ||
'{"answer": "Your markdown answer"}. ' | ||
"Do not provide any other information." | ||
"Preserve the language." | ||
), | ||
"correct": ( | ||
"Correct grammar and spelling of the markdown text, " | ||
"preserving language and markdown formatting. " | ||
'Return JSON: {"answer": "your corrected markdown text"}. ' | ||
"Do not provide any other information." | ||
"Preserve the language." | ||
), | ||
"rephrase": ( | ||
"Rephrase the given markdown text, " | ||
"preserving language and markdown formatting. " | ||
'Return JSON: {"answer": "your rephrased markdown text"}. ' | ||
"Do not provide any other information." | ||
"Preserve the language." | ||
), | ||
"summarize": ( | ||
"Summarize the markdown text, preserving language and markdown formatting. " | ||
'Return JSON: {"answer": "your markdown summary"}. ' | ||
"Do not provide any other information." | ||
"Preserve the language." | ||
), | ||
} | ||
|
||
AI_TRANSLATE = ( | ||
"Translate the markdown text to {language:s}, preserving markdown formatting. " | ||
'Return JSON: {{"answer": "your translated markdown text in {language:s}"}}. ' | ||
"Translate to {language:s} for every value of the json provided." | ||
"Keep the same json but with the value updated, keep the keys accordingly." | ||
"Do not provide any other information." | ||
) | ||
|
||
|
@@ -62,7 +66,7 @@ def call_ai_api(self, system_content, text): | |
response_format={"type": "json_object"}, | ||
messages=[ | ||
{"role": "system", "content": system_content}, | ||
{"role": "user", "content": json.dumps({"markdown_input": text})}, | ||
{"role": "user", "content": json.dumps({"answer": text})}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you keep using the answer keyword, although it is not the answer in this context but the input ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also it feels weird than when we already have structured json output in the translate case, we still pass it to the model within the answer json. |
||
], | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: wouldn't call this text in this context