jasonjmcghee / plock

From anywhere you can type, query and stream the output of an LLM or any other script
MIT License
473 stars 31 forks source link

Generation skipping some characters #10

Closed nuaimat closed 9 months ago

nuaimat commented 10 months ago

Hello

in addition to the other issue i am facing (https://github.com/jasonjmcghee/plock/issues/9) whenever i generate text using either cmd+shift+. or cmd+shift+/ the generated text seems to be missing few characters from some words.

notice that i am running plock + ollama : openhermes2.5-mistral

see these two examples

  1. highlighted text: "what is the purpose of life" response: The purpose of life is a subjective and philosophical question, with various perspectives based on cultural, religious, and personal beliefs. Some common themes include self-fulfilment, personal growh contributing positvely to societ, and finding meanig i relationships and xperiences. Ulimately, each indivdual mus determine their ow sense o purpose. notice the misspelled words:

    • growh instead of growth
    • positvely instead of positively
    • societ instead of society
    • meanig instead of meaning all of them are missing one character
  2. highlighted text: "write a one line story about cryptocurrencies " response As the world embrace digital currency, ryptocurencies soared an crashed like wavesin a unpredictable sea. notice the misspelled words:

    • ryptocurencies instead of cryptocurencies
    • wavesin instead of "waves in"

it's strange that it doesn't happen on all cases. and i am not sure if it has to do with macos throttling typing of generated text or the code logic that transforms the ollama response stream.

asking the same questions to ollama directly: ollama run openhermes2.5-mistral

  1. prompt: what is the purpose of life response: The purpose of life is a subjective and philosophical question that has been debated throughout human history. Different people, cultures, and belief systems offer various answers to this question. Some believe life's purpose is to seek happiness, personal growth, or self-fulfillment. Others may see it as serving a higher power, contributing to society, or finding meaning in relationships and experiences. Ultimately, the purpose of life depends on an individual's values, beliefs, and personal journey.
  2. prompt: write a one line story about cryptocurrencies response: In a world ravaged by economic turmoil, cryptocurrencies emerged as a revolutionary digital asset, transforming the financial landscape forever.
jasonjmcghee commented 10 months ago

This is rough. Is this a dev build? Can you try adding "-- --release" if so? That's really only kicking the problem down the road.

We might need to find a more creative and/or lower level solution.

Or maybe a self-monitoring / self-correction mechanism of some sort.

Other things to try....

nuaimat commented 10 months ago

retried compiling with npm run tauri build '-- --release' then installed the generated app

and started it via command line, still same issue, some characters are still missing when generating.

jasonjmcghee commented 10 months ago

I added a new capability to paste the text after it finishes which won't have this problem. But that doesn't have the nice capability of real time streaming.

Another approach could be to pop up a window that it streams to, and then have an easy copy / paste. This would ensure nothing is missed.

See https://github.com/jasonjmcghee/plock/issues/15

nuaimat commented 10 months ago

whats strange is the generation text on terminal is fine, see: plock terminal output:

SELECTION: Some("Searches wikipedia for the given query, then returns the search results. This is a helper function.")
Whole output: def wiki_search(query):
    from bs4 import BeautifulSoup
    import requests
    url = f"https://en.wikipedia.org/wiki/Special:Search/{query}"
    response = requests.get(url)
    soup = BeautifulSoup(response.text, "html.parser")
    return soup.find_all("h3")[1:]

text output in a text editor:

def wiki_search(query):
    from bs4 import BeautifulSoup
    import requests
    url = f"https://en.wikipedia.org/wiki/Special:Search/{query}"
    response = requests.get(url)
    soup = Beautifuloup(response.tex, "html.parse")
    return sou.find_all(h3")[:]

notice "Beautifuloup" is misspelled inside the IDE, but it's fine on the terminal.

i strongly believe this bug has to do with the way the code is fetching response from ollama -> display it on the gui

jasonjmcghee commented 10 months ago

Sorry for not being clear- this is 100% enigo causing this issue. Like enigo::fast_text (now using enigo::text which calls it). I think it is either truncating incorrectly or getting io blocked and not confirming it outputted properly.

kgoodridge commented 9 months ago

Happening to me too. Could you chunk the streaming and do a short sleep between chunks? Totally ignorant guess.

kengoodridge commented 9 months ago

This fixed it for me...

do with it what you will...

https://github.com/jasonjmcghee/plock/pull/20/files

jasonjmcghee commented 9 months ago

@kengoodridge / @kgoodridge excited to review it- Welcome to developing plock- happy you’re here!

jasonjmcghee commented 9 months ago

https://github.com/enigo-rs/enigo/issues/260

jasonjmcghee commented 9 months ago

I believe this is fixed - going to cut a new version