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

To-do: Return the translated content gracefully. #29

Open
MitsuhaMiyamizu opened this issue Jun 6, 2024 · 1 comment
Open

To-do: Return the translated content gracefully. #29

MitsuhaMiyamizu opened this issue Jun 6, 2024 · 1 comment

Comments

@MitsuhaMiyamizu
Copy link
Contributor

MitsuhaMiyamizu commented Jun 6, 2024

It's frustrated to hardcode the exact position where the translated content located in returned format each time we adapt to the API of specific platform, i.e., lots of platform adopt JSON format the way like OpenAI (see: https://platform.openai.com/docs/api-reference/making-requests).

This is sort of good and it really reduces time developers spent on wrangling with the JSON output and work on other problems using the rest of their time. HOWEVER, some platform just don't, see:

jsonlite::fromJSON(res_temp[[x]]$data)$choices$delta$content

This is extremely FRUSTRATING! We shouldn't hardcode this in our code, instead, we should adopt more self-adaptive and graceful method. Think JSON as a tree structure, basically we should iterate this recursively to find all the leaves on the tree, see if it contains contents.

@GuangchuangYu
Copy link
Member

Somehow we can unify the get_translate_text() function with this idea. https://github.com/search?q=repo%3AYuLab-SMU%2Ffanyi%20get_translate_text&type=code

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

2 participants