LuteOrg / lute-v3

LUTE = Learning Using Texts: learn languages through reading.
https://luteorg.github.io/lute-manual/
MIT License
488 stars 46 forks source link

ChatGPT Integration #17

Open Mycheze opened 1 year ago

Mycheze commented 1 year ago

Is your feature request related to a problem? Please describe.

Many small issues with texts or dictionaries are easily solved by ChatGPT and a few prompts. But copy/pasting things between Lute and ChatGPT can be cumbersome and slow. It would be great to have the integrated a little.

Describe the solution you'd like

I would like to see a few ChatGPT features.

  1. Add ChatGPT similar to a dictionary source. When you click on a word/sentence, you have a button to send that variable (plus a predefined prompt) to ChatGPT and then receive a response. It would be great for looking up words that don't appear in your dictionary or for getting an explanation for something. ChatGPT can also provide cultural context or come up with mnemonics. There are tons of possibilities if it's configurable in the language settings.
  2. Allow ChatGPT to reformat pages. Since Lute only works on text, some of the pages can be imported weird, and it'd be really handy to have a button that just sends that text to ChatGPT, tells it to reformat it to better fit Lute, then to replace that page with the new response. There'd need to be some prompt engineering, but it would be very useful. I've personally been coming across lots of typos in the webnovels that I'm reading which ChatGPT would solve in an instant.

Additional context

Here're some example prompts that I've been using:

For defining stubborn words:

Help me translate this word as it doesn't appear in dictionaries.

The word is: olizovala

Format the response like this, but replace the capitalized words with the correct information:

WORD UNCONJUGATED, UNDECLINED DICTIONARY FORM OF THE WORD PART OF SPEECH

  1. TRANSLATION IN ENGLISH
  2. OTHER MEANING (ONLY IF APPLICABLE)

SHORT EXAMPLE SENTENCE USING THE WORD

VERY SHORT EXPLANATION OF THE SIGINIFICANCE OF THE WORD USING SIMPLE ENGLISH

For reformatting:

The following passage has a few typos and formatting issues. Please rewrite the passage exactly the same, but fix any typos and reformat it to be more readable. Keep all the "artistic" choices made by the author.

Here's the passage:

Shantibhushan95 commented 8 months ago

This enhancement should really be on the greatest priority list in my opinion. Achieving this will put Lute on steroids, and can possibly become THE greatest app there is for language learning.

Mycheze commented 8 months ago

I was actually thinking about this again today. I agree that this feature would be so killer and make Lute 10x more useful. Some more ideas and thoughts:

M-Biggles commented 8 months ago

I don't trust GPT-4 or any other AI to be accurate enough (it's known to just straight-out lie and make stuff up) for any language that doesn't already have good dictionaries.

It's good with English and other major languages. We have the dictionaries and grammars. It's inaccurate with smaller languages - we'd rather use something more accurate. What's the actual value here?

Mycheze commented 8 months ago

GPT-3.5 is much worse than 4. I've only seen 4 make a few mistakes with Czech. I've heard it's much worse for even smaller languages, but Czech isn't very big.

I disagree that most languages have good dictionaries and grammars that are actually useful for the average language learner. Frequently, looking up a word requires you to do 3-4 more lookups to sorta understand what you looked up. And I personally find "linguistic grammars" to be totally useless. I'd much prefer a short and simple explanation from GPT-4.

I don't care if it's occasionally wrong. Natives are as well. I've gotten conflicting (and flat out wrong) grammar explanations from native speakers. I use what it says as a guide to help my understanding. Plus, that single look up is less than .0001% of my time spent with the language.

If it's wrong 20% of the time or more, then yeah, you should probably use something else. But incorporating this feature earlier to straighten out bugs and problems will make it even more useful with GPT-5 and other models come around.

jzohrab commented 8 months ago

This enhancement should really be on the greatest priority list in my opinion.

So hard to say what the right priority is. There are some things which are "just features", which don't really push the envelope. Possibly this chatgpt is one of those features which does push the envelope, but there are others too. Some of the other pending requests feel more like foundational things, which should get priority over this, the biggest of which is #99 (changing how data is stored, which has many knock-on effects such as sharing books/vocab lists, reducing some parsing inconsistences, etc).

The challenges I see offhand with chatgpt -- or essentially any other service:

These are all just questions to explore the issue, not reasons to rule it out this idea. Cheers all, jz

Shantibhushan95 commented 8 months ago

So, I fiddled around a bit and without any substantial work, I got this sweet result. Just hosted another python server and used curl and OpenAI api, and added the localhost url as a dictionary link. chatgpt acts whimsically btw, sometimes gives a nice conjugation list and sometimes not :(

Screenshot 2024-02-22 at 19 42 20 Screenshot 2024-02-22 at 19 51 49 Screenshot 2024-02-22 at 19 54 14
Shantibhushan95 commented 8 months ago

Whole sentence selection :) (no change in code or prompt)

Screenshot 2024-02-22 at 20 50 05
Shantibhushan95 commented 8 months ago

Feel free to use as a makeshift feature: https://github.com/Shantibhushan95/lute-gpt-server

jzohrab commented 8 months ago

Hey there @Shantibhushan95 that looks pretty great! I’ll check out the code, thank you.

Shantibhushan95 commented 8 months ago

Also, @jzohrab I guess the Discord invite link is broken

jzohrab commented 8 months ago

Also, @jzohrab I guess the Discord invite link is broken

Whoops! What was the link you tried?

Shantibhushan95 commented 8 months ago

The one under Getting Started. https://discord.com/invite/CzFUQP5m8u Nevermind, logged in from Safari and it worked